use of org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution in project pnc by project-ncl.
the class BuildGroupIncludesProductVersionGroupTest method verifyGroupComposition_ProductVersion_NoConfSet.
@Test
public void verifyGroupComposition_ProductVersion_NoConfSet() throws Exception {
// create a dummy non-chained build execution and repo session based on it
BuildExecution execution = new TestBuildExecution("build_myproject_12345");
Indy indy = driver.getIndy(accessToken);
RepositorySession repositoryConfiguration = driver.createBuildRepository(execution, accessToken, accessToken, RepositoryType.MAVEN, Collections.emptyMap(), false);
String repoId = repositoryConfiguration.getBuildRepositoryId();
assertThat(repoId, equalTo(execution.getBuildContentId()));
// check that the build group includes:
// - the build's hosted repo
// - the product version repo group
// - the "shared-releases" repo group
// - the "shared-imports" repo
// - the public group
// ...in that order
Group buildGroup = indy.stores().load(new StoreKey(MAVEN_PKG_KEY, StoreType.group, repoId), Group.class);
System.out.printf("Constituents:\n %s\n", join(buildGroup.getConstituents(), "\n "));
assertGroupConstituents(buildGroup, new StoreKey(MAVEN_PKG_KEY, StoreType.hosted, execution.getBuildContentId()), new StoreKey(MAVEN_PKG_KEY, StoreType.group, IndyRepositoryConstants.COMMON_BUILD_GROUP_CONSTITUENTS_GROUP));
}
use of org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution in project pnc by project-ncl.
the class BuildGroupIndySidecarActivatedTest method verifyGroupComposition_ProductVersion_WithConfSet.
@Test
public void verifyGroupComposition_ProductVersion_WithConfSet() throws Exception {
// create a dummy composed (chained) build execution and a repo session based on it
BuildExecution execution = new TestBuildExecution("build_myproject_1111");
Indy indy = driver.getIndy(accessToken);
RepositorySession repositoryConfiguration = driver.createBuildRepository(execution, accessToken, accessToken, RepositoryType.MAVEN, Collections.emptyMap(), false);
RepositoryConnectionInfo info = repositoryConfiguration.getConnectionInfo();
assertThat(info.getDependencyUrl()).startsWith(sideCarUrl);
assertThat(info.getDeployUrl()).startsWith(sideCarUrl);
}
use of org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution in project pnc by project-ncl.
the class BuildGroupIndySidecarDeActivatedTest method verifyGroupComposition_ProductVersion_WithConfSet.
@Test
public void verifyGroupComposition_ProductVersion_WithConfSet() throws Exception {
// create a dummy composed (chained) build execution and a repo session based on it
BuildExecution execution = new TestBuildExecution("build_myproject_1111");
Indy indy = driver.getIndy(accessToken);
RepositorySession repositoryConfiguration = driver.createBuildRepository(execution, accessToken, accessToken, RepositoryType.MAVEN, Collections.emptyMap(), false);
RepositoryConnectionInfo info = repositoryConfiguration.getConnectionInfo();
assertThat(info.getDependencyUrl()).doesNotStartWith(sideCarUrl);
assertThat(info.getDeployUrl()).doesNotStartWith(sideCarUrl);
}
use of org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution in project pnc by project-ncl.
the class DependencyUrlIncludesTrackingIdAndGeneratedBuildGroupNameTest method formatRepositoryURLForSimpleInfo_CheckDependencyURL.
@Test
public void formatRepositoryURLForSimpleInfo_CheckDependencyURL() throws Exception {
// create a dummy non-chained build execution and repo session based on it
BuildExecution execution = new TestBuildExecution();
RepositorySession repositoryConfiguration = driver.createBuildRepository(execution, accessToken, accessToken, RepositoryType.MAVEN, Collections.emptyMap(), false);
assertThat(repositoryConfiguration, notNullValue());
// verify the URLs in the connection info reference this build, and refer to a tracked repository group URL
RepositoryConnectionInfo connectionInfo = repositoryConfiguration.getConnectionInfo();
assertThat(connectionInfo, notNullValue());
String expectedUrlPrefix = String.format("%sfolo/track/%s", url, execution.getBuildContentId());
String expectedGroupPathPrefix = String.format("/group/%s", execution.getBuildContentId());
assertThat("Expected URL prefix: " + expectedUrlPrefix + "\nActual URL was: " + connectionInfo.getDependencyUrl(), connectionInfo.getDependencyUrl().startsWith(expectedUrlPrefix), equalTo(true));
assertThat("Expected URL to contain group path prefix: " + expectedGroupPathPrefix + "\nActual URL was: " + connectionInfo.getDependencyUrl(), connectionInfo.getDependencyUrl().contains(expectedGroupPathPrefix), equalTo(true));
}
use of org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution in project pnc by project-ncl.
the class DownloadTwoThenVerifyExtractedArtifactsContainThemTest method extractBuildArtifacts_ContainsTwoDownloads.
@Test
public void extractBuildArtifacts_ContainsTwoDownloads() throws Exception {
String pomPath = "org/commonjava/indy/indy-core/0.17.0/indy-core-0.17.0.pom";
String jarPath = "org/commonjava/indy/indy-core/0.17.0/indy-core-0.17.0.jar";
String pomContent = "This is a pom test " + System.currentTimeMillis();
String jarContent = "This is a jar test " + System.currentTimeMillis();
// setup the expectation that the remote repo pointing at this server will request this file...and define its
// content.
server.expect(server.formatUrl(STORE, pomPath), 200, pomContent);
server.expect(server.formatUrl(STORE, jarPath), 200, jarContent);
// 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().getDependencyUrl();
// 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, pomPath)), equalTo(pomContent));
assertThat(download(UrlUtils.buildUrl(baseUrl, jarPath)), equalTo(jarContent));
// extract the build artifacts, which should contain the two imported deps.
// This will also trigger promoting imported artifacts into the shared-imports hosted repo
RepositoryManagerResult repositoryManagerResult = rc.extractBuildArtifacts(true);
List<Artifact> deps = repositoryManagerResult.getDependencies();
System.out.println(deps);
assertThat(deps, notNullValue());
assertThat("Expected 2 dependencies, got: " + deps, deps.size(), equalTo(2));
ProjectVersionRef pvr = new SimpleProjectVersionRef("org.commonjava.indy", "indy-core", "0.17.0");
Set<String> refs = new HashSet<>();
refs.add(new SimpleArtifactRef(pvr, "pom", null).toString());
refs.add(new SimpleArtifactRef(pvr, "jar", null).toString());
// check that both files are in the dep artifacts list using getIdentifier() to match on GAVT[C]
for (Artifact artifact : deps) {
assertThat(artifact + " is not in the expected list of deps: " + refs, refs.contains(artifact.getIdentifier()), equalTo(true));
}
Indy indy = driver.getIndy(accessToken);
// check that the new imports are available from shared-imports
assertAvailableInSharedImports(indy, pomContent, pomPath);
assertAvailableInSharedImports(indy, jarContent, jarPath);
}
Aggregations