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();
}
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();
}
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();
}
Aggregations