use of org.jboss.pnc.dto.ProductVersion in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method createProductVersion.
private ProductVersion createProductVersion() throws ClientException {
ProductClient pClient = new ProductClient(RestClientConfiguration.asUser());
Product product = pClient.getAll().iterator().next();
ProductVersionClient pvClient = new ProductVersionClient(RestClientConfiguration.asUser());
ProductVersion pv = ProductVersion.builder().version("3245.6742").product(ProductRef.refBuilder().id(product.getId()).build()).build();
return pvClient.createNew(pv);
}
use of org.jboss.pnc.dto.ProductVersion in project pnc by project-ncl.
the class ProductVersionEndpointTest method prepareData.
@BeforeClass
public static void prepareData() throws Exception {
ProductClient productClient = new ProductClient(RestClientConfiguration.asAnonymous());
product = productClient.getAll().iterator().next();
Iterator<ProductVersion> it = productClient.getProductVersions(product.getId()).iterator();
productVersionsId = it.next().getId();
productVersionsId2 = it.next().getId();
}
use of org.jboss.pnc.dto.ProductVersion in project pnc by project-ncl.
the class ProductVersionEndpointTest method shouldNotUpdateGroupConfigsWithNonExistantGroupConfig.
@Test
public void shouldNotUpdateGroupConfigsWithNonExistantGroupConfig() throws ClientException {
// given
GroupConfigurationRef notExistingGC = GroupConfigurationRef.refBuilder().id("9999").name("i-dont-exist").build();
Map<String, GroupConfigurationRef> groupConfis = new HashMap<>();
// when
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
ProductVersion productVersion = client.getSpecific(productVersionsId2);
groupConfis.putAll(productVersion.getGroupConfigs());
groupConfis.put(notExistingGC.getId(), notExistingGC);
ProductVersion toUpdate = productVersion.toBuilder().groupConfigs(groupConfis).build();
// then
assertThatThrownBy(() -> client.update(productVersion.getId(), toUpdate)).isInstanceOf(ClientException.class);
}
use of org.jboss.pnc.dto.ProductVersion 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.dto.ProductVersion 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()]));
}
Aggregations