Search in sources :

Example 1 with ValidationResponse

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

use of org.jboss.pnc.dto.response.ValidationResponse 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 3 with ValidationResponse

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

the class ProductMilestoneEndpointTest method testSuccessfulValidationWithNewVersion.

@Test
public void testSuccessfulValidationWithNewVersion() throws RemoteResourceException {
    // with
    ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asUser());
    // when
    final ValidationResponse response = client.validateVersion(VersionValidationRequest.builder().productVersionId("100").version("1.0.3.Build1").build());
    // then
    assertThat(response.getIsValid()).isTrue();
    assertThat(response.getErrorType()).isNull();
    assertThat(response.getHints()).isNullOrEmpty();
}
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)

Aggregations

ProductMilestoneClient (org.jboss.pnc.client.ProductMilestoneClient)3 ValidationResponse (org.jboss.pnc.dto.response.ValidationResponse)3 ContainerTest (org.jboss.pnc.test.category.ContainerTest)3 Test (org.junit.Test)3 ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)1 ProductMilestone (org.jboss.pnc.dto.ProductMilestone)1