Search in sources :

Example 1 with ProductMilestoneClient

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

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

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

the class ProductMilestoneEndpointTest method testValidateWithWrongPattern.

@Test
public void testValidateWithWrongPattern() throws RemoteResourceException {
    // with
    ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asUser());
    // when
    final ValidationResponse response = client.validateVersion(VersionValidationRequest.builder().productVersionId("shouldn't matter").version("1.NOTVALID").build());
    // then
    assertThat(response.getIsValid()).isFalse();
    assertThat(response.getErrorType()).isEqualTo(ValidationErrorType.FORMAT);
    assertThat(response.getHints()).isNotEmpty();
}
Also used : ProductMilestoneClient(org.jboss.pnc.client.ProductMilestoneClient) ValidationResponse(org.jboss.pnc.dto.response.ValidationResponse) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 4 with ProductMilestoneClient

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

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

Aggregations

ProductMilestoneClient (org.jboss.pnc.client.ProductMilestoneClient)14 ContainerTest (org.jboss.pnc.test.category.ContainerTest)13 Test (org.junit.Test)13 ProductMilestone (org.jboss.pnc.dto.ProductMilestone)9 ValidationResponse (org.jboss.pnc.dto.response.ValidationResponse)4 ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)2 Artifact (org.jboss.pnc.dto.Artifact)2 Build (org.jboss.pnc.dto.Build)2 ProductMilestoneCloseResult (org.jboss.pnc.dto.ProductMilestoneCloseResult)2 ProductMilestoneCloseParameters (org.jboss.pnc.rest.api.parameters.ProductMilestoneCloseParameters)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