Package br.com.caelum.stella

Examples of br.com.caelum.stella.SimpleValidationMessage


     */
    public ValidationMessage getMessage(InvalidValue invalidValue) {
        try {
            Method constraintMessage = constraint.annotationType().getMethod("message");
            String message = constraintMessage.invoke(constraint).toString();
            return new SimpleValidationMessage(message);
        } catch (NoSuchMethodException e) {
            // same behavior as Hibernate Validator built-in validators
            // see
            // org.hibernate.validator.interpolator.DefaultMessageInterpolator
            throw new IllegalArgumentException("Annotation " + constraint
View Full Code Here


    public void shouldReturnCorrectValidationMessage() {
        Mockery mockery = new Mockery();
        final MessageProducer messageProducer = mockery.mock(MessageProducer.class);
        LengthValidator lengthValidator = new LengthValidator(messageProducer, 2);
        String message = "O tamanho da entrada é inválido.";
        final ValidationMessage validationMessage = new SimpleValidationMessage(message);
        mockery.checking(new Expectations() {
            {
                one(messageProducer).getMessage(with(equal(new LengthError(2))));
                will(returnValue(validationMessage));
            }
View Full Code Here

    public ValidationMessage getMessage(final InvalidValue invalidValue) {
        try {
            Method constraintMessage = constraint.annotationType().getDeclaredMethod("message");
            constraintMessage.setAccessible(true);
            String message = constraintMessage.invoke(constraint).toString();
            return new SimpleValidationMessage(message);
        } catch (NoSuchMethodException e) {
            // same behavior as Hibernate Validator built-in validators
            // see
            // org.hibernate.validator.interpolator.DefaultMessageInterpolator
            throw new IllegalArgumentException("Annotation " + constraint
View Full Code Here

     */
    public ValidationMessage getMessage(InvalidValue invalidValue) {
        try {
            Method constraintMessage = constraint.annotationType().getMethod("message");
            String message = constraintMessage.invoke(constraint).toString();
            return new SimpleValidationMessage(message);
        } catch (NoSuchMethodException e) {
            // same behavior as Hibernate Validator built-in validators
            // see org.hibernate.validator.interpolator.DefaultMessageInterpolator
            throw new IllegalArgumentException("Annotation " + constraint + " does not have an (accessible) message attribute");
        } catch (IllegalAccessException e) {
View Full Code Here

TOP

Related Classes of br.com.caelum.stella.SimpleValidationMessage

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.