use of javax.validation.ConstraintViolation in project API by ca-cwds.
the class CmsDocumentBlobSegmentTest method testConstraintDocSegmentPattern.
@Test
public void testConstraintDocSegmentPattern() throws Exception {
CmsDocumentBlobSegment blob = new CmsDocumentBlobSegment(docHandle, "abcd", docBlob);
Set<ConstraintViolation<CmsDocumentBlobSegment>> violations = validator.validate(blob);
assertEquals(1, violations.size());
// assertEquals("invalid DOC_HANDLE", violations.iterator().next().getMessage());
}
use of javax.validation.ConstraintViolation in project API by ca-cwds.
the class CmsDocumentBlobSegmentTest method testConstraintDocHandlePattern.
// ====================
// DOC_HANDLE
// ====================
@Test
public void testConstraintDocHandlePattern() throws Exception {
CmsDocumentBlobSegment blob = new CmsDocumentBlobSegment("123456789012345678901234567890", segmentSequence, docBlob);
Set<ConstraintViolation<CmsDocumentBlobSegment>> violations = validator.validate(blob);
assertEquals(1, violations.size());
assertEquals("invalid DOC_HANDLE", violations.iterator().next().getMessage());
}
use of javax.validation.ConstraintViolation in project API by ca-cwds.
the class CmsDocumentBlobSegmentTest method testConstraintDocSegmentNull.
// ====================
// DOC_SEGMENT
// ====================
@Test
public void testConstraintDocSegmentNull() throws Exception {
CmsDocumentBlobSegment blob = new CmsDocumentBlobSegment(docHandle, null, docBlob);
Set<ConstraintViolation<CmsDocumentBlobSegment>> violations = validator.validate(blob);
assertEquals(1, violations.size());
assertEquals("may not be null", violations.iterator().next().getMessage());
}
use of javax.validation.ConstraintViolation in project dropwizard by dropwizard.
the class JerseyViolationExceptionMapper method toResponse.
@Override
public Response toResponse(final JerseyViolationException exception) {
final Set<ConstraintViolation<?>> violations = exception.getConstraintViolations();
final Invocable invocable = exception.getInvocable();
final ImmutableList<String> errors = FluentIterable.from(exception.getConstraintViolations()).transform(violation -> ConstraintMessage.getMessage(violation, invocable)).toList();
final int status = ConstraintMessage.determineStatus(violations, invocable);
return Response.status(status).entity(new ValidationErrorMessage(errors)).build();
}
use of javax.validation.ConstraintViolation in project dropwizard by dropwizard.
the class ConfigurationValidationExceptionTest method setUp.
@Before
public void setUp() throws Exception {
assumeThat(Locale.getDefault().getLanguage(), is("en"));
final Validator validator = BaseValidator.newValidator();
final Set<ConstraintViolation<Example>> violations = validator.validate(new Example());
this.e = new ConfigurationValidationException("config.yml", violations);
}
Aggregations