@Test(expected = IllegalArgumentException.class) public void should_fail_to_copy_to_directory_unsupported_location() { Locators locators = new Locators(mock(FileSystem.class), mock(Artifactory.class)); locators.copyToDirectory(new UnsupportedLocation(), new File("destination")); }
public File copyToDirectory(Location location, File toDir) { File file; if (location instanceof FileLocation) { file = fileLocator.copyToDirectory((FileLocation) location, toDir); } else if (location instanceof MavenLocation) { file = mavenLocator.copyToDirectory((MavenLocation) location, toDir); } else if (location instanceof ResourceLocation) { file = resourceLocator.copyToDirectory((ResourceLocation) location, toDir); } else if (location instanceof URLLocation) { file = urlLocator.copyToDirectory((URLLocation) location, toDir); } else { throw throwNotSupported(location); } return file; }
Locators { public File copyToDirectory(Location location, File toDir) { File file; if (location instanceof FileLocation) { file = fileLocator.copyToDirectory((FileLocation) location, toDir); } else if (location instanceof MavenLocation) { file = mavenLocator.copyToDirectory((MavenLocation) location, toDir); } else if (location instanceof ResourceLocation) { file = resourceLocator.copyToDirectory((ResourceLocation) location, toDir); } else if (location instanceof URLLocation) { file = urlLocator.copyToDirectory((URLLocation) location, toDir); } else { throw throwNotSupported(location); } return file; } }
Locators { public File copyToDirectory(Location location, File toDir) { File file; if (location instanceof FileLocation) { file = fileLocator.copyToDirectory((FileLocation) location, toDir); } else if (location instanceof MavenLocation) { file = mavenLocator.copyToDirectory((MavenLocation) location, toDir); } else if (location instanceof ResourceLocation) { file = resourceLocator.copyToDirectory((ResourceLocation) location, toDir); } else if (location instanceof URLLocation) { file = urlLocator.copyToDirectory((URLLocation) location, toDir); } else { throw throwNotSupported(location); } return file; } Locators(FileSystem fileSystem, Artifactory artifactory);   Locators(FileLocator fileLocator, MavenLocator mavenLocator, ResourceLocator resourceLocator, URLLocator urlLocator); }
Locators { public File copyToDirectory(Location location, File toDir) { File file; if (location instanceof FileLocation) { file = fileLocator.copyToDirectory((FileLocation) location, toDir); } else if (location instanceof MavenLocation) { file = mavenLocator.copyToDirectory((MavenLocation) location, toDir); } else if (location instanceof ResourceLocation) { file = resourceLocator.copyToDirectory((ResourceLocation) location, toDir); } else if (location instanceof URLLocation) { file = urlLocator.copyToDirectory((URLLocation) location, toDir); } else { throw throwNotSupported(location); } return file; } Locators(FileSystem fileSystem, Artifactory artifactory);   Locators(FileLocator fileLocator, MavenLocator mavenLocator, ResourceLocator resourceLocator, URLLocator urlLocator); MavenLocator maven(); File locate(Location location); File copyToDirectory(Location location, File toDir); File copyToFile(Location location, File toFile); InputStream openInputStream(Location location); }
Locators { public File copyToDirectory(Location location, File toDir) { File file; if (location instanceof FileLocation) { file = fileLocator.copyToDirectory((FileLocation) location, toDir); } else if (location instanceof MavenLocation) { file = mavenLocator.copyToDirectory((MavenLocation) location, toDir); } else if (location instanceof ResourceLocation) { file = resourceLocator.copyToDirectory((ResourceLocation) location, toDir); } else if (location instanceof URLLocation) { file = urlLocator.copyToDirectory((URLLocation) location, toDir); } else { throw throwNotSupported(location); } return file; } Locators(FileSystem fileSystem, Artifactory artifactory);   Locators(FileLocator fileLocator, MavenLocator mavenLocator, ResourceLocator resourceLocator, URLLocator urlLocator); MavenLocator maven(); File locate(Location location); File copyToDirectory(Location location, File toDir); File copyToFile(Location location, File toFile); InputStream openInputStream(Location location);  }