use of org.jboss.pnc.client.ProductVersionClient in project pnc by project-ncl.
the class ProductVersionEndpointTest method testGetBuildConfigurations.
@Test
public void testGetBuildConfigurations() throws ClientException {
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asAnonymous());
RemoteCollection<BuildConfiguration> all = client.getBuildConfigs(productVersionsId);
assertThat(all).hasSize(2).allMatch(v -> v.getProductVersion().getId().equals(productVersionsId));
}
use of org.jboss.pnc.client.ProductVersionClient in project pnc by project-ncl.
the class ProductVersionEndpointTest method testGetSpecific.
@Test
public void testGetSpecific() throws ClientException {
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asAnonymous());
ProductVersion dto = client.getSpecific(productVersionsId);
// from DatabaseDataInitializer
assertThat(dto.getVersion()).isEqualTo("1.0");
// from DatabaseDataInitializer
assertThat(dto.getProduct().getId()).isEqualTo(product.getId());
}
use of org.jboss.pnc.client.ProductVersionClient in project pnc by project-ncl.
the class ProductVersionEndpointTest method testGetMilestones.
@Test
public void testGetMilestones() throws ClientException {
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asAnonymous());
RemoteCollection<ProductMilestone> all = client.getMilestones(productVersionsId);
assertThat(all).hasSize(4).allMatch(v -> v.getProductVersion().getId().equals(productVersionsId));
}
use of org.jboss.pnc.client.ProductVersionClient in project pnc by project-ncl.
the class ProductVersionEndpointTest method shouldUpdateGroupConfigsUsingPatch.
@Test
public void shouldUpdateGroupConfigsUsingPatch() throws PatchBuilderException, RemoteResourceException {
// given
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
GroupConfiguration gc = GroupConfiguration.builder().name("GC patch test").build();
GroupConfigurationClient gcc = new GroupConfigurationClient(RestClientConfiguration.asUser());
GroupConfiguration gcToAdd = gcc.createNew(gc);
ProductVersion productVersion = client.getSpecific(productVersionsId2);
Map<String, GroupConfigurationRef> groupConfigs = productVersion.getGroupConfigs();
// when
ProductVersionPatchBuilder patchBuilder = new ProductVersionPatchBuilder();
ProductVersionPatchBuilder patch = patchBuilder.addGroupConfigs(Collections.singletonMap(gcToAdd.getId(), gcToAdd));
client.patch(productVersionsId2, patch);
// then
groupConfigs.put(gcToAdd.getId(), gcToAdd);
ProductVersion productVersionUpdated = client.getSpecific(productVersionsId2);
assertThat(productVersionUpdated.getGroupConfigs()).containsKeys(groupConfigs.keySet().toArray(new String[groupConfigs.keySet().size()]));
}
use of org.jboss.pnc.client.ProductVersionClient in project pnc by project-ncl.
the class ProductVersionEndpointTest method shouldNotUpdateCurrentToClosedMilestone.
@Test
public void shouldNotUpdateCurrentToClosedMilestone() throws ClientException {
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
ProductVersion productVersion = client.getSpecific(productVersionsId);
Map<String, ProductMilestoneRef> milestones = productVersion.getProductMilestones();
ProductMilestoneRef closedMilestoneRef = null;
for (ProductMilestoneRef milestone : milestones.values()) {
if (milestone.getVersion().equals("1.0.0.Build4")) {
closedMilestoneRef = milestone;
break;
}
}
assertThat(closedMilestoneRef.getEndDate()).isNotNull();
ProductVersion updatedWithClosedMilestone = productVersion.toBuilder().currentProductMilestone(closedMilestoneRef).build();
assertThatThrownBy(() -> client.update(productVersionsId, updatedWithClosedMilestone)).isInstanceOf(ClientException.class);
}
Aggregations