Package javax.validation

Examples of javax.validation.Path$CrossParameterNode


    ConstraintViolation<CustomerRepositoryImpl> constraintViolation = violations.iterator().next();
    assertThat( constraintViolation.getMessage() ).isEqualTo( messagePrefix() + "may not be null" );
    assertThat( constraintViolation.getRootBeanClass() ).isEqualTo( CustomerRepositoryImpl.class );
    assertThat( constraintViolation.getInvalidValue() ).isNull();

    Path path = constraintViolation.getPropertyPath();
    assertNodeKinds( path, ElementKind.CONSTRUCTOR, ElementKind.RETURN_VALUE, ElementKind.PROPERTY );
    assertNodeNames( path, "CustomerRepositoryImpl", "<return value>", "customer" );
  }
View Full Code Here


    Set<ConstraintViolation<C>> constraintViolations = validator.validate( c );
    assertNumberOfViolations( constraintViolations, 1 );
    assertCorrectPropertyPaths( constraintViolations, "" );

    Path path = constraintViolations.iterator().next().getPropertyPath();
    Iterator<Path.Node> nodeIterator = path.iterator();

    Path.Node node = nodeIterator.next();
    assertEquals( node.getKind(), ElementKind.BEAN, "unexpected node kind" );
  }
View Full Code Here

    Set<ConstraintViolation<D>> constraintViolations = validator.validate( d );
    assertNumberOfViolations( constraintViolations, 1 );
    assertCorrectPropertyPaths( constraintViolations, "c" );

    Path path = constraintViolations.iterator().next().getPropertyPath();
    Iterator<Path.Node> nodeIterator = path.iterator();

    Path.Node node = nodeIterator.next();
    assertEquals( node.getKind(), ElementKind.PROPERTY, "unexpected node kind" );

    node = nodeIterator.next();
View Full Code Here

    Set<ConstraintViolation<AWithListOfB>> constraintViolations = validator.validate( a );

    assertNumberOfViolations( constraintViolations, 1 );
    assertCorrectPropertyPaths( constraintViolations, "bs[0].b" );

    Path path = constraintViolations.iterator().next().getPropertyPath();
    Iterator<Path.Node> nodeIterator = path.iterator();

    Path.Node node = nodeIterator.next();
    assertEquals( node.getKind(), ElementKind.PROPERTY, "unexpected node kind" );

    node = nodeIterator.next();
View Full Code Here

    Set<ConstraintViolation<AWithArrayOfB>> constraintViolations = validator.validate( a );

    assertNumberOfViolations( constraintViolations, 1 );
    assertCorrectPropertyPaths( constraintViolations, "bs[0].b" );

    Path path = constraintViolations.iterator().next().getPropertyPath();
    Iterator<Path.Node> nodeIterator = path.iterator();

    Path.Node node = nodeIterator.next();
    assertEquals( node.getKind(), ElementKind.PROPERTY, "unexpected node kind" );

    node = nodeIterator.next();
View Full Code Here

    Set<ConstraintViolation<AWithMapOfB>> constraintViolations = validator.validate( a );

    assertNumberOfViolations( constraintViolations, 1 );
    assertCorrectPropertyPaths( constraintViolations, "bs[b].b" );

    Path path = constraintViolations.iterator().next().getPropertyPath();
    Iterator<Path.Node> nodeIterator = path.iterator();

    Path.Node node = nodeIterator.next();
    assertEquals( node.getKind(), ElementKind.PROPERTY, "unexpected node kind" );

    node = nodeIterator.next();
View Full Code Here

  private void assertConstraintViolationToOneValidation(Set<ConstraintViolation<AWithB>> constraintViolations) {
    assertNumberOfViolations( constraintViolations, 1 );
    assertCorrectPropertyPaths( constraintViolations, "b.b" );

    Path path = constraintViolations.iterator().next().getPropertyPath();
    Iterator<Path.Node> nodeIterator = path.iterator();

    Path.Node node = nodeIterator.next();
    assertEquals( node.getKind(), ElementKind.PROPERTY, "unexpected node kind" );

    node = nodeIterator.next();
View Full Code Here

  private void assertConstraintViolationPropertyValidation(Set<ConstraintViolation<A>> constraintViolations) {
    assertNumberOfViolations( constraintViolations, 1 );
    assertCorrectPropertyPaths( constraintViolations, "a" );

    Path path = constraintViolations.iterator().next().getPropertyPath();
    Iterator<Path.Node> nodeIterator = path.iterator();

    Path.Node node = nodeIterator.next();
    assertEquals( node.getKind(), ElementKind.PROPERTY, "unexpected node kind" );
  }
View Full Code Here

public class PathImplTest {

  @Test
  public void testParsing() {
    String property = "orders[3].deliveryAddress.addressline[1]";
    Path path = PathImpl.createPathFromString( property );
    Iterator<Path.Node> propIter = path.iterator();

    assertTrue( propIter.hasNext() );
    Path.Node elem = propIter.next();
    assertEquals( elem.getName(), "orders" );
    assertFalse( elem.isInIterable() );

    assertTrue( propIter.hasNext() );
    elem = propIter.next();
    assertEquals( elem.getName(), "deliveryAddress" );
    assertTrue( elem.isInIterable() );
    assertEquals( elem.getIndex(), new Integer( 3 ) );

    assertTrue( propIter.hasNext() );
    elem = propIter.next();
    assertEquals( elem.getName(), "addressline" );
    assertFalse( elem.isInIterable() );

    assertTrue( propIter.hasNext() );
    elem = propIter.next();
    assertEquals( elem.getName(), null );
    assertTrue( elem.isInIterable() );
    assertEquals( elem.getIndex(), new Integer( 1 ) );

    assertFalse( propIter.hasNext() );

    assertEquals( path.toString(), property );
  }
View Full Code Here

    }
  }

  private void buildValidationErrorMessage(StringBuilder errorMessage, ConstraintViolation<Object> violation) {
    String className = violation.getLeafBean().getClass().getCanonicalName();
    Path propertyPath = violation.getPropertyPath();

    errorMessage.append("\t");
    if (propertyPath != null && isNotBlank(propertyPath.toString())) {
      errorMessage.append("property '").append(propertyPath).append("'") //
          .append(" of class '").append(className).append("' ") //
          .append(violation.getMessage()).append("\n");
    } else {
      errorMessage.append(violation.getMessage()).append(" for class '").append(className).append("'");
View Full Code Here

TOP

Related Classes of javax.validation.Path$CrossParameterNode

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.