Search in sources :

Example 1 with BuildConfigurationRevision

use of org.jboss.pnc.dto.BuildConfigurationRevision in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldRestoreBuildConfigurationRevision.

@Test
@InSequence(50)
public void shouldRestoreBuildConfigurationRevision() throws Exception {
    // given
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration original = client.getSpecific(configurationId);
    String description = original.getDescription();
    Iterator<BuildConfigurationRevision> it = client.getRevisions(configurationId).iterator();
    // given latest revision
    BuildConfigurationRevision originalRev = it.next();
    while (it.hasNext()) {
        BuildConfigurationRevision candidate = it.next();
        if (candidate.getRev() > originalRev.getRev()) {
            originalRev = candidate;
        }
    }
    // when
    String newDescription = "shouldRestoreBuildConfigurationRevision Updated";
    BuildConfiguration toUpdate = original.toBuilder().description(newDescription).build();
    client.update(configurationId, toUpdate);
    assertThat(toUpdate.getDescription()).isNotEqualTo(description);
    // and when
    BuildConfiguration restored = client.restoreRevision(configurationId, originalRev.getRev());
    BuildConfiguration retrieved = client.getSpecific(configurationId);
    // then
    // we don't audit anymore the description, so it cannot be restored from a previous revision
    assertThat(restored.getDescription()).isEqualTo(toUpdate.getDescription());
    assertThat(restored).isEqualToIgnoringGivenFields(original, "description", "modificationTime", "modificationUser", "creationTime", "creationUser");
    assertThat(retrieved).isEqualToIgnoringGivenFields(restored, "description", "modificationTime", "modificationUser", "creationTime", "creationUser");
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 2 with BuildConfigurationRevision

use of org.jboss.pnc.dto.BuildConfigurationRevision in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldGetBuildConfigurationRevision.

@Test
public void shouldGetBuildConfigurationRevision() throws Exception {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    BuildConfigurationRevision revision = client.getRevision(configurationId, 1);
    assertThat(revision.getId()).isEqualTo(configurationId);
}
Also used : BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 3 with BuildConfigurationRevision

use of org.jboss.pnc.dto.BuildConfigurationRevision in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldCreateBuildConfigRevision.

@Test
public void shouldCreateBuildConfigRevision() throws ClientException {
    final String description = "Updated description.";
    final String updatedName = "thisisanupdatedname";
    final String buildScript = "mvn deploy # Updated script";
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration bc = client.getSpecific(configurationId);
    Instant modTime = bc.getModificationTime();
    BuildConfiguration newBC1 = bc.toBuilder().name(updatedName).description(description).build();
    BuildConfiguration newBC2 = bc.toBuilder().buildScript(buildScript).build();
    BuildConfigurationRevision newRevision1 = client.createRevision(configurationId, newBC1);
    BuildConfigurationRevision newRevision2 = client.createRevision(configurationId, newBC2);
    assertNotEquals(modTime, newRevision1.getModificationTime());
    assertNotEquals(modTime, newRevision2.getModificationTime());
    assertEquals(updatedName, newRevision1.getName());
    assertEquals(bc.getBuildScript(), newRevision1.getBuildScript());
    assertEquals(bc.getEnvironment(), newRevision2.getEnvironment());
    assertEquals(buildScript, newRevision2.getBuildScript());
    assertThat(newRevision1.getRev()).isLessThan(newRevision2.getRev());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Instant(java.time.Instant) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 4 with BuildConfigurationRevision

use of org.jboss.pnc.dto.BuildConfigurationRevision in project pnc by project-ncl.

the class BuildEndpointTest method shouldGetBuildConfigurationRevision.

@Test
public void shouldGetBuildConfigurationRevision() throws ClientException {
    // when
    BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
    BuildConfigurationRevision bcRevision = client.getBuildConfigRevision(buildId);
    // then
    // from
    assertThat(bcRevision.getScmRevision()).isEqualTo("*/v0.2");
// DatabaseDataInitializer
}
Also used : BuildClient(org.jboss.pnc.client.BuildClient) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 5 with BuildConfigurationRevision

use of org.jboss.pnc.dto.BuildConfigurationRevision in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldGetBuildConfigurationRevisions.

@Test
public void shouldGetBuildConfigurationRevisions() throws Exception {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<BuildConfigurationRevision> revisions = client.getRevisions(configurationId);
    assertThat(revisions).anySatisfy(config -> assertThat(config.getId()).isEqualTo(configurationId));
}
Also used : BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)8 Test (org.junit.Test)8 ContainerTest (org.jboss.pnc.test.category.ContainerTest)7 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)5 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)3 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 InSequence (org.jboss.arquillian.junit.InSequence)1 BuildClient (org.jboss.pnc.client.BuildClient)1 BuildConfigurationRevisionRef (org.jboss.pnc.dto.BuildConfigurationRevisionRef)1 GroupBuild (org.jboss.pnc.dto.GroupBuild)1 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)1 GroupBuildRequest (org.jboss.pnc.dto.requests.GroupBuildRequest)1 BuildStatus (org.jboss.pnc.enums.BuildStatus)1 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)1 IdRev (org.jboss.pnc.model.IdRev)1 GroupBuildParameters (org.jboss.pnc.rest.api.parameters.GroupBuildParameters)1