use of org.jboss.pnc.dto.ProductVersion in project pnc by project-ncl.
the class ProductEndpointTest method testGetProductVersions.
@Test
public void testGetProductVersions() throws ClientException {
ProductClient client = new ProductClient(RestClientConfiguration.asAnonymous());
RemoteCollection<ProductVersion> all = client.getProductVersions(productId);
assertThat(all).hasSize(2).allMatch(v -> v.getProduct().getId().equals(productId));
}
use of org.jboss.pnc.dto.ProductVersion in project pnc by project-ncl.
the class SecondLevelCacheStoreTest method createProductVersionAndValidateResults.
public ProductVersion createProductVersionAndValidateResults(Product product, String version) throws ClientException {
// given
ProductVersion productVersion = ProductVersion.builder().product(product).version(version).build();
// when
ProductVersion created = productVersionClient.createNew(productVersion);
// then
assertThat(created.getId()).isNotEmpty();
ProductVersion retrieved = productVersionClient.getSpecific(created.getId());
ProductVersion toCompare = productVersion.toBuilder().productMilestones(// query had null, but server responds with empty map
Collections.emptyMap()).productReleases(// query had null, but server responds with empty map
Collections.emptyMap()).groupConfigs(// query had null, but server responds with empty map
Collections.emptyMap()).buildConfigs(// query had null, but server responds with empty map
Collections.emptyMap()).build();
assertThat(created.getProduct().getId()).isEqualTo(toCompare.getProduct().getId());
assertThat(created).isEqualToIgnoringGivenFields(toCompare, "id", "product", "attributes");
assertThat(retrieved).isEqualTo(created);
return retrieved;
}
use of org.jboss.pnc.dto.ProductVersion in project pnc by project-ncl.
the class ProductVersionEndpointTest method shouldFailGracefullyOnNonExistentProduct.
@Test
public void shouldFailGracefullyOnNonExistentProduct() {
// given
String nonExistentProductId = "384583";
ProductVersion productVersion = ProductVersion.builder().product(ProductRef.refBuilder().id(nonExistentProductId).build()).version("42.2").build();
// whenthen
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
assertThatThrownBy(() -> client.createNew(productVersion)).isInstanceOf(ClientException.class);
}
use of org.jboss.pnc.dto.ProductVersion in project pnc by project-ncl.
the class ProductVersionEndpointTest method shouldNotUpdateGroupConfigsWhenOneIsAlreadyAsssociatedWithAnotherProductVersion.
@Test
public void shouldNotUpdateGroupConfigsWhenOneIsAlreadyAsssociatedWithAnotherProductVersion() throws ClientException {
// given
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
GroupConfigurationRef alreadyAssignedGC = client.getSpecific(productVersionsId).getGroupConfigs().values().iterator().next();
Map<String, GroupConfigurationRef> groupConfis = new HashMap<>();
assertThat(alreadyAssignedGC).isNotNull();
// when
ProductVersion productVersion = client.getSpecific(productVersionsId2);
groupConfis.putAll(productVersion.getGroupConfigs());
groupConfis.put(alreadyAssignedGC.getId(), alreadyAssignedGC);
ProductVersion toUpdate = productVersion.toBuilder().groupConfigs(groupConfis).build();
// then
assertThatThrownBy(() -> client.update(productVersion.getId(), toUpdate)).isInstanceOf(ClientException.class);
}
Aggregations