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");
}
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);
}
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());
}
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
}
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));
}
Aggregations