Search in sources :

Example 1 with ProductClient

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

the class BuildConfigurationEndpointTest method prepareData.

@SuppressWarnings("unchecked")
@BeforeClass
public static void prepareData() throws Exception {
    BuildConfigurationClient bcc = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    Iterator<BuildConfiguration> it = bcc.getAll().iterator();
    configurationId = it.next().getId();
    configuration2Id = it.next().getId();
    configuration3Id = it.next().getId();
    configuration4Id = it.next().getId();
    ProductClient pdc = new ProductClient(RestClientConfiguration.asAnonymous());
    productId = pdc.getAll().iterator().next().getId();
    EnvironmentClient ec = new EnvironmentClient(RestClientConfiguration.asAnonymous());
    environmentId = ec.getAll().iterator().next().getId();
    ProjectClient pjc = new ProjectClient(RestClientConfiguration.asAnonymous());
    projectId = pjc.getAll().iterator().next().getId();
    SCMRepositoryClient scmrc = new SCMRepositoryClient(RestClientConfiguration.asAnonymous());
    final Iterator<SCMRepository> scmrIt = scmrc.getAll(null, null).iterator();
    repositoryConfigurationId = scmrIt.next().getId();
    repositoryConfiguration2Id = scmrIt.next().getId();
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) SCMRepositoryClient(org.jboss.pnc.client.SCMRepositoryClient) ProductClient(org.jboss.pnc.client.ProductClient) EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) ProjectClient(org.jboss.pnc.client.ProjectClient) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) SCMRepository(org.jboss.pnc.dto.SCMRepository) BeforeClass(org.junit.BeforeClass)

Example 2 with ProductClient

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

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

the class ProductEndpointTest method testCreateNew.

@Test
@InSequence(20)
public void testCreateNew() throws ClientException {
    ProductClient client = new ProductClient(RestClientConfiguration.asUser());
    Product product = Product.builder().name("New Product").abbreviation("NP").description("The newst product of them all").productVersions(Collections.emptyMap()).build();
    Product created = client.createNew(product);
    assertThat(created.getId()).isNotEmpty();
    Product retrieved = client.getSpecific(created.getId());
    assertThat(created).isEqualToIgnoringGivenFields(product, "id");
    assertThat(retrieved).isEqualToIgnoringGivenFields(product, "id");
    assertThat(retrieved).isEqualTo(created);
}
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) InSequence(org.jboss.arquillian.junit.InSequence)

Example 4 with ProductClient

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

the class ProductEndpointTest method shouldFailToAddConflictingProduct.

@Test
@InSequence(30)
public void shouldFailToAddConflictingProduct() throws URISyntaxException, ClientException {
    ProductClient client = new ProductClient(RestClientConfiguration.asUser());
    Product product = Product.builder().name("The Same Thing").abbreviation("TST").description("Let's keep doing the same thing over and over. Nobody will notice.").build();
    Product created = client.createNew(product);
    assertThat(created.getId()).isNotEmpty();
    try {
        client.createNew(product);
        fail("Exception should be thrown");
    } catch (ClientException ex) {
    // OK
    }
}
Also used : ProductClient(org.jboss.pnc.client.ProductClient) Product(org.jboss.pnc.dto.Product) ClientException(org.jboss.pnc.client.ClientException) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 5 with ProductClient

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

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