### Question:
SchemaCopier { public Path copy(String source, String destination, EventTableReplication eventTableReplication, String eventId) { checkNotNull(source, "source cannot be null"); checkNotNull(destination, "destinationFolder cannot be null"); FileSystemPathResolver sourceFileSystemPathResolver = new FileSystemPathResolver(sourceHiveConf); Path sourceLocation = new Path(source); sourceLocation = sourceFileSystemPathResolver.resolveScheme(sourceLocation); sourceLocation = sourceFileSystemPathResolver.resolveNameServices(sourceLocation); Path destinationSchemaFile = new Path(destination, sourceLocation.getName()); Map<String, Object> mergedCopierOptions = new HashMap<>(TableReplication .getMergedCopierOptions(globalCopierOptions.getCopierOptions(), eventTableReplication.getCopierOptions())); mergedCopierOptions.put(CopierOptions.COPY_DESTINATION_IS_FILE, "true"); CopierFactory copierFactory = copierFactoryManager .getCopierFactory(sourceLocation, destinationSchemaFile, mergedCopierOptions); LOG.info("Replicating Avro schema from '{}' to '{}'", sourceLocation, destinationSchemaFile); CopierContext copierContext = new CopierContext(eventId, sourceLocation, destinationSchemaFile, mergedCopierOptions); Copier copier = copierFactory.newInstance(copierContext); Metrics metrics = copier.copy(); LOG .info("Avro schema '{} bytes' has been copied from '{}' to '{}'", metrics.getBytesReplicated(), sourceLocation, destinationSchemaFile); return destinationSchemaFile; } @Autowired  SchemaCopier(
      Configuration sourceHiveConf,
      CopierFactoryManager copierFactoryManager,
      CopierOptions globalCopierOptions); Path copy(String source, String destination, EventTableReplication eventTableReplication, String eventId);  }### Answer:
@Test public void copiedToCorrectDestination() throws IOException { Path source = new Path(temporaryFolder.newFile("test.txt").toURI()); File destination = temporaryFolder.newFolder(); Path targetFile = new Path(destination.toString(), "test.txt"); Map<String, Object> copierOptionsMap = new HashMap<>(); copierOptionsMap.put(CopierOptions.COPY_DESTINATION_IS_FILE, "true"); when(copierFactoryManager.getCopierFactory(eq(source), eq(targetFile), eq(copierOptionsMap))) .thenReturn(copierFactory); when(copierFactory.newInstance(any(CopierContext.class))).thenReturn(copier); when(copier.copy()).thenReturn(metrics); when(metrics.getBytesReplicated()).thenReturn(123L); Path result = schemaCopier.copy(source.toString(), destination.toString(), eventTableReplication, eventId); assertThat(result, is(targetFile)); }
@Test(expected = NullPointerException.class) public void copyWithNullSourceParamThrowsException() throws IOException { File destination = temporaryFolder.newFolder(); schemaCopier.copy(null, destination.toString(), eventTableReplication, eventId); }
@Test(expected = IllegalArgumentException.class) public void copyWithEmptySourceParamThrowsException() throws IOException { File destination = temporaryFolder.newFolder(); schemaCopier.copy("", destination.toString(), eventTableReplication, eventId); }
@Test(expected = NullPointerException.class) public void copyWithNullDestinationParamThrowsException() throws IOException { File source = temporaryFolder.newFile("test.txt"); schemaCopier.copy(source.toString(), null, eventTableReplication, eventId); }
@Test(expected = IllegalArgumentException.class) public void copyWithEmptyDestinationParamThrowsException() throws IOException { File source = temporaryFolder.newFile("test.txt"); schemaCopier.copy(source.toString(), "", eventTableReplication, eventId); }