MavenLocator implements Locator<MavenLocation> { @Override public File copyToDirectory(MavenLocation location, File toDir) { File target = locate(location); if (target == null) { return null; } try { FileUtils.copyFileToDirectory(target, toDir); return new File(toDir, target.getName()); } catch (IOException e) { throw new IllegalStateException("Fail to copy file to dir: " + toDir, 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 copyToDirectory_returns_null_if_artifact_not_found() throws IOException { MavenLocation location = MavenLocation.of("foo", "bar", "1.0"); markVersionsAsResolved(); File toDir = temp.newFolder(); File result = underTest.copyToDirectory(location, toDir); assertThat(result).isNull(); assertThat(toDir.listFiles()).isEmpty(); }