Hi,
The order of validation is testable in the way I described.
Quote:
Set up a Foo instance in a way you expect it to violate constraints of all three groups. Validate it and only the violation(s) of Group1 should be returned.
You would assert on the violations returned by the validator. By that you know that the constraints of Group1 are validated first, otherwise you'd see violations of the Group2 or Group3 constraints.
Quote:
Update the model so it satisfies the Group1 constraints, validate again and you should only see the Group2 constraints being violated.
Again you would assert on the violations returned by the validator. Now you see that the constraints of Group1 are validated before Group2 and Group2 before Group3 (otherwise you'd have seen constraints of Group2 in the first validation and now would see Group3 constraints).
As far as asserting that no constraint is validated twice is concerned, you could add listeners to your model for revealing the order of invocation of their getters (assuming you use getter-level constraints and not field level constraints), which gives an indication of the order of validated constraints. An alternative would be to use something like AspectJ to expose the invocation order (then even including field access) without altering your actual model. Not sure though whether that all is worth the effort really.
Hth,
--Gunnar