[hibernate-issues] [Hibernate-JIRA] Commented: (HV-164) Add test for default group sequence isolation

Emmanuel Bernard (JIRA) noreply at atlassian.com
Wed May 27 11:59:14 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HV-164?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33253#action_33253 ] 

Emmanuel Bernard commented on HV-164:
-------------------------------------

## test 5
@GroupSequence(Default.class, Heavy.class)
interface Complete {}

interface Later {}
 
@GroupSequence( {Minimal.class, A.class} ) 
public class A { 
  @Max(value = 10, groups = Minimal.class) int size; 
  @Size(max=50) String name; //A group 
  @Valid B b; 
} 

@GroupSequence( {B.class, Later.class} ) 
public class B { 
  @SafeEncryption(groups = Heavy.class) String encryptionKey; 
  @Size(max=50) String nickname; //B group 
  @IsAdult(groups=Later.class) int age;
} 

a < b means that the constraint a must be validated before b 

When validating Default on A,
The Default group is validated and the following constraints are validated in parallel:
 - @Max on size < @Size on name
 - @Size on nickname < @IsAdult on age
If the Default group pass the following constraints are validated: @ SafeEncryption on encryptionKey

in other words, if @Max on size fails, @Size on name is not evaluated but @Size on nickname is and potentially @IsAdult on age.
If all 4 constraints pass, then the group Default pass and Heavy is evaluated

I have clarified this point in the spec BVAL-158

> Add test for default group sequence isolation
> ---------------------------------------------
>
>                 Key: HV-164
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-164
>             Project: Hibernate Validator
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 4.0.0.Beta1
>            Reporter: Emmanuel Bernard
>            Assignee: Hardy Ferentschik
>             Fix For: 4.0.0.Beta2
>
>
> public interface Minimal {}
> public interface Heavy {}
> ## test 1 - Rule D
> @GroupSequence( {Minimal.class, A.class} )
> public class A {
>   @Max(value = 10, groups = Minimal.class) int size;
>   @Size(max=50) String name; //A group
> }
> @GroupSequence( {B.class, Heavy.class} )
> public class B extends A {
>   @SafeEncryption(groups = Heavy.class) String encryptionKey;
>   @Size(max=50) String nickname; //B group
> }
> when validating Default.class on B, you need to validate sequentially:
>  - @Size on name and @Size on nickname (A is part of B)
>  - @SafeEncryption on encryptionKey
> note that @Max on size is not validated as it's not part of the sequence nor the group A
> ## test 2 - Rule D
> @GroupSequence( {Minimal.class, A.class} )
> public class A {
>   @Max(value = 10, groups = Minimal.class) int size;
>   @Size(max=50) String name; //A group
> }
> @GroupSequence( {Minimal.class, B.class, Heavy.class} )
> public class B extends A {
>   @SafeEncryption(groups = Heavy.class) String encryptionKey;
>   @Size(max=50) String nickname; //B group
> }
> when validating Default.class on B, you need to validate sequentially:
>  - @Max on size (Minnimal group)
>  - @Size on name and @Size on nickname (A is part of B)
>  - @SafeEncryption on encryptionKey
> ## test 3 Rules C1 and C2
> @GroupSequence( {Minimal.class, A.class} )
> public class A {
>   @Max(value = 10, groups = Minimal.class) int size; 
>   @Size(max=50) String name; //A group
> }
> public class B extends A {
>   @SafeEncryption(groups = Heavy.class) String encryptionKey;
>   @Size(max=50) String nickname; //B group
> }
> when validating Default.class on B, you need to validate sequentially:
>  - @Max on size (Minimal)
>  - @Size on name (A)
> and in // at any time @Size on nickname (B group). Note that B is not constrained by the group sequence defined by A, B contains A. @Size on nickname could fail but @Size on name will be validated. Likewise @Max on size could fail and @Size on nickname (A) will be validated (note that @Size on nickname (B) will not as it has to be validated only if Minimal constraints pass)
> All based on http://people.redhat.com/~ebernard/validation/#constraintdeclarationvalidationprocess-groupsequence-formaldefinition
> particularly
> C1, C2 and D

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list