@Test public void testRequestFileWithSuccess() throws IOException { File artifactFile = temporaryFolder.newFile("downloadedJar.jar"); stubbedMavenArtifact.setFile(artifactFile); ArtifactResolutionResult result = new ArtifactResolutionResult() .setOriginatingArtifact(stubbedMavenArtifact); doReturn(stubbedMavenArtifact) .when(repositorySystem) .createArtifact(anyString(), anyString(), anyString(), anyString()); doReturn(result) .when(repositorySystem) .resolve(any()); Path targetDirectory = temporaryFolder.newFolder("dependencies").toPath(); Optional<File> file = mavenRuntimeRequester.requestFile(coordinate, targetDirectory, ClassifierInformation.DEFAULT_JAR); assertThat(file).isPresent(); assertThat(Arrays.stream(targetDirectory.toFile().listFiles()) .anyMatch(f -> f.equals(file.get()))).isTrue(); }
@Override public Optional<File> requestFile(Coordinate mavenCoordinate, Path targetDirectory, ClassifierInformation classifierInformation) { if (classifierInformation.isSource) { return requestFile(mavenCoordinate, targetDirectory, "java-source", classifierInformation); } return requestFile(mavenCoordinate, targetDirectory, "jar", classifierInformation); }
MavenRuntimeRequester extends IArtifactRequester { @Override public Optional<File> requestFile(Coordinate mavenCoordinate, Path targetDirectory, ClassifierInformation classifierInformation) { if (classifierInformation.isSource) { return requestFile(mavenCoordinate, targetDirectory, "java-source", classifierInformation); } return requestFile(mavenCoordinate, targetDirectory, "jar", classifierInformation); } }
MavenRuntimeRequester extends IArtifactRequester { @Override public Optional<File> requestFile(Coordinate mavenCoordinate, Path targetDirectory, ClassifierInformation classifierInformation) { if (classifierInformation.isSource) { return requestFile(mavenCoordinate, targetDirectory, "java-source", classifierInformation); } return requestFile(mavenCoordinate, targetDirectory, "jar", classifierInformation); } MavenRuntimeRequester(RepositorySystem repositorySystem, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, Optional<URL> sourcesRepositoryUrl); }
MavenRuntimeRequester extends IArtifactRequester { @Override public Optional<File> requestFile(Coordinate mavenCoordinate, Path targetDirectory, ClassifierInformation classifierInformation) { if (classifierInformation.isSource) { return requestFile(mavenCoordinate, targetDirectory, "java-source", classifierInformation); } return requestFile(mavenCoordinate, targetDirectory, "jar", classifierInformation); } MavenRuntimeRequester(RepositorySystem repositorySystem, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, Optional<URL> sourcesRepositoryUrl); @Override Optional<File> requestFile(Coordinate mavenCoordinate, Path targetDirectory, ClassifierInformation classifierInformation); }
MavenRuntimeRequester extends IArtifactRequester { @Override public Optional<File> requestFile(Coordinate mavenCoordinate, Path targetDirectory, ClassifierInformation classifierInformation) { if (classifierInformation.isSource) { return requestFile(mavenCoordinate, targetDirectory, "java-source", classifierInformation); } return requestFile(mavenCoordinate, targetDirectory, "jar", classifierInformation); } MavenRuntimeRequester(RepositorySystem repositorySystem, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, Optional<URL> sourcesRepositoryUrl); @Override Optional<File> requestFile(Coordinate mavenCoordinate, Path targetDirectory, ClassifierInformation classifierInformation);  }