Search in sources :

Example 16 with BuildConfiguration

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);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) SCMRepositoryClient(org.jboss.pnc.client.SCMRepositoryClient) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 17 with BuildConfiguration

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);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupBuild(org.jboss.pnc.dto.GroupBuild) Build(org.jboss.pnc.dto.Build) BuildStatus(org.jboss.pnc.enums.BuildStatus) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 18 with BuildConfiguration

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());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupBuild(org.jboss.pnc.dto.GroupBuild) Build(org.jboss.pnc.dto.Build) BuildStatus(org.jboss.pnc.enums.BuildStatus) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 19 with BuildConfiguration

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);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupBuild(org.jboss.pnc.dto.GroupBuild) Build(org.jboss.pnc.dto.Build) BuildStatus(org.jboss.pnc.enums.BuildStatus) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 20 with BuildConfiguration

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);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)90 Test (org.junit.Test)65 ContainerTest (org.jboss.pnc.test.category.ContainerTest)45 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)31 HashMap (java.util.HashMap)17 InSequence (org.jboss.arquillian.junit.InSequence)17 Build (org.jboss.pnc.dto.Build)13 GroupBuild (org.jboss.pnc.dto.GroupBuild)12 SCMRepository (org.jboss.pnc.dto.SCMRepository)10 Test (org.junit.jupiter.api.Test)10 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)9 Instant (java.time.Instant)8 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)7 BuildStatus (org.jboss.pnc.enums.BuildStatus)7 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 ArrayList (java.util.ArrayList)4 BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)4 HashSet (java.util.HashSet)3