@Test public void should_open_stream_with_file_locator() { FileLocation location = mock(FileLocation.class); InputStream expectedStream = mock(InputStream.class); when(fileLocator.openInputStream(location)).thenReturn(expectedStream); InputStream actualStream = locators.openInputStream(location); assertThat(actualStream).isSameAs(expectedStream); }
public InputStream openInputStream(Location location) { InputStream input; if (location instanceof FileLocation) { input = fileLocator.openInputStream((FileLocation) location); } else if (location instanceof MavenLocation) { input = mavenLocator.openInputStream((MavenLocation) location); } else if (location instanceof ResourceLocation) { input = resourceLocator.openInputStream((ResourceLocation) location); } else if (location instanceof URLLocation) { input = urlLocator.openInputStream((URLLocation) location); } else { throw throwNotSupported(location); } return input; }
Locators { public InputStream openInputStream(Location location) { InputStream input; if (location instanceof FileLocation) { input = fileLocator.openInputStream((FileLocation) location); } else if (location instanceof MavenLocation) { input = mavenLocator.openInputStream((MavenLocation) location); } else if (location instanceof ResourceLocation) { input = resourceLocator.openInputStream((ResourceLocation) location); } else if (location instanceof URLLocation) { input = urlLocator.openInputStream((URLLocation) location); } else { throw throwNotSupported(location); } return input; } }
Locators { public InputStream openInputStream(Location location) { InputStream input; if (location instanceof FileLocation) { input = fileLocator.openInputStream((FileLocation) location); } else if (location instanceof MavenLocation) { input = mavenLocator.openInputStream((MavenLocation) location); } else if (location instanceof ResourceLocation) { input = resourceLocator.openInputStream((ResourceLocation) location); } else if (location instanceof URLLocation) { input = urlLocator.openInputStream((URLLocation) location); } else { throw throwNotSupported(location); } return input; } Locators(FileSystem fileSystem, Artifactory artifactory);   Locators(FileLocator fileLocator, MavenLocator mavenLocator, ResourceLocator resourceLocator, URLLocator urlLocator); }
Locators { public InputStream openInputStream(Location location) { InputStream input; if (location instanceof FileLocation) { input = fileLocator.openInputStream((FileLocation) location); } else if (location instanceof MavenLocation) { input = mavenLocator.openInputStream((MavenLocation) location); } else if (location instanceof ResourceLocation) { input = resourceLocator.openInputStream((ResourceLocation) location); } else if (location instanceof URLLocation) { input = urlLocator.openInputStream((URLLocation) location); } else { throw throwNotSupported(location); } return input; } 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 InputStream openInputStream(Location location) { InputStream input; if (location instanceof FileLocation) { input = fileLocator.openInputStream((FileLocation) location); } else if (location instanceof MavenLocation) { input = mavenLocator.openInputStream((MavenLocation) location); } else if (location instanceof ResourceLocation) { input = resourceLocator.openInputStream((ResourceLocation) location); } else if (location instanceof URLLocation) { input = urlLocator.openInputStream((URLLocation) location); } else { throw throwNotSupported(location); } return input; } 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);  }