Package org.springmodules.validation.bean.conf

Examples of org.springmodules.validation.bean.conf.CascadeValidation


        // configuring the expectations of the bean wrapper that will be used to extract the array property
        wrapperControl.expectAndReturn(wrapper.getPropertyType("array"), Object[].class);
        wrapperControl.expectAndReturn(wrapper.getPropertyValue("array"), propertyValue);

        CascadeValidation[] cascadeValidations = new CascadeValidation[] { new CascadeValidation("array") };
        configurationControl.expectAndReturn(configuration.getCascadeValidations(), cascadeValidations);
        loaderControl.expectAndReturn(loader.loadConfiguration(Object.class), configuration);

        replay();
        validator.validateObjectGraphConstraints(object, object, errors, validatedObjects);
View Full Code Here


        // configuring the expectations of the bean wrapper that will be used to extract the array property
        wrapperControl.expectAndReturn(wrapper.getPropertyType("list"), List.class);
        wrapperControl.expectAndReturn(wrapper.getPropertyValue("list"), propertyValue);

        CascadeValidation[] cascadeValidations = new CascadeValidation[] { new CascadeValidation("list") };
        configurationControl.expectAndReturn(configuration.getCascadeValidations(), cascadeValidations);
        loaderControl.expectAndReturn(loader.loadConfiguration(Object.class), configuration);

        replay();
        validator.validateObjectGraphConstraints(object, object, errors, validatedObjects);
View Full Code Here

        // configuring the expectations of the bean wrapper that will be used to extract the array property
        wrapperControl.expectAndReturn(wrapper.getPropertyType("set"), Set.class);
        wrapperControl.expectAndReturn(wrapper.getPropertyValue("set"), propertyValue);

        CascadeValidation[] cascadeValidations = new CascadeValidation[] { new CascadeValidation("set") };
        configurationControl.expectAndReturn(configuration.getCascadeValidations(), cascadeValidations);
        loaderControl.expectAndReturn(loader.loadConfiguration(Object.class), configuration);

        replay();
        validator.validateObjectGraphConstraints(object, object, errors, validatedObjects);
View Full Code Here

        // configuring the expectations of the bean wrapper that will be used to extract the array property
        wrapperControl.expectAndReturn(wrapper.getPropertyType("map"), Map.class);
        wrapperControl.expectAndReturn(wrapper.getPropertyValue("map"), propertyValue);

        CascadeValidation[] cascadeValidations = new CascadeValidation[] { new CascadeValidation("map") };
        configurationControl.expectAndReturn(configuration.getCascadeValidations(), cascadeValidations);
        loaderControl.expectAndReturn(loader.loadConfiguration(Object.class), configuration);

        replay();
        validator.validateObjectGraphConstraints(object, object, errors, validatedObjects);
View Full Code Here

        // configuring the expectations of the bean wrapper that will be used to extract the array property
        wrapperControl.expectAndReturn(wrapper.getPropertyType("subBean"), Object.class);
        wrapperControl.expectAndReturn(wrapper.getPropertyValue("subBean"), propertyValue);

        CascadeValidation[] cascadeValidations = new CascadeValidation[] { new CascadeValidation("subBean") };
        configurationControl.expectAndReturn(configuration.getCascadeValidations(), cascadeValidations);
        loaderControl.expectAndReturn(loader.loadConfiguration(Object.class), configuration);

        replay();
        validator.validateObjectGraphConstraints(object, object, errors, validatedObjects);
View Full Code Here

        // after all the validation rules where applied, checking what properties of the object require their own
        // validation and recursively calling this method on them.
        CascadeValidation[] cascadeValidations = configuration.getCascadeValidations();
        BeanWrapper wrapper = wrapBean(obj);
        for (int i=0; i<cascadeValidations.length; i++) {
            CascadeValidation cascadeValidation = cascadeValidations[i];
            Condition applicabilityCondition = cascadeValidation.getApplicabilityCondition();

            if (!applicabilityCondition.check(obj)) {
                continue;
            }

            String propertyName = cascadeValidation.getPropertyName();
            Class propertyType = wrapper.getPropertyType(propertyName);
            Object propertyValue = wrapper.getPropertyValue(propertyName);

            // if the property value is not there nothing to validate.
            if (propertyValue == null) {
View Full Code Here

        Element propertyDefinition = element("property",
            new String[] { "name", "cascade" },
            new String[] { "name", "true" }
        );

        configuration.addCascadeValidation(new CascadeValidation("name"));

        replay();
        loader.handlePropertyDefinition(propertyDefinition, TestBean.class, configuration);
        verify();
    }
View Full Code Here

        Element ruleDefinition = element(document, "rule");
        propertyDefinition.appendChild(ruleDefinition);

        PropertyDescriptor descriptor = BeanUtils.getPropertyDescriptor(TestBean.class, "name");

        configuration.addCascadeValidation(new CascadeValidation("name"));
        registryControl.expectAndReturn(registry.findPropertyHandler(ruleDefinition, TestBean.class, descriptor), propertyHandler);
        propertyHandler.handle(ruleDefinition, "name", configuration);

        final PropertyValidationRule propertyRule = new PropertyValidationRule("name", rule);
        loader = new DefaultXmlBeanValidationConfigurationLoader(registry) {
View Full Code Here

        Element ruleDefinition = element(document, "rule");
        propertyDefinition.appendChild(ruleDefinition);

        PropertyDescriptor descriptor = BeanUtils.getPropertyDescriptor(TestBean.class, "name");

        configuration.addCascadeValidation(new CascadeValidation("name"));
        registryControl.expectAndReturn(registry.findPropertyHandler(ruleDefinition, TestBean.class, descriptor), null);

        replay();

        try {
View Full Code Here

     * @param configuration The bean validation configuration to manipulate.
     */
    public void handleAnnotation(Annotation annotation, Class clazz, PropertyDescriptor descriptor, MutableBeanValidationConfiguration configuration) {

        if (annotation instanceof Valid) {
            configuration.addCascadeValidation(new CascadeValidation(descriptor.getName()));
            return;
        }

        Class annotationClass = annotation.annotationType();
        ValidatorClass validatorClassAnnotation = (ValidatorClass) annotationClass.getAnnotation(ValidatorClass.class);
View Full Code Here

TOP

Related Classes of org.springmodules.validation.bean.conf.CascadeValidation

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.