Search in sources :

Example 1 with ProductMilestone

use of org.jboss.pnc.dto.ProductMilestone 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 2 with ProductMilestone

use of org.jboss.pnc.dto.ProductMilestone in project pnc by project-ncl.

the class ProductMilestoneEndpointTest method testCreateNew.

@Test
public void testCreateNew() throws ClientException {
    // given
    ProductMilestone productMilestone = ProductMilestone.builder().productVersion(productVersion).version("1.0.0.ER1").startingDate(Instant.ofEpochMilli(100_000)).plannedEndDate(Instant.ofEpochMilli(200_000)).build();
    // when
    ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asUser());
    ProductMilestone created = client.createNew(productMilestone);
    assertThat(created.getId()).isNotEmpty();
    ProductMilestone retrieved = client.getSpecific(created.getId());
    // then
    assertThat(created.getProductVersion().getId()).isEqualTo(productMilestone.getProductVersion().getId());
    assertThat(retrieved.getProductVersion().getId()).isEqualTo(productMilestone.getProductVersion().getId());
    assertThat(created).isEqualToIgnoringGivenFields(productMilestone, "id", "productVersion");
    assertThat(retrieved).isEqualToIgnoringGivenFields(productMilestone, "id", "productVersion");
    assertThat(retrieved).isEqualTo(created);
}
Also used : ProductMilestone(org.jboss.pnc.dto.ProductMilestone) ProductMilestoneClient(org.jboss.pnc.client.ProductMilestoneClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 3 with ProductMilestone

use of org.jboss.pnc.dto.ProductMilestone in project pnc by project-ncl.

the class ProductMilestoneEndpointTest method shouldFailToCreateClosedMilestone.

@Test
public void shouldFailToCreateClosedMilestone() throws IOException {
    // given
    ProductMilestone closedMilestone = ProductMilestone.builder().productVersion(productVersion).version("1.0.0.ER2").startingDate(Instant.ofEpochMilli(100_000)).plannedEndDate(Instant.ofEpochMilli(200_000)).endDate(Instant.ofEpochMilli(300_000)).build();
    ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asUser());
    // when then
    assertThatThrownBy(() -> client.createNew(closedMilestone)).isInstanceOf(ClientException.class);
}
Also used : ProductMilestone(org.jboss.pnc.dto.ProductMilestone) ProductMilestoneClient(org.jboss.pnc.client.ProductMilestoneClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 4 with ProductMilestone

use of org.jboss.pnc.dto.ProductMilestone in project pnc by project-ncl.

the class ProductMilestoneEndpointTest method testShouldFailToCloseWithNoBuilds.

@Test
public void testShouldFailToCloseWithNoBuilds() throws ClientException {
    ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asUser());
    ProductMilestone newMilestone = ProductMilestone.builder().productVersion(productVersion).version("9.9.9.ER9").startingDate(Instant.ofEpochMilli(100_000)).plannedEndDate(Instant.ofEpochMilli(200_000)).build();
    ProductMilestone created = client.createNew(newMilestone);
    assertThat(created.getId()).isNotEmpty();
    ProductMilestone retrieved = client.getSpecific(created.getId());
    assertThatThrownBy(() -> client.closeMilestone(retrieved.getId())).hasCauseInstanceOf(BadRequestException.class);
}
Also used : ProductMilestone(org.jboss.pnc.dto.ProductMilestone) ProductMilestoneClient(org.jboss.pnc.client.ProductMilestoneClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 5 with ProductMilestone

use of org.jboss.pnc.dto.ProductMilestone 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

ProductMilestone (org.jboss.pnc.dto.ProductMilestone)12 ContainerTest (org.jboss.pnc.test.category.ContainerTest)10 Test (org.junit.Test)10 ProductMilestoneClient (org.jboss.pnc.client.ProductMilestoneClient)9 ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)4 ProductClient (org.jboss.pnc.client.ProductClient)2 Product (org.jboss.pnc.dto.Product)2 ProductVersion (org.jboss.pnc.dto.ProductVersion)2 ValidationResponse (org.jboss.pnc.dto.response.ValidationResponse)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)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