use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method shouldCloneBuildConfiguration.
@Test
@InSequence(20)
public void shouldCloneBuildConfiguration() throws ClientException {
// given
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
BuildConfiguration original = client.getSpecific(configurationId);
assertThat(original.getProductVersion()).isNotNull();
assertThat(original.getGroupConfigs()).isNotEmpty();
BuildConfiguration parent = client.getSpecific(configuration4Id);
assertThat(parent.getDependencies()).containsKey(configurationId);
// when
BuildConfiguration clone = client.clone(original.getId());
// then
assertThat(clone.getId()).isNotEmpty();
assertThat(clone.getProductVersion()).isNull();
assertThat(clone.getGroupConfigs()).isEmpty();
BuildConfiguration retrieved = client.getSpecific(clone.getId());
BuildConfiguration retrivedParent = client.getSpecific(configuration4Id);
assertThat(retrivedParent.getDependencies()).containsKey(configurationId);
assertThat(retrivedParent.getDependencies()).doesNotContainKey(clone.getId());
assertThat(clone).isEqualToIgnoringGivenFields(original, "id", "name", "groupConfigs", "creationTime", "modificationTime", "modificationTime", "productVersion", "creationUser", "modificationUser");
assertThat(retrieved).isEqualToIgnoringGivenFields(clone, "modificationTime", "creationUser", // close
"modificationUser");
// of
// transaction
// changes
// the modification time -
// WONTFIX
}
use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method shouldReturn404WhenRevisionToRestoreDoesNotExist.
// TODO Test will fail due to issue: NCL-4473, remove @Ignore when fixed.
@Ignore
@Test
public void shouldReturn404WhenRevisionToRestoreDoesNotExist() throws ClientException {
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
assertThatThrownBy(() -> client.restoreRevision(configurationId, 9999)).hasCauseInstanceOf(NotFoundException.class);
}
use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method shouldDeleteDependencyWithPatch.
@Test
@InSequence(100)
public void shouldDeleteDependencyWithPatch() throws Exception {
// given
BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
BuildConfiguration gc = null;
for (BuildConfiguration bc1 : bcClient.getAll()) {
if (!bc1.getDependencies().isEmpty()) {
gc = bc1;
break;
}
}
assertThat(gc).isNotNull();
BuildConfiguration toRemove = bcClient.getSpecific(gc.getDependencies().keySet().iterator().next());
BuildConfigurationPatchBuilder builder = new BuildConfigurationPatchBuilder();
builder.removeDependencies(Collections.singletonList(toRemove.getId()));
// when
bcClient.patch(gc.getId(), builder);
// then
BuildConfiguration refresh = bcClient.getSpecific(gc.getId());
assertThat(refresh.getDependencies().keySet()).doesNotContain(toRemove.getId());
}
use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method testGetAllWithLatest.
@Test
@InSequence(10)
public void testGetAllWithLatest() throws RemoteResourceException {
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
RemoteCollection<BuildConfigurationWithLatestBuild> bcsWithLatest = client.getAllWithLatestBuild();
BuildsFilterParameters filter = new BuildsFilterParameters();
filter.setLatest(true);
// from DatabaseDataInitializer
assertThat(bcsWithLatest).hasSize(5);
for (BuildConfigurationWithLatestBuild bc : bcsWithLatest.getAll()) {
List<Build> associatedBuilds = new ArrayList<>(client.getBuilds(bc.getId(), filter).getAll());
if (bc.getLatestBuild() != null) {
assertThat(associatedBuilds).isNotEmpty();
assertThat(bc.getLatestBuild().getId()).isEqualTo(associatedBuilds.get(0).getId());
}
}
}
use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method testGetDependants.
@Test
@InSequence(30)
public void testGetDependants() throws ClientException {
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
List<String> allDependantIds = client.getDependants(configuration2Id).getAll().stream().map(BuildConfiguration::getId).collect(Collectors.toList());
assertThat(allDependantIds).containsOnly(configuration3Id);
}
Aggregations