use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method shouldChangeRepositoryConfiguration.
@Test
@InSequence(61)
public void shouldChangeRepositoryConfiguration() throws ClientException {
// given
BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
SCMRepositoryClient scmClient = new SCMRepositoryClient(RestClientConfiguration.asAnonymous());
BuildConfiguration buildConfiguration = bcClient.getSpecific(configuration4Id);
// make sure this RC is not already set
assertThat(buildConfiguration.getScmRepository().getId()).isNotEqualTo(repositoryConfiguration2Id);
// when
BuildConfiguration updateBC = BuildConfiguration.builder().id(buildConfiguration.getId()).name(buildConfiguration.getName()).buildScript(buildConfiguration.getBuildScript()).creationTime(buildConfiguration.getCreationTime()).modificationTime(buildConfiguration.getModificationTime()).project(buildConfiguration.getProject()).environment(buildConfiguration.getEnvironment()).parameters(buildConfiguration.getParameters()).scmRepository(scmClient.getSpecific(repositoryConfiguration2Id)).buildType(buildConfiguration.getBuildType()).build();
bcClient.update(updateBC.getId(), updateBC);
BuildConfiguration updatedBC = bcClient.getSpecific(updateBC.getId());
// then
assertThat(updateBC.getScmRepository().getId()).isEqualTo(repositoryConfiguration2Id);
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class BuildTest method shouldTriggerBuildWithADependencyAndFinishWithoutProblems.
@Test
public void shouldTriggerBuildWithADependencyAndFinishWithoutProblems() throws ClientException {
// given - A BC with a dependency on pnc-1.0.0.DR1
BuildConfiguration buildConfigurationParent = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==dependency-analysis-1.3")).iterator().next();
// Update dependency
BuildConfiguration buildConfigurationChild = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==pnc-1.0.0.DR1")).iterator().next();
BuildConfiguration updatedBuildConfigurationChild = buildConfigurationChild.toBuilder().description(buildConfigurationChild.getDescription() + ".").build();
buildConfigurationClient.update(buildConfigurationChild.getId(), updatedBuildConfigurationChild);
// The update of the description should not have changed the lastModificationDate
assertThat(buildConfigurationChild.getModificationTime()).isEqualTo(updatedBuildConfigurationChild.getModificationTime());
// when
Build build = buildConfigurationClient.trigger(buildConfigurationParent.getId(), getBuildParameters(false, true));
BuildsFilterParameters parameters = new BuildsFilterParameters();
parameters.setRunning(true);
RemoteCollection<Build> childBuildCol = buildConfigurationClient.getBuilds(buildConfigurationChild.getId(), parameters);
Build childBuild = childBuildCol.getAll().iterator().next();
// then
assertThat(childBuildCol.size()).isEqualTo(1);
assertThat(buildConfigurationParent.getDependencies().size()).isEqualTo(1);
assertThat(build).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(build.getId(), isIn, null), 15, TimeUnit.SECONDS);
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(childBuild.getId(), isIn, null), 15, TimeUnit.SECONDS);
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class BuildTest method shouldHaveNoRebuildCauseFilled.
@Test
public void shouldHaveNoRebuildCauseFilled() throws Exception {
// with
BuildConfiguration buildConfiguration = buildConfigurationClient.getAll().iterator().next();
// when #1
Build build = buildConfigurationClient.trigger(buildConfiguration.getId(), getPersistentParameters(true));
assertThat(build).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(build.getId(), isIn, null), 15, TimeUnit.SECONDS);
// when #2
EnumSet<BuildStatus> isNotIn = EnumSet.of(BuildStatus.SUCCESS, BuildStatus.FAILED);
Build rebuild = buildConfigurationClient.trigger(buildConfiguration.getId(), getBuildParameters(false, false));
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(rebuild.getId(), EnumSet.of(BuildStatus.NO_REBUILD_REQUIRED), isNotIn), 15, TimeUnit.SECONDS);
// then
Build refresh = buildClient.getSpecific(rebuild.getId());
assertThat(refresh.getNoRebuildCause()).isNotNull().extracting("id").isEqualTo(build.getId());
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class BuildTest method shouldTriggerBuildAndFinishWithoutProblems.
@Test
public void shouldTriggerBuildAndFinishWithoutProblems() throws ClientException {
// with
BuildConfiguration buildConfiguration = buildConfigurationClient.getAll().iterator().next();
// when
Build build = buildConfigurationClient.trigger(buildConfiguration.getId(), getPersistentParameters(true));
assertThat(build).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(build.getId(), isIn, null), 15, TimeUnit.SECONDS);
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method shouldFailToCreateBuildConfigurationWhichDoesntMatchRegexp.
@Test
public void shouldFailToCreateBuildConfigurationWhichDoesntMatchRegexp() throws ClientException {
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
BuildConfiguration bc = client.getSpecific(configurationId);
BuildConfiguration invalidName = BuildConfiguration.builder().name(":").buildScript(bc.getBuildScript()).project(bc.getProject()).environment(bc.getEnvironment()).parameters(bc.getParameters()).scmRepository(bc.getScmRepository()).buildType(bc.getBuildType()).build();
assertThatThrownBy(() -> client.createNew(invalidName)).hasCauseInstanceOf(BadRequestException.class);
}
Aggregations