MavenLocator implements Locator<MavenLocation> { @Override @CheckForNull public InputStream openInputStream(MavenLocation location) { File target = locate(location); if (target == null) { return null; } try { return FileUtils.openInputStream(target); } catch (IOException e) { throw new IllegalStateException("Fail to open " + target, e); } } MavenLocator(FileSystem fileSystem, Artifactory artifactory); @Override File locate(MavenLocation location); Optional<String> resolveVersion(MavenLocation location); @Override File copyToDirectory(MavenLocation location, File toDir); @Override File copyToFile(MavenLocation location, File toFile); @Override @CheckForNull InputStream openInputStream(MavenLocation location);  }
@Test public void openInputStream_returns_null_if_artifact_not_found() { MavenLocation location = MavenLocation.of("foo", "bar", "1.0"); markVersionsAsResolved(); assertThat(underTest.openInputStream(location)).isNull(); }