use of org.jboss.pnc.spi.repositorymanager.model.RepositorySession in project pnc by project-ncl.
the class UploadOneThenDownloadAndVerifyArtifactHasOriginUrlTest method extractBuildArtifacts_ContainsTwoUploads.
@Test
public void extractBuildArtifacts_ContainsTwoUploads() throws Exception {
// create a dummy non-chained build execution and repo session based on it
BuildExecution execution = new TestBuildExecution();
RepositorySession rc = driver.createBuildRepository(execution, accessToken, accessToken, RepositoryType.MAVEN, Collections.emptyMap(), false);
assertThat(rc, notNullValue());
String baseUrl = rc.getConnectionInfo().getDeployUrl();
String path = "org/commonjava/indy/indy-core/0.17.0/indy-core-0.17.0.pom";
String content = "This is a test";
CloseableHttpClient client = HttpClientBuilder.create().build();
// upload a couple files related to a single GAV using the repo session deployment url
// this simulates a build deploying one jar and its associated POM
final String url = UrlUtils.buildUrl(baseUrl, path);
assertThat("Failed to upload: " + url, ArtifactUploadUtils.put(client, url, content), equalTo(true));
// download the two files via the repo session's dependency URL, which will proxy the test http server
// using the expectations above
assertThat(download(UrlUtils.buildUrl(baseUrl, path)), equalTo(content));
ProjectVersionRef pvr = new SimpleProjectVersionRef("org.commonjava.indy", "indy-core", "0.17.0");
String artifactRef = new SimpleArtifactRef(pvr, "pom", null).toString();
// extract the "builtArtifacts" artifacts we uploaded above.
RepositoryManagerResult repositoryManagerResult = rc.extractBuildArtifacts(true);
// check that both files are present in extracted result
List<Artifact> builtArtifacts = repositoryManagerResult.getBuiltArtifacts();
log.info("Built artifacts: " + builtArtifacts.toString());
assertThat(builtArtifacts, notNullValue());
assertThat(builtArtifacts.size(), equalTo(1));
Artifact builtArtifact = builtArtifacts.get(0);
assertThat(builtArtifact + " doesn't match pom ref: " + artifactRef, builtArtifact.getIdentifier(), equalTo(artifactRef));
assertThat(builtArtifact + " doesn't have correct build category: " + BuildCategory.STANDARD, builtArtifact.getBuildCategory(), equalTo(BuildCategory.STANDARD));
client.close();
}
Aggregations