@@ -39,10 +39,22 @@ public class CascadedValidation {
39
39
@ State (Scope .Benchmark )
40
40
public static class CascadedValidationState {
41
41
public volatile Validator validator ;
42
+ public volatile Person person ;
42
43
43
44
public CascadedValidationState () {
44
45
ValidatorFactory factory = Validation .buildDefaultValidatorFactory ();
45
46
validator = factory .getValidator ();
47
+
48
+ // TODO graphs needs to be generated and deeper
49
+ Person kermit = new Person ( "kermit" );
50
+ Person piggy = new Person ( "miss piggy" );
51
+ Person gonzo = new Person ( "gonzo" );
52
+
53
+ kermit .addFriend ( piggy ).addFriend ( gonzo );
54
+ piggy .addFriend ( kermit ).addFriend ( gonzo );
55
+ gonzo .addFriend ( kermit ).addFriend ( piggy );
56
+
57
+ person = kermit ;
46
58
}
47
59
}
48
60
@@ -54,22 +66,13 @@ public CascadedValidationState() {
54
66
@ Warmup (iterations = 10 )
55
67
@ Measurement (iterations = 20 )
56
68
public void testCascadedValidation (CascadedValidationState state , Blackhole bh ) {
57
- // TODO graphs needs to be generated and deeper
58
- Person kermit = new Person ( "kermit" );
59
- Person piggy = new Person ( "miss piggy" );
60
- Person gonzo = new Person ( "gonzo" );
61
-
62
- kermit .addFriend ( piggy ).addFriend ( gonzo );
63
- piggy .addFriend ( kermit ).addFriend ( gonzo );
64
- gonzo .addFriend ( kermit ).addFriend ( piggy );
65
-
66
- Set <ConstraintViolation <Person >> violations = state .validator .validate ( kermit );
69
+ Set <ConstraintViolation <Person >> violations = state .validator .validate ( state .person );
67
70
assertThat ( violations ).hasSize ( 0 );
68
71
69
72
bh .consume ( violations );
70
73
}
71
74
72
- public class Person {
75
+ public static class Person {
73
76
@ NotNull
74
77
String name ;
75
78
0 commit comments