Examples of Errors


Examples of org.springframework.validation.Errors

    @Translate
    @RemoteMethod
    @SuppressWarnings("unchecked")
    public Object validatePrimitive(Class clazz, String path, String value) throws Exception {
        Errors e = doValidation(clazz, path, value);
        return e.getFieldErrors(path);
    }
View Full Code Here

Examples of org.springframework.validation.Errors

        DomainEntity object = (DomainEntity) ClassUtils.instantiateClass(clazz);
        object.initialize(contextHolder);
        BeanWrapper validatable = new BeanWrapperImpl(object);
        validatable.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), false));
        validatable.setPropertyValue(path, value);
        Errors errors = new BeanPropertyBindingResult(object, "target");
        validator.validate(object, errors);
        return errors;
    }
View Full Code Here

Examples of org.springframework.validation.Errors

        user.setUsername(VALID_NAME);
        user.setPassword(VALID_PASSWORD);
        user.setConfirmPassword(VALID_PASSWORD);
        user.setEmail(VALID_EMAIL);

        Errors errors = new BindException(user, USER);
        validator.validate(user, errors);

        assertFalse("No errors", errors.hasErrors());
    }
View Full Code Here

Examples of org.springframework.validation.Errors

    public void testValidateFailsOnEmptyPassword() throws Exception {
        User user = new UserImpl();
        user.setUsername(VALID_NAME);
        user.setEmail(VALID_EMAIL);

        Errors errors = new BindException(user, USER);
        validator.validate(user, errors);

        assertTrue("Validation errors", errors.hasErrors());
        assertNotNull(errors.getFieldError(FIELD_PASSWORD));

    }
View Full Code Here

Examples of org.springframework.validation.Errors

        User user = new UserImpl();
        user.setUsername(VALID_NAME);
        user.setPassword("123");
        user.setPassword("123");

        Errors errors = new BindException(user, USER);
        validator.validate(user, errors);

        assertTrue("Validation errors", errors.hasErrors());
        assertNotNull(errors.getFieldError(FIELD_PASSWORD));

    }
View Full Code Here

Examples of org.springframework.validation.Errors

        User user = new UserImpl();
        user.setUsername(VALID_NAME);
        user.setPassword(VALID_PASSWORD);
        user.setConfirmPassword("DoesNotMatch");

        Errors errors = new BindException(user, USER);
        validator.validate(user, errors);

        assertTrue("Validation errors", errors.hasErrors());
        assertNotNull(errors.getFieldError(FIELD_CONFIRM_PASSWORD));

    }
View Full Code Here

Examples of org.springframework.validation.Errors

        widget.setId("123");
        widget.setTitle(VALID_TITLE);
        widget.setUrl(VALID_URL);
        widget.setType(VALID_TYPE);
        widget.setDescription(VALID_DESCRIPTION);
        Errors errors = new BindException(widget, WIDGET);

        expect(widgetService.getWidgetByUrl(VALID_URL)).andReturn(widget);
        replay(widgetService);
        widgetValidator.validate(widget, errors);
        verify(widgetService);

        assertFalse("No validation errors", errors.hasErrors());
    }
View Full Code Here

Examples of org.springframework.validation.Errors

    }

    @Test
    public void testValidationFailsOnEmptyValues() {
        Widget widget = new WidgetImpl();
        Errors errors = new BindException(widget, WIDGET);

        widgetValidator.validate(widget, errors);

        assertEquals(4, errors.getErrorCount());
    }
View Full Code Here

Examples of org.springframework.validation.Errors

        Widget newWidget = new WidgetImpl();
        newWidget.setTitle(VALID_TITLE);
        newWidget.setType(VALID_TYPE);
        newWidget.setDescription(VALID_DESCRIPTION);
        newWidget.setUrl(existingUrl);
        Errors errors = new BindException(newWidget, WIDGET);

        expect(widgetService.getWidgetByUrl(existingUrl)).andReturn(widget);
        replay(widgetService);

        widgetValidator.validate(newWidget, errors);
        verify(widgetService);
        assertEquals(1, errors.getErrorCount());
        assertNotNull("Field error for duplicate url", errors.getFieldError("url"));
    }
View Full Code Here

Examples of org.springframework.validation.Errors

        widget.setDescription(VALID_DESCRIPTION);
        widget.setUrl("http:/this.is/invalid?url=true&reject=true");
        widget.setScreenshotUrl("https://///invalid/screenshot");
        widget.setThumbnailUrl("thumbnail");
        widget.setTitleUrl("titleUrl");
        Errors errors = new BindException(widget, WIDGET);

        widgetValidator.validate(widget, errors);
        assertEquals(4, errors.getErrorCount());
        assertNotNull("Field error on url", errors.getFieldError("url"));
        assertNotNull("Field error on screenshot url", errors.getFieldError("screenshotUrl"));
        assertNotNull("Field error on thumbnail url", errors.getFieldError("thumbnailUrl"));
        assertNotNull("Field error on title url", errors.getFieldError("titleUrl"));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.