Search in sources :

Example 6 with ProductClient

use of org.jboss.pnc.client.ProductClient 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 7 with ProductClient

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

Example 8 with ProductClient

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

the class ProductEndpointTest method testUpdate.

@Test
public void testUpdate() throws ClientException {
    ProductClient client = new ProductClient(RestClientConfiguration.asUser());
    Product dto = client.getSpecific(productId);
    Product toUpdate = dto.toBuilder().name("Updated name").build();
    client.update(productId, toUpdate);
    Product retrieved = client.getSpecific(dto.getId());
    assertThat(retrieved).isEqualTo(toUpdate);
    assertThat(retrieved).isEqualToIgnoringGivenFields(dto, "name");
    assertThat(retrieved.getName()).isEqualTo("Updated name");
}
Also used : ProductClient(org.jboss.pnc.client.ProductClient) Product(org.jboss.pnc.dto.Product) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 9 with ProductClient

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

the class ProductEndpointTest method testPatch.

@Test
public void testPatch() throws ClientException, PatchBuilderException {
    // given
    ProductClient client = new ProductClient(RestClientConfiguration.asUser());
    Product original = client.getSpecific(productId);
    final String newProductAbbreviation = "newAbb";
    // when
    client.patch(productId, new ProductPatchBuilder().replaceAbbreviation(newProductAbbreviation));
    Product patched = client.getSpecific(original.getId());
    // then
    assertThat(patched).isEqualToIgnoringGivenFields(original, "abbreviation");
    assertThat(patched.getAbbreviation()).isEqualTo(newProductAbbreviation);
}
Also used : ProductPatchBuilder(org.jboss.pnc.client.patch.ProductPatchBuilder) ProductClient(org.jboss.pnc.client.ProductClient) Product(org.jboss.pnc.dto.Product) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 10 with ProductClient

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

the class ProductEndpointTest method prepareData.

@BeforeClass
public static void prepareData() throws Exception {
    ProductClient client = new ProductClient(RestClientConfiguration.asAnonymous());
    productId = client.getAll().iterator().next().getId();
}
Also used : ProductClient(org.jboss.pnc.client.ProductClient) BeforeClass(org.junit.BeforeClass)

Aggregations

ProductClient (org.jboss.pnc.client.ProductClient)16 Product (org.jboss.pnc.dto.Product)10 ContainerTest (org.jboss.pnc.test.category.ContainerTest)9 Test (org.junit.Test)9 BeforeClass (org.junit.BeforeClass)6 ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)4 ProductVersion (org.jboss.pnc.dto.ProductVersion)4 InSequence (org.jboss.arquillian.junit.InSequence)3 ClientException (org.jboss.pnc.client.ClientException)3 ProductMilestone (org.jboss.pnc.dto.ProductMilestone)2 IOException (java.io.IOException)1 Instant (java.time.Instant)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Optional (java.util.Optional)1 BadRequestException (javax.ws.rs.BadRequestException)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)1 Deployment (org.jboss.arquillian.container.test.api.Deployment)1 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)1