Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HV-1692 Change when beans are marked as processed
- in case of redefined group sequences only the last group was marked as processed while all other groups were ignored. Marking bean as processed in the loop allows to catch all the groups in the sequence
- Loading branch information
1 parent
d1f6377
commit 29c257f
Showing
2 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...hibernate/validator/test/internal/engine/groups/sequence/SequenceOnObjectsWithCycles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.test.internal.engine.groups.sequence; | ||
|
||
import java.util.Set; | ||
|
||
import javax.validation.ConstraintViolation; | ||
import javax.validation.GroupSequence; | ||
import javax.validation.Valid; | ||
import javax.validation.Validator; | ||
|
||
import org.hibernate.validator.testutil.TestForIssue; | ||
import org.hibernate.validator.testutils.ValidatorUtil; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
@TestForIssue(jiraKey = "HV-1692") | ||
public class SequenceOnObjectsWithCycles { | ||
|
||
@Test | ||
public void groupSequenceOfGroupSequences() { | ||
Validator validator = ValidatorUtil.getValidator(); | ||
|
||
YourAnnotatedBean yourEntity1 = new YourAnnotatedBean(); | ||
AnotherBean anotherBean = new AnotherBean(); | ||
anotherBean.setYourAnnotatedBean( yourEntity1 ); | ||
yourEntity1.setBean( anotherBean ); | ||
|
||
Set<ConstraintViolation<YourAnnotatedBean>> constraintViolations = validator.validate( yourEntity1 ); | ||
Assert.assertEquals( 0, constraintViolations.size() ); | ||
|
||
} | ||
|
||
@GroupSequence({ AnotherBean.class, Magic.class }) | ||
public class AnotherBean { | ||
|
||
@Valid | ||
private YourAnnotatedBean yourAnnotatedBean; | ||
|
||
|
||
public void setYourAnnotatedBean(YourAnnotatedBean yourAnnotatedBean) { | ||
this.yourAnnotatedBean = yourAnnotatedBean; | ||
} | ||
} | ||
|
||
@GroupSequence({ YourAnnotatedBean.class, Magic.class }) | ||
public class YourAnnotatedBean { | ||
|
||
@Valid | ||
private AnotherBean bean; | ||
|
||
public void setBean(AnotherBean bean) { | ||
this.bean = bean; | ||
} | ||
} | ||
|
||
public interface Magic { | ||
} | ||
} |