### Question:
DefaultDataManipulatorFactoryManager implements DataManipulatorFactoryManager { @Override public DataManipulatorFactory getFactory( Path sourceTableLocation, Path replicaTableLocation, Map<String, Object> copierOptions) { String replicaLocation = replicaTableLocation.toUri().getScheme(); String sourceLocation = sourceTableLocation.toUri().getScheme(); if (copierOptions.containsKey(DATA_MANIPULATOR_FACTORY_CLASS)) { for (DataManipulatorFactory factory : dataManipulatorFactories) { final String factoryClassName = factory.getClass().getName(); if (factoryClassName.equals(copierOptions.get(DATA_MANIPULATOR_FACTORY_CLASS).toString())) { log.debug("Found DataManipulatorFactory '{}' using config", factoryClassName); return factory; } } } else { for (DataManipulatorFactory factory : dataManipulatorFactories) { if (factory.supportsSchemes(sourceLocation, replicaLocation)) { log .debug("Found DataManipulatorFactory {} for cleanup at location {}.", factory.getClass().getName(), replicaLocation); return factory; } } } throw new UnsupportedOperationException( "No DataManipulator found which can delete the data at location: " + replicaLocation); } @Autowired  DefaultDataManipulatorFactoryManager(List<DataManipulatorFactory> factories); @Override DataManipulatorFactory getFactory(
      Path sourceTableLocation,
      Path replicaTableLocation,
      Map<String, Object> copierOptions);  }### Answer:
@Test public void s3ManipulatorReturnedForS3S3Copy() { replicaLocation = new Path(s3Path); dataManipulatorFactory = manager.getFactory(sourceLocation, replicaLocation, copierOptions); assertEquals(S3_S3, ((TestDataManipulatorFactory) dataManipulatorFactory).getType()); }
@Test public void awsMapReduceManipulatorReturnedForHdfsS3Copy() { sourceLocation = new Path(hdfsPath); replicaLocation = new Path(s3Path); dataManipulatorFactory = manager.getFactory(sourceLocation, replicaLocation, copierOptions); assertEquals(S3_MAPREDUCE, ((TestDataManipulatorFactory) dataManipulatorFactory).getType()); }
@Test public void hdfsManipulatorReturnedForHdfsCopy() { sourceLocation = new Path(hdfsPath); replicaLocation = new Path(hdfsPath); dataManipulatorFactory = manager.getFactory(sourceLocation, replicaLocation, copierOptions); assertEquals(HDFS, ((TestDataManipulatorFactory) dataManipulatorFactory).getType()); }
@Test public void dataManipulatorReturnedFromCopierOption() { replicaLocation = new Path(hdfsPath); TestDataManipulatorFactory testFactory = new TestDataManipulatorFactory(HDFS); manager = new DefaultDataManipulatorFactoryManager(Arrays.asList(testFactory)); copierOptions.put(DATA_MANIPULATOR_FACTORY_CLASS, testFactory.getClass().getName()); dataManipulatorFactory = manager.getFactory(sourceLocation, replicaLocation, copierOptions); assertEquals(dataManipulatorFactory, testFactory); }
@Test(expected = UnsupportedOperationException.class) public void noSupportingFactory() { replicaLocation = new Path("<path>"); dataManipulatorFactory = manager.getFactory(sourceLocation, replicaLocation, copierOptions); assertTrue(((TestDataManipulatorFactory) dataManipulatorFactory).getType() == HDFS); }