use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildEndpointTest method shouldGetBuilds.
@Test
@InSequence(10)
public void shouldGetBuilds() throws RemoteResourceException {
BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Build> all = client.getAll(null, null);
assertThat(all).hasSize(4);
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildEndpointTest method shouldFilterByBuildConfigurationNameNotLike.
@Test
public void shouldFilterByBuildConfigurationNameNotLike() throws Exception {
BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
String buildConfigName = DatabaseDataInitializer.PNC_PROJECT_BUILD_CFG_ID;
BuildsFilterParameters filter = new BuildsFilterParameters();
filter.setBuildConfigName("!*" + buildConfigName.substring(1, buildConfigName.length() - 2) + "*");
List<String> buildConfigNames = client.getAll(filter, null).getAll().stream().map(Build::getBuildConfigRevision).map(BuildConfigurationRevisionRef::getName).collect(Collectors.toList());
// from DatabaseDataInitializer
assertThat(buildConfigNames).hasSize(2);
assertThat(buildConfigNames).doesNotContain(buildConfigName);
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildTest method shouldRejectAfterBuildingTwoTempBuildsOnSameRevision.
@Test
public void shouldRejectAfterBuildingTwoTempBuildsOnSameRevision() throws ClientException {
BuildConfiguration buildConfiguration = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==maven-plugin-test")).iterator().next();
BuildConfiguration updatedConfiguration = buildConfiguration.toBuilder().description("Random Description to be able to trigger build again so that temporary build will be first on this revision").buildScript("mvn" + " clean deploy -DskipTests=true").build();
buildConfigurationClient.update(updatedConfiguration.getId(), updatedConfiguration);
Build temporaryBuild = buildConfigurationClient.trigger(updatedConfiguration.getId(), getTemporaryParameters());
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(temporaryBuild.getId(), EnumSet.of(BuildStatus.SUCCESS), null), 15, TimeUnit.SECONDS);
Build secondTempBuild = buildConfigurationClient.trigger(updatedConfiguration.getId(), getTemporaryParameters());
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(secondTempBuild.getId(), EnumSet.of(BuildStatus.NO_REBUILD_REQUIRED), EnumSet.of(BuildStatus.SUCCESS, BuildStatus.REJECTED)), 15, TimeUnit.SECONDS);
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildTest method shouldBuildTemporaryBuildAndNotAssignItToMilestone.
@Test
public void shouldBuildTemporaryBuildAndNotAssignItToMilestone() throws ClientException {
// BC pnc-1.0.0.DR1 is assigned to a product version containing an active product milestone see
// DatabaseDataInitializer#initiliazeProjectProductData
BuildConfiguration buildConfiguration = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==pnc-1.0.0.DR1")).iterator().next();
// when
Build build = buildConfigurationClient.trigger(buildConfiguration.getId(), getTemporaryParameters(true));
// then
assertThat(build).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(build.getId()), 15, TimeUnit.SECONDS);
Build updatedBuild = buildClient.getSpecific(build.getId());
assertThat(updatedBuild.getProductMilestone()).isNull();
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildTest method buildToFinish.
private Boolean buildToFinish(String buildId, EnumSet<BuildStatus> isIn, EnumSet<BuildStatus> isNotIn) {
Build build = null;
logger.debug("Waiting for build {} to finish", buildId);
try {
build = buildClient.getSpecific(buildId);
assertThat(build).isNotNull();
logger.debug("Gotten build with status: {}", build.getStatus());
if (!build.getStatus().isFinal())
return false;
} catch (RemoteResourceNotFoundException e) {
fail(String.format("Build with id:%s not present", buildId), e);
} catch (ClientException e) {
fail("Client has failed in an unexpected way.", e);
}
assertThat(build).isNotNull();
assertThat(build.getStatus()).isNotNull();
if (isIn != null && !isIn.isEmpty())
assertThat(build.getStatus()).isIn(isIn);
if (isNotIn != null && !isNotIn.isEmpty())
assertThat(build.getStatus()).isNotIn(isNotIn);
return true;
}
Aggregations