Package org.springframework.validation

Examples of org.springframework.validation.BindException


        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


    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

        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

        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

        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

    }

    @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

        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

        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

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

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

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

    }

    @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

TOP

Related Classes of org.springframework.validation.BindException

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.