Package javax.validation.ConstraintValidatorContext

Examples of javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder


  private void passViolations(ConstraintValidatorContext context,
      Set<ConstraintViolation<Object>> source) {
    for (final ConstraintViolation<Object> violation : source) {
      final Iterator<Node> nodeIter = violation.getPropertyPath()
          .iterator();
      final ConstraintViolationBuilder builder = context
          .buildConstraintViolationWithTemplate(violation
              .getMessageTemplate());
            ConstraintValidatorContext nodeContext;

      if (nodeIter.hasNext()) {
        StringBuilder sb = new StringBuilder(nodeIter.next().getName());

        if (supportsConstraintComposition) {
          while (nodeIter.hasNext()) {
            sb.append('.').append(nodeIter.next());
          }
        }

        builder.addNode(sb.toString()).addConstraintViolation();
      } else {
                builder.addConstraintViolation();
            }
    }
  }
View Full Code Here


     */
    @Test
    public void rejectsInvalidSyslog() throws Exception {
        final ConstraintValidatorContext ctx =
            Mockito.mock(ConstraintValidatorContext.class);
        final ConstraintViolationBuilder builder =
            Mockito.mock(ConstraintViolationBuilder.class);
        Mockito.doReturn(builder).when(ctx)
            .buildConstraintViolationWithTemplate(Mockito.anyString());
        Mockito.doReturn(Mockito.mock(NodeBuilderCustomizableContext.class))
            .when(builder).addPropertyNode(Mockito.anyString());
View Full Code Here

TOP

Related Classes of javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.