### Question:
DefaultCopierFactoryManager implements com.hotels.bdp.circustrain.api.copier.CopierFactoryManager { @Override public CopierFactory getCopierFactory(Path sourceLocation, Path replicaLocation, Map<String, Object> copierOptions) { String sourceScheme = sourceLocation.toUri().getScheme(); String replicaScheme = replicaLocation.toUri().getScheme(); if (copierOptions.containsKey(COPIER_FACTORY_CLASS)) { for (CopierFactory copierFactory : copierFactories) { final String copierFactoryClassName = copierFactory.getClass().getName(); if (copierFactoryClassName.equals(copierOptions.get(COPIER_FACTORY_CLASS).toString())) { LOG.debug("Found CopierFactory '{}' using config", copierFactoryClassName); return copierFactory; } } } else { for (CopierFactory copierFactory : copierFactories) { final String copierFactoryClassName = copierFactory.getClass().getName(); if (copierFactory.supportsSchemes(sourceScheme, replicaScheme)) { LOG .debug("Found CopierFactory '{}' for sourceScheme '{}' and replicaScheme '{}'", copierFactoryClassName, sourceScheme, replicaScheme); return copierFactory; } } } throw new UnsupportedOperationException("No CopierFactory that suppports sourceScheme '" + sourceScheme + "' and replicaScheme '" + replicaScheme + "'"); } @Autowired  DefaultCopierFactoryManager(List<CopierFactory> copierFactories); @Override CopierFactory getCopierFactory(Path sourceLocation, Path replicaLocation, Map<String, Object> copierOptions);  }### Answer:
@Test public void supportsScheme() { defaultCopierFactoryManager = new DefaultCopierFactoryManager(Arrays.asList(copierFactory)); when(copierFactory.supportsSchemes(SCHEME, SCHEME)).thenReturn(true); CopierFactory copierFactoryResult = defaultCopierFactoryManager.getCopierFactory(path, path, ImmutableMap.<String, Object> of()); assertEquals(copierFactory, copierFactoryResult); }
@Test(expected = UnsupportedOperationException.class) public void doesNotSupportScheme() { defaultCopierFactoryManager = new DefaultCopierFactoryManager(Arrays.asList(copierFactory)); when(copierFactory.supportsSchemes(SCHEME, SCHEME)).thenReturn(false); defaultCopierFactoryManager.getCopierFactory(path, path, ImmutableMap.<String, Object> of()); }
@Test public void supportsSchemeWithCopierFactoryClass() { CopierFactory testCopierFactory = new TestCopierFactory(); defaultCopierFactoryManager = new DefaultCopierFactoryManager(Arrays.asList(testCopierFactory)); CopierFactory copierFactoryResult = defaultCopierFactoryManager.getCopierFactory(path, path, ImmutableMap.<String, Object> of("copier-factory-class", testCopierFactory.getClass().getName())); assertEquals(copierFactoryResult, testCopierFactory); }
@Test(expected = UnsupportedOperationException.class) public void supportsSchemeWithCopierFactoryClassNotFound() { CopierFactory testCopierFactory = new TestCopierFactory(); defaultCopierFactoryManager = new DefaultCopierFactoryManager(Arrays.asList(testCopierFactory)); defaultCopierFactoryManager.getCopierFactory(path, path, ImmutableMap.<String, Object> of("copier-factory-class", "test")); }