Search in sources :

Example 1 with ProductVersionClient

use of org.jboss.pnc.client.ProductVersionClient 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);
}
Also used : ProductClient(org.jboss.pnc.client.ProductClient) Product(org.jboss.pnc.dto.Product) ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient)

Example 2 with ProductVersionClient

use of org.jboss.pnc.client.ProductVersionClient in project pnc by project-ncl.

the class ProductMilestoneEndpointTest method testValidateWithExistingVersion.

@Test
public void testValidateWithExistingVersion() throws RemoteResourceException {
    // with
    ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asUser());
    ProductVersionClient productVersionClient = new ProductVersionClient(RestClientConfiguration.asUser());
    final ProductMilestone milestone = productVersionClient.getMilestones("100").iterator().next();
    // when
    final ValidationResponse response = client.validateVersion(VersionValidationRequest.builder().productVersionId("100").version(milestone.getVersion()).build());
    // then
    assertThat(response.getIsValid()).isFalse();
    assertThat(response.getErrorType()).isEqualTo(ValidationErrorType.DUPLICATION);
    assertThat(response.getHints()).isNotEmpty();
}
Also used : ProductMilestone(org.jboss.pnc.dto.ProductMilestone) ProductMilestoneClient(org.jboss.pnc.client.ProductMilestoneClient) ValidationResponse(org.jboss.pnc.dto.response.ValidationResponse) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 3 with ProductVersionClient

use of org.jboss.pnc.client.ProductVersionClient in project pnc by project-ncl.

the class ProductMilestoneEndpointTest method prepareData.

@BeforeClass
public static void prepareData() throws Exception {
    ProductClient productClient = new ProductClient(RestClientConfiguration.asAnonymous());
    product = productClient.getAll().iterator().next();
    productVersion = productClient.getProductVersions(product.getId()).iterator().next();
    ProductVersionClient productVersionClient = new ProductVersionClient(RestClientConfiguration.asAnonymous());
    Iterator<ProductMilestone> it = productVersionClient.getMilestones(productVersion.getId()).iterator();
    milestone = it.next();
    milestoneId = milestone.getId();
    milestone2 = it.next();
}
Also used : ProductMilestone(org.jboss.pnc.dto.ProductMilestone) ProductClient(org.jboss.pnc.client.ProductClient) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) BeforeClass(org.junit.BeforeClass)

Example 4 with ProductVersionClient

use of org.jboss.pnc.client.ProductVersionClient in project pnc by project-ncl.

the class ProductReleaseEndpointTest method prepareData.

@BeforeClass
public static void prepareData() throws Exception {
    ProductClient productClient = new ProductClient(RestClientConfiguration.asAnonymous());
    product = productClient.getAll().iterator().next();
    productVersion = productClient.getProductVersions(product.getId()).iterator().next();
    ProductVersionClient productVersionClient = new ProductVersionClient(RestClientConfiguration.asAnonymous());
    milestone = productVersionClient.getMilestones(productVersion.getId()).iterator().next();
    releaseId = productVersionClient.getReleases(productVersion.getId()).iterator().next().getId();
}
Also used : ProductClient(org.jboss.pnc.client.ProductClient) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) BeforeClass(org.junit.BeforeClass)

Example 5 with ProductVersionClient

use of org.jboss.pnc.client.ProductVersionClient 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);
}
Also used : GroupConfigurationRef(org.jboss.pnc.dto.GroupConfigurationRef) HashMap(java.util.HashMap) ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)25 ContainerTest (org.jboss.pnc.test.category.ContainerTest)20 Test (org.junit.Test)20 ProductVersion (org.jboss.pnc.dto.ProductVersion)17 GroupConfigurationRef (org.jboss.pnc.dto.GroupConfigurationRef)6 HashMap (java.util.HashMap)5 ProductClient (org.jboss.pnc.client.ProductClient)4 ProductVersionPatchBuilder (org.jboss.pnc.client.patch.ProductVersionPatchBuilder)4 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)4 ProductMilestone (org.jboss.pnc.dto.ProductMilestone)4 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)3 ProductMilestoneClient (org.jboss.pnc.client.ProductMilestoneClient)2 RemoteResourceException (org.jboss.pnc.client.RemoteResourceException)2 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)2 Product (org.jboss.pnc.dto.Product)2 ValidationResponse (org.jboss.pnc.dto.response.ValidationResponse)2 BeforeClass (org.junit.BeforeClass)2 IOException (java.io.IOException)1 Instant (java.time.Instant)1 Iterator (java.util.Iterator)1