[ 
https://issues.apache.org/jira/browse/BVAL-149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16196491#comment-16196491
 ] 

Zhuofu Chen commented on BVAL-149:
----------------------------------

Hi, where it your fixed code?

> 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
>             Fix For: 1.1.2
>
>
> 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.4.14#64029)

Reply via email to