bval-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Benson (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (BVAL-149) ConstraintViolation contains wrong property
Date Wed, 19 Oct 2016 22:06:58 GMT

     [ https://issues.apache.org/jira/browse/BVAL-149?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Matt Benson resolved BVAL-149.
------------------------------
    Resolution: Fixed

Committed revision 1765727.

> ConstraintViolation contains wrong property
> -------------------------------------------
>
>                 Key: BVAL-149
>                 URL: https://issues.apache.org/jira/browse/BVAL-149
>             Project: BVal
>          Issue Type: Bug
>    Affects Versions: 1.1.0, 1.1.1
>            Reporter: John Myers
>            Assignee: Matt Benson
>
> The following test case fails with:
> {noformat}
> java.lang.AssertionError: expected [booleanFalse] but found [booleanTrue]
> Expected :booleanFalse
> Actual   :booleanTrue
> {noformat}
> {code}
> import com.google.common.collect.Iterables;
> import org.apache.bval.jsr.ApacheValidationProvider;
> import org.testng.annotations.Test;
> import javax.validation.ConstraintViolation;
> import javax.validation.Validation;
> import javax.validation.Validator;
> import javax.validation.constraints.AssertTrue;
> import static org.testng.Assert.assertEquals;
> public class TestValidation
> {
>     private static final Validator VALIDATOR = Validation.byProvider(ApacheValidationProvider.class).configure().buildValidatorFactory().getValidator();
>     @Test
>     public void testViolationIdentifiesCorrectAttribute()
>     {
>         TestingObject trueObject = new TestingObject();
>         ConstraintViolation<TestingObject> violation = Iterables.getOnlyElement(VALIDATOR.validate(trueObject));
>         assertEquals(violation.getMessage(), "boolean is false");
>         assertEquals(violation.getPropertyPath().toString(), "booleanFalse");
>     }
>     private static class TestingObject
>     {
>         @AssertTrue(message = "boolean is true")
>         private boolean isBooleanTrue()
>         {
>             return true;
>         }
>         @AssertTrue(message = "boolean is false")
>         private boolean isBooleanFalse()
>         {
>             return false;
>         }
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message