Examples of AnnotationMessageProducer


Examples of br.com.caelum.stella.bean.validation.logic.AnnotationMessageProducer

        Field field = BeanToBeValidated.class.getDeclaredField("field");
        field.setAccessible(true);
        FakeConstraint constraint = field.getAnnotation(FakeConstraint.class);

        {
            AnnotationMessageProducer producer = new AnnotationMessageProducer(constraint);
            ValidationMessage validationMessage = producer.getMessage(Errors.ANY);
            Assert.assertEquals(constraint.message(), validationMessage.getMessage());
        }
        {
            AnnotationMessageProducer producer = new AnnotationMessageProducer(constraint);
            ValidationMessage validationMessage = producer.getMessage(Errors.OTHER);
            Assert.assertEquals(constraint.message(), validationMessage.getMessage());
        }
    }
View Full Code Here

Examples of br.com.caelum.stella.bean.validation.logic.AnnotationMessageProducer

    public void shouldThrowIllegalArgumentExceptionIfConstraintHasNoMessage() throws Exception {
        Field field = BeanToBeValidated.class.getDeclaredField("other");
        field.setAccessible(true);
        ConstraintWithoutMessage constraint = field.getAnnotation(ConstraintWithoutMessage.class);

        AnnotationMessageProducer producer = new AnnotationMessageProducer(constraint);
        try {
            @SuppressWarnings("unused")
            ValidationMessage validationMessage = producer.getMessage(Errors.ANY);
            fail();
        } catch (IllegalArgumentException e) {
            // ok
        } catch (Exception e) {
            // any other exception should fail
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.