2121import build .buf .validate .conformance .cases .AnEnum ;
2222import build .buf .validate .conformance .cases .BoolConstTrue ;
2323import build .buf .validate .conformance .cases .BytesContains ;
24+ import build .buf .validate .conformance .cases .BytesIn ;
2425import build .buf .validate .conformance .cases .DurationGTELTE ;
2526import build .buf .validate .conformance .cases .Embed ;
2627import build .buf .validate .conformance .cases .EnumDefined ;
@@ -64,33 +65,33 @@ public void setUp() {
6465 public void strprefix () throws Exception {
6566 StringPrefix invalid = StringPrefix .newBuilder ().setVal ("foo" ).build ();
6667 ValidationResult validate = validator .validate (invalid );
67- assertThat (validate .getViolations (). isEmpty ()). isTrue ();
68- assertThat (validate .getViolations ()).hasSize ( 0 );
68+ assertThat (validate .getViolations ()). isEmpty ();
69+ assertThat (validate .isSuccess ()).isTrue ( );
6970 }
7071
7172 @ Test
7273 public void bytescontains () throws Exception {
7374 BytesContains invalid =
7475 BytesContains .newBuilder ().setVal (ByteString .copyFromUtf8 ("candy bars" )).build ();
7576 ValidationResult validate = validator .validate (invalid );
76- assertThat (validate .getViolations (). isEmpty ()). isTrue ();
77- assertThat (validate .getViolations ()).hasSize ( 0 );
77+ assertThat (validate .getViolations ()). isEmpty ();
78+ assertThat (validate .isSuccess ()).isTrue ( );
7879 }
7980
8081 @ Test
8182 public void strcontains () throws Exception {
8283 StringContains invalid = StringContains .newBuilder ().setVal ("foobar" ).build ();
8384 ValidationResult validate = validator .validate (invalid );
84- assertThat (validate .getViolations (). isEmpty ()). isTrue ();
85- assertThat (validate .getViolations ()).hasSize ( 0 );
85+ assertThat (validate .getViolations ()). isEmpty ();
86+ assertThat (validate .isSuccess ()).isTrue ( );
8687 }
8788
8889 @ Test
8990 public void boolconsttrue () throws Exception {
9091 BoolConstTrue invalid = BoolConstTrue .newBuilder ().build ();
9192 ValidationResult validate = validator .validate (invalid );
9293 assertThat (validate .getViolations ()).hasSize (1 );
93- assertThat (validate .isSuccess ()).isTrue ();
94+ assertThat (validate .isSuccess ()).isFalse ();
9495 }
9596
9697 @ Test
@@ -99,41 +100,41 @@ public void timestampwithin() throws Exception {
99100 TimestampWithin .newBuilder ().setVal (Timestamp .newBuilder ().build ()).build ();
100101 ValidationResult validate = validator .validate (invalid );
101102 assertThat (validate .getViolations ()).hasSize (1 );
102- assertThat (validate .isSuccess ()).isTrue ();
103+ assertThat (validate .isSuccess ()).isFalse ();
103104 }
104105
105106 @ Test
106107 public void timestampcost () throws Exception {
107108 TimestampConst invalid =
108109 TimestampConst .newBuilder ().setVal (Timestamp .newBuilder ().setSeconds (3 ).build ()).build ();
109110 ValidationResult validate = validator .validate (invalid );
110- assertThat (validate .getViolations (). isEmpty ()). isTrue ();
111- assertThat (validate .getViolations ()).hasSize ( 0 );
111+ assertThat (validate .getViolations ()). isEmpty ();
112+ assertThat (validate .isSuccess ()).isTrue ( );
112113 }
113114
114115 @ Test
115- public void OneofIgnoreEmpty () throws Exception {
116+ public void oneofIgnoreEmpty () throws Exception {
116117 OneofIgnoreEmpty invalid =
117118 OneofIgnoreEmpty .newBuilder ().setY (ByteString .copyFromUtf8 ("" )).build ();
118119 ValidationResult validate = validator .validate (invalid );
119- assertThat (validate .getViolations (). isEmpty ()). isTrue ();
120- assertThat (validate .getViolations ()).hasSize ( 0 );
120+ assertThat (validate .getViolations ()). isEmpty ();
121+ assertThat (validate .isSuccess ()).isTrue ( );
121122 }
122123
123124 @ Test
124125 public void enumdefined () throws Exception {
125126 EnumDefined invalid = EnumDefined .newBuilder ().setValValue (2147483647 ).build ();
126127 ValidationResult validate = validator .validate (invalid );
127128 assertThat (validate .getViolations ()).hasSize (1 );
128- assertThat (validate .isSuccess ()).isTrue ();
129+ assertThat (validate .isSuccess ()).isFalse ();
129130 }
130131
131132 @ Test
132133 public void strictFixed32LT () throws Exception {
133134 Fixed32LT invalid = Fixed32LT .newBuilder ().setVal (5 ).build ();
134135 ValidationResult validate = validator .validate (invalid );
135136 assertThat (validate .getViolations ()).hasSize (1 );
136- assertThat (validate .isSuccess ()).isTrue ();
137+ assertThat (validate .isSuccess ()).isFalse ();
137138 }
138139
139140 @ Test
@@ -142,15 +143,15 @@ public void strictWrapperDouble() throws Exception {
142143 WrapperDouble .newBuilder ().setVal (DoubleValue .newBuilder ().build ()).build ();
143144 ValidationResult validate = validator .validate (invalid );
144145 assertThat (validate .getViolations ()).hasSize (1 );
145- assertThat (validate .isSuccess ()).isTrue ();
146+ assertThat (validate .isSuccess ()).isFalse ();
146147 }
147148
148149 @ Test
149150 public void strictFieldExpressions () throws Exception {
150151 FieldExpressions invalid = FieldExpressions .newBuilder ().build ();
151152 ValidationResult validate = validator .validate (invalid );
152153 assertThat (validate .getViolations ()).hasSize (2 );
153- assertThat (validate .isSuccess ()).isTrue ();
154+ assertThat (validate .isSuccess ()).isFalse ();
154155 }
155156
156157 @ Test
@@ -161,22 +162,22 @@ public void strictDurationGTELTE() throws Exception {
161162 .build ();
162163 ValidationResult validate = validator .validate (invalid );
163164 assertThat (validate .getViolations ()).hasSize (1 );
164- assertThat (validate .isSuccess ()).isTrue ();
165+ assertThat (validate .isSuccess ()).isFalse ();
165166 }
166167
167168 @ Test
168169 public void strictRepeatedExact () throws Exception {
169170 RepeatedExact invalid = RepeatedExact .newBuilder ().addAllVal (Arrays .asList (1 , 2 )).build ();
170171 ValidationResult validate = validator .validate (invalid );
171- assertThat (validate .isSuccess ()).isTrue ();
172+ assertThat (validate .isSuccess ()).isFalse ();
172173 assertThat (validate .getViolations ()).hasSize (1 );
173174 }
174175
175176 @ Test
176177 public void strictSFixed64In () throws Exception {
177178 SFixed64In invalid = SFixed64In .newBuilder ().setVal (5 ).build ();
178179 ValidationResult validate = validator .validate (invalid );
179- assertThat (validate .isSuccess ()).isTrue ();
180+ assertThat (validate .isSuccess ()).isFalse ();
180181 assertThat (validate .getViolations ()).hasSize (1 );
181182 }
182183
@@ -188,31 +189,31 @@ public void strictFieldExpressionsNested() throws Exception {
188189 .setC (FieldExpressions .Nested .newBuilder ().setA (-3 ).build ())
189190 .build ();
190191 ValidationResult validate = validator .validate (invalid );
191- assertThat (validate .isSuccess ()).isTrue ();
192+ assertThat (validate .isSuccess ()).isFalse ();
192193 assertThat (validate .getViolations ()).hasSize (4 );
193194 }
194195
195196 @ Test
196197 public void strictRepeatedExactIgnore () throws Exception {
197198 RepeatedExactIgnore invalid = RepeatedExactIgnore .newBuilder ().build ();
198199 ValidationResult validate = validator .validate (invalid );
199- assertThat (validate .getViolations (). isEmpty ()). isTrue ();
200- assertThat (validate .getViolations ()).hasSize ( 0 );
200+ assertThat (validate .getViolations ()). isEmpty ();
201+ assertThat (validate .isSuccess ()).isTrue ( );
201202 }
202203
203204 @ Test
204205 public void strictInt32In () throws Exception {
205206 Int32In invalid = Int32In .newBuilder ().setVal (4 ).build ();
206207 ValidationResult validate = validator .validate (invalid );
207- assertThat (validate .isSuccess ()).isTrue ();
208+ assertThat (validate .isSuccess ()).isFalse ();
208209 assertThat (validate .getViolations ()).hasSize (1 );
209210 }
210211
211212 @ Test
212213 public void strictRepeatedEnumIn () throws Exception {
213214 RepeatedEnumIn invalid = RepeatedEnumIn .newBuilder ().addVal (AnEnum .AN_ENUM_X ).build ();
214215 ValidationResult validate = validator .validate (invalid );
215- assertThat (validate .isSuccess ()).isTrue ();
216+ assertThat (validate .isSuccess ()).isFalse ();
216217 assertThat (validate .getViolations ()).hasSize (1 );
217218 }
218219
@@ -224,7 +225,7 @@ public void strictRepeatedMin() throws Exception {
224225 .addVal (Embed .newBuilder ().setVal (-1 ).build ())
225226 .build ();
226227 ValidationResult validate = validator .validate (invalid );
227- assertThat (validate .isSuccess ()).isTrue ();
228+ assertThat (validate .isSuccess ()).isFalse ();
228229 assertThat (validate .getViolations ()).hasSize (1 );
229230 }
230231
@@ -234,20 +235,19 @@ public void testDynRuntimeError() throws Exception {
234235 validator .validate (invalid );
235236 }
236237
237- // Needs : https://github.com/projectnessie/cel-java/pull/419
238- // @Test
239- // public void strictBytesIn() throws ValidationException {
240- // BytesIn invalid = BytesIn.newBuilder().setVal(ByteString.copyFromUtf8("bar")).build();
241- // ValidationResult validate = validator.validate(invalid);
242- // assertThat(validate.isSuccess()).isTrue();
243- // }
238+ @ Test
239+ public void strictBytesIn () throws ValidationException {
240+ BytesIn invalid = BytesIn .newBuilder ().setVal (ByteString .copyFromUtf8 ("bar" )).build ();
241+ ValidationResult validate = validator .validate (invalid );
242+ assertThat (validate .isSuccess ()).isTrue ();
243+ }
244244
245245 @ Test
246246 public void strictRepeatedUnique () throws ValidationException {
247247 RepeatedUnique invalid =
248248 RepeatedUnique .newBuilder ().addAllVal (Arrays .asList ("foo" , "bar" , "foo" , "baz" )).build ();
249249 ValidationResult validate = validator .validate (invalid );
250- assertThat (validate .isSuccess ()).isTrue ();
250+ assertThat (validate .isSuccess ()).isFalse ();
251251 }
252252
253253 @ Test
@@ -264,14 +264,14 @@ public void testRecursiveInvalid() throws ValidationException {
264264 MapRecursive .newBuilder ().putVal (1 , MapRecursive .Msg .newBuilder ().build ()).build ();
265265 ValidationResult validate = validator .validate (test );
266266 assertThat (validate .getViolations ()).hasSize (1 );
267- assertThat (validate .isSuccess ()).isTrue ();
267+ assertThat (validate .isSuccess ()).isFalse ();
268268 }
269269
270270 @ Test
271271 public void testStringLenEmoji () throws ValidationException {
272272 StringLen test = StringLen .newBuilder ().setVal ("😅😄👾" ).build ();
273273 ValidationResult validate = validator .validate (test );
274- assertThat (validate .getViolations ()).hasSize ( 0 );
275- assertThat (validate .getViolations (). isEmpty ()).isTrue ();
274+ assertThat (validate .getViolations ()).isEmpty ( );
275+ assertThat (validate .isSuccess ()).isTrue ();
276276 }
277277}
0 commit comments