Package javax.validation.Path

Examples of javax.validation.Path.Node


   * Returns the category for this constraint violation. By default, the category returned
   * is the full path for property. You can override this method if you prefer another strategy.
   */
  protected String extractCategory(ValuedParameter[] params, ConstraintViolation<Object> violation) {
    Iterator<Node> path = violation.getPropertyPath().iterator();
    Node method = path.next();
    logger.debug("Constraint violation on method {}: {}", method, violation);

    StringBuilder cat = new StringBuilder();
    cat.append(params[path.next().as(ParameterNode.class).getParameterIndex()].getName());// parameter name

View Full Code Here


        "arg0"
    ).getPropertyPath().iterator();

    //parameter 0
    assertTrue( nodeIter.hasNext() );
    Node nextNode = nodeIter.next();
    assertNode( nextNode, methodName, ElementKind.METHOD, false, null, null );

    MethodNode methodNode = nextNode.as( MethodNode.class );
    assertNotNull( methodNode );
    assertEquals(
        methodNode.getParameterTypes(),
        Arrays.<Class<?>>asList( String.class, Person.class, List.class )
    );

    assertTrue( nodeIter.hasNext() );
    nextNode = nodeIter.next();
    assertNode( nextNode, "arg0", ElementKind.PARAMETER, false, null, null );
    ParameterNode parameterNode = nextNode.as( ParameterNode.class );
    assertNotNull( parameterNode );
    assertEquals( parameterNode.getParameterIndex(), 0 );

    assertFalse( nodeIter.hasNext() );

    //parameter 1
    nodeIter = getConstraintViolationForParameter( constraintViolations, "arg1" ).getPropertyPath().iterator();

    assertTrue( nodeIter.hasNext() );
    assertNode( nodeIter.next(), methodName, ElementKind.METHOD, false, null, null );

    assertTrue( nodeIter.hasNext() );
    nextNode = nodeIter.next();
    assertNode( nextNode, "arg1", ElementKind.PARAMETER, false, null, null );
    parameterNode = nextNode.as( ParameterNode.class );
    assertNotNull( parameterNode );
    assertEquals( parameterNode.getParameterIndex(), 1 );

    assertFalse( nodeIter.hasNext() );
  }
View Full Code Here

    assertTrue( nodeIter.hasNext() );
    assertNode( nodeIter.next(), methodName, ElementKind.METHOD, false, null, null );

    assertTrue( nodeIter.hasNext() );
    Node nextNode = nodeIter.next();
    assertNode( nextNode, TestUtil.RETURN_VALUE_NODE_NAME, ElementKind.RETURN_VALUE, false, null, null );

    ReturnValueNode returnValueNode = nextNode.as( ReturnValueNode.class );
    assertNotNull( returnValueNode );

    assertFalse( nodeIter.hasNext() );
  }
View Full Code Here

        "arg0"
    ).getPropertyPath().iterator();

    //parameter 0
    assertTrue( nodeIter.hasNext() );
    Node nextNode = nodeIter.next();
    assertNode( nextNode, "MovieStudio", ElementKind.CONSTRUCTOR, false, null, null );

    ConstructorNode constructorNode = nextNode.as( ConstructorNode.class );
    assertNotNull( constructorNode );
    assertEquals( constructorNode.getParameterTypes(), Arrays.<Class<?>>asList( String.class, Person.class ) );

    assertTrue( nodeIter.hasNext() );
    nextNode = nodeIter.next();
    assertNode( nextNode, "arg0", ElementKind.PARAMETER, false, null, null );
    ParameterNode parameterNode = nextNode.as( ParameterNode.class );
    assertNotNull( parameterNode );
    assertEquals( parameterNode.getParameterIndex(), 0 );

    assertFalse( nodeIter.hasNext() );

    //parameter 1
    nodeIter = getConstraintViolationForParameter( constraintViolations, "arg1" ).getPropertyPath().iterator();

    assertTrue( nodeIter.hasNext() );
    assertNode( nodeIter.next(), "MovieStudio", ElementKind.CONSTRUCTOR, false, null, null );

    assertTrue( nodeIter.hasNext() );
    nextNode = nodeIter.next();
    assertNode( nextNode, "arg1", ElementKind.PARAMETER, false, null, null );
    parameterNode = nextNode.as( ParameterNode.class );
    assertNotNull( parameterNode );
    assertEquals( parameterNode.getParameterIndex(), 1 );

    assertFalse( nodeIter.hasNext() );
  }
View Full Code Here

    assertTrue( nodeIter.hasNext() );
    assertNode( nodeIter.next(), "MovieStudio", ElementKind.CONSTRUCTOR, false, null, null );

    assertTrue( nodeIter.hasNext() );
    Node nextNode = nodeIter.next();
    assertNode(
        nextNode,
        TestUtil.CROSS_PARAMETER_NODE_NAME,
        ElementKind.CROSS_PARAMETER,
        false,
        null,
        null
    );

    CrossParameterNode crossParameterNode = nextNode.as( CrossParameterNode.class );
    assertNotNull( crossParameterNode );

    assertFalse( nodeIter.hasNext() );
  }
View Full Code Here

    ConstraintViolation<VerySpecialClass> constraintViolation = constraintViolations.iterator().next();

    Iterator<Path.Node> nodeIter = constraintViolation.getPropertyPath().iterator();

    assertTrue( nodeIter.hasNext() );
    Node node = nodeIter.next();
    assertNode( node, TestUtil.BEAN_NODE_NAME, ElementKind.BEAN, false, null, null );

    node.as( PropertyNode.class );
  }
View Full Code Here

        "arg0"
    ).getPropertyPath().iterator();

    //parameter 0
    assertTrue( nodeIter.hasNext() );
    Node nextNode = nodeIter.next();
    assertNode( nextNode, "MovieStudio", ElementKind.CONSTRUCTOR, false, null, null );

    nextNode.as( PropertyNode.class );
  }
View Full Code Here

        "arg0"
    ).getPropertyPath().iterator();

    //parameter 0
    assertTrue( nodeIter.hasNext() );
    Node nextNode = nodeIter.next();
    assertNode( nextNode, "MovieStudio", ElementKind.CONSTRUCTOR, false, null, null );

    ConstructorNode constructorNode = nextNode.as( ConstructorNode.class );
    assertNotNull( constructorNode );
    assertEquals( constructorNode.getParameterTypes(), Arrays.<Class<?>>asList( String.class, Person.class ) );

    assertTrue( nodeIter.hasNext() );
    nextNode = nodeIter.next();
    assertNode( nextNode, "arg0", ElementKind.PARAMETER, false, null, null );
    nextNode.as( BeanNode.class );
  }
View Full Code Here

        .next();

    Iterator<Path.Node> nodeIter = constraintViolation.getPropertyPath().iterator();

    assertTrue( nodeIter.hasNext() );
    Node node = nodeIter.next();
    assertNode( node, TestUtil.BEAN_NODE_NAME, ElementKind.BEAN, false, null, null );
    BeanNode beanNode = node.as( BeanNode.class );
    assertNotNull( beanNode );

    assertFalse( nodeIter.hasNext() );
  }
View Full Code Here

    ConstraintViolation<Engine> constraintViolation = constraintViolations.iterator().next();

    Iterator<Path.Node> nodeIter = constraintViolation.getPropertyPath().iterator();

    assertTrue( nodeIter.hasNext() );
    Node node = nodeIter.next();
    assertNode( node, "serialNumber", ElementKind.PROPERTY, false, null, null );
    PropertyNode propertyNode = node.as( PropertyNode.class );
    assertNotNull( propertyNode );
    assertFalse( nodeIter.hasNext() );
  }
View Full Code Here

TOP

Related Classes of javax.validation.Path.Node

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.