@Test public void should_copy_to_directory_with_resource_locator() { ResourceLocation location = mock(ResourceLocation.class); File expectedFile = new File("found"); when(resourceLocator.copyToDirectory(location, new File("destination"))).thenReturn(expectedFile); File actualFile = locators.copyToDirectory(location, new File("destination")); assertThat(actualFile).isSameAs(expectedFile); }
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);  }