use of javax.validation.ConstraintViolation in project API by ca-cwds.
the class CmsDocumentBlobSegmentTest method testConstraintDocSegmentSize.
@Test
public void testConstraintDocSegmentSize() throws Exception {
CmsDocumentBlobSegment blob = new CmsDocumentBlobSegment(docHandle, "002", docBlob);
Set<ConstraintViolation<CmsDocumentBlobSegment>> violations = validator.validate(blob);
assertEquals(2, violations.size());
// assertEquals("size must be between 4 and 4", violations.iterator().next().getMessage());
}
use of javax.validation.ConstraintViolation in project API by ca-cwds.
the class CmsDocumentBlobSegmentTest method testConstraintBlobMinSize.
@Test
public void testConstraintBlobMinSize() throws Exception {
CmsDocumentBlobSegment blob = new CmsDocumentBlobSegment(docHandle, segmentSequence, "");
Set<ConstraintViolation<CmsDocumentBlobSegment>> violations = validator.validate(blob);
assertEquals(1, violations.size());
assertEquals("size must be between 1 and 4000", violations.iterator().next().getMessage());
}
use of javax.validation.ConstraintViolation in project API by ca-cwds.
the class CmsDocumentBlobSegmentTest method testConstraintBlobMaxSize.
@Test
public void testConstraintBlobMaxSize() throws Exception {
StringBuilder buf = new StringBuilder();
final String alphabet = "abcefghijklmnopqrstuvwxyz";
for (int i = 0; i < 1000; i++) {
buf.append(alphabet);
}
final String theBlob = buf.toString();
CmsDocumentBlobSegment blob = new CmsDocumentBlobSegment(docHandle, segmentSequence, theBlob);
Set<ConstraintViolation<CmsDocumentBlobSegment>> violations = validator.validate(blob);
assertEquals(1, violations.size());
assertEquals("size must be between 1 and 4000", violations.iterator().next().getMessage());
}
use of javax.validation.ConstraintViolation in project API by ca-cwds.
the class CmsDocumentBlobSegmentTest method testConstraintDocHandleSize.
@Test
public void testConstraintDocHandleSize() throws Exception {
CmsDocumentBlobSegment blob = new CmsDocumentBlobSegment("0131351421120020*JONEM 00004", segmentSequence, docBlob);
Set<ConstraintViolation<CmsDocumentBlobSegment>> violations = validator.validate(blob);
assertEquals(1, violations.size());
assertEquals("size must be between 30 and 30", violations.iterator().next().getMessage());
}
use of javax.validation.ConstraintViolation in project javaee7-firstcup by ecabrerar.
the class BooksCollectionTest method shouldReturnAValidationError.
@Test
public void shouldReturnAValidationError() {
Book book = new Book("Effective Java", "2234555568", "");
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<Book>> violations = validator.validate(book);
Assert.assertEquals(2, violations.size());
System.out.println(violations.stream().map(error -> error.getMessage()).collect(Collectors.joining(", ")));
}
Aggregations