Package org.apache.bval.jsr303

Examples of org.apache.bval.jsr303.ValidatorResolutionTest$Person


   * uses prop[index] in property path for elements in to-many-relationships.
   *
   * @return the path in dot notation
   */
  public PathImpl getPropertyPath() {
    PathImpl currentPath = PathImpl.copy(path);
    if (getMetaProperty() != null) {
      currentPath.addNode(new NodeImpl(getMetaProperty().getName()));
    }
    return currentPath;
  }
View Full Code Here


      }
    }
  }

  private boolean isReachable(GroupValidationContext context) {
    PathImpl path = context.getPropertyPath();
    NodeImpl node = path.getLeafNode();
    PathImpl beanPath = path.getPathWithoutLeafNode();
    if (beanPath == null) {
      beanPath = PathImpl.create(null);
    }
    try {
      if (!context.getTraversableResolver()
View Full Code Here

        Path path = PathImpl.createPathFromString("");
        assertEquals(null, path.iterator().next().getName());
    }

    public void testToString() {
        PathImpl path = PathImpl.create(null);
        path.addNode(new NodeImpl("firstName"));
        assertEquals("firstName", path.toString());

        path = PathImpl.create(null);
        path.getLeafNode().setIndex(2);
        assertEquals("[2]", path.toString());
        path.addNode(new NodeImpl("firstName"));
        assertEquals("[2].firstName", path.toString());
    }
View Full Code Here

     * @return <code>true</code> if the validator can access the related bean,
     *         <code>false</code> otherwise.
     */
    private boolean isCascadable(GroupValidationContext<?> context, MetaProperty prop, AccessStrategy access) {
       
        PathImpl beanPath = context.getPropertyPath();
        NodeImpl node = new NodeImpl(prop.getName());
        if (beanPath == null) {
            beanPath = PathImpl.create(null);
        }
        try {
View Full Code Here

        // persons[1]
        cvb.addNode("person").addNode(null).inIterable().atIndex(1)
                .addConstraintViolation();
        Error error = cvc.getErrorMessages().iterator().next();
        PathImpl errorPath = (PathImpl) error.getOwner();
        Assert.assertEquals("Incorrect path created", "person[1]", errorPath.toString());

        resetConstraintValidatorContext();

        // persons[lawyer].name
        cvb.addNode("person").addNode("name").inIterable().atKey("john")
                .addConstraintViolation();
        error = cvc.getErrorMessages().iterator().next();
        errorPath = (PathImpl) error.getOwner();
        Assert.assertEquals("Incorrect path created", "person[john].name", errorPath.toString());

        resetConstraintValidatorContext();

        // [0].name[]
        cvb.addNode(null).addNode("name").inIterable().atIndex(0).addNode(null)
                .inIterable().addConstraintViolation();
        error = cvc.getErrorMessages().iterator().next();
        errorPath = (PathImpl) error.getOwner();
        Assert.assertEquals("Incorrect path created", "[0].name[]", errorPath.toString());

        resetConstraintValidatorContext();

        // []
        cvb.addNode(null).addNode(null).inIterable().addConstraintViolation();
        error = cvc.getErrorMessages().iterator().next();
        errorPath = (PathImpl) error.getOwner();
        Assert.assertEquals("Incorrect path created", "[]", errorPath.toString());
       
        resetConstraintValidatorContext();
       
        // Adding only nulls should still give a root path
        cvb.addNode(null).addNode(null).addNode(null).addNode(null).addConstraintViolation();
        error = cvc.getErrorMessages().iterator().next();
        errorPath = (PathImpl) error.getOwner();
        Assert.assertTrue("Created path must be a root path", errorPath.isRootPath());

    }
View Full Code Here

     * to-many-relationships.
     *
     * @return the path in dot notation
     */
    public PathImpl getPropertyPath() {
        PathImpl currentPath = PathImpl.copy(path);
        if (getMetaProperty() != null) {
            currentPath.addProperty(getMetaProperty().getName());
        }
        return currentPath;
    }
View Full Code Here

                                    }
                                    stream = new StreamSource(inp1);
                                    unmarshaller = CONSTRAINTMAPPINGSTYPE_JAXBCONTEXT.createUnmarshaller();
                                    unmarshaller.setSchema(VALIDATION_MAPPING_SCHMEA);
                                    JAXBElement<ConstraintMappingsType> mappingRoot = unmarshaller.unmarshal(stream, ConstraintMappingsType.class);
                                    ConstraintMappingsType constraintMappings = mappingRoot.getValue();
                                } catch (JAXBException e) {
                                    log.debug("Error processing constraint mapping file "+mappingFileName+" specified in "+validationConfig+" in module "+module.getName(), e);
                                } catch (IOException e) {
                                    log.debug("Error processing constraint mapping file "+mappingFileName+" specified in "+validationConfig+" in module "+module.getName(), e);
                                } finally {
View Full Code Here

                    Unmarshaller unmarshaller = VALIDATION_CONFIGURATION_JAXBCONTEXT.createUnmarshaller();
                    unmarshaller.setSchema(VALIDATION_CONFIGURATION_SCHMEA);
                    inp = validationConfigEntry.openStream();
                    StreamSource stream = new StreamSource(inp);
                    JAXBElement<ValidationConfigType> root = unmarshaller.unmarshal(stream, ValidationConfigType.class);
                    ValidationConfigType xmlConfig = root.getValue();
                    if(xmlConfig.getConstraintMapping().size() > 0) {
                        for (JAXBElement<String> mappingFileNameElement : xmlConfig.getConstraintMapping()) {
                            String mappingFileName = mappingFileNameElement.getValue();
                            if(bundle.getEntry(mappingFileName) == null) {
                                if (log.isDebugEnabled()) {
                                    log.debug("Non-existent constraint mapping file " + mappingFileName + " specified in " + validationConfig + " in module " + module.getName());
                                }
View Full Code Here

            if (validationConfig == null) {
                // just create the default
                createDefaultFactory();
            } else {
                // Parse the validation xml
                ValidationConfigType validationConfigType = null;
                try {
                    Unmarshaller unmarshaller = VALIDATION_FACTORY_CONTEXT.createUnmarshaller();
                    unmarshaller.setSchema(VALIDATION_FACTORY_SCHEMA);
                    URL validationConfigURL = null;
                    if(moduleName == null) {
View Full Code Here

        getProperties().putAll(configuration.getProperties());
        setMessageInterpolator(configuration.getMessageInterpolator());
        setTraversableResolver(configuration.getTraversableResolver());
        setConstraintValidatorFactory(configuration
            .getConstraintValidatorFactory());
        ValidationMappingParser parser = new ValidationMappingParser(this);
        parser.processMappingConfig(configuration.getMappingStreams());
    }
View Full Code Here

TOP

Related Classes of org.apache.bval.jsr303.ValidatorResolutionTest$Person

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.