43
43
44
44
/**
45
45
* @author Christoph Strobl
46
+ * @author Tom Van Wemmel
46
47
*/
47
48
@ ExtendWith (MockitoExtension .class )
48
49
public abstract class AbstractQueryCreatorTestBase <QUERY_CREATOR extends AbstractQueryCreator <KeyValueQuery <CRITERIA >, ?>, CRITERIA > {
@@ -70,6 +71,17 @@ void equalsReturnsFalseWhenNotMatching() {
70
71
assertThat (evaluate ("findByFirstname" , BRAN .firstname ).against (RICKON )).isFalse ();
71
72
}
72
73
74
+ @ Test
75
+ // GH-603
76
+ void notEqualsReturnsTrueWhenMatching () {
77
+ assertThat (evaluate ("findByFirstnameNot" , BRAN .firstname ).against (RICKON )).isTrue ();
78
+ }
79
+
80
+ @ Test // GH-603
81
+ void notEqualsReturnsFalseWhenNotMatching () {
82
+ assertThat (evaluate ("findByFirstnameNot" , BRAN .firstname ).against (BRAN )).isFalse ();
83
+ }
84
+
73
85
@ Test // DATACMNS-525
74
86
void isTrueAssertedProperlyWhenTrue () {
75
87
assertThat (evaluate ("findBySkinChangerIsTrue" ).against (BRAN )).isTrue ();
@@ -130,6 +142,16 @@ void likeReturnsFalseWhenNotMatching() {
130
142
assertThat (evaluate ("findByFirstnameLike" , "ra" ).against (ROBB )).isFalse ();
131
143
}
132
144
145
+ @ Test // GH-603
146
+ void notLikeReturnsTrueWhenMatching () {
147
+ assertThat (evaluate ("findByFirstnameNotLike" , "ra" ).against (ROBB )).isTrue ();
148
+ }
149
+
150
+ @ Test // GH-603
151
+ void notLikeReturnsFalseWhenNotMatching () {
152
+ assertThat (evaluate ("findByFirstnameNotLike" , "ob" ).against (ROBB )).isFalse ();
153
+ }
154
+
133
155
@ Test // DATACMNS-525
134
156
void endsWithReturnsTrueWhenMatching () {
135
157
assertThat (evaluate ("findByFirstnameEndingWith" , "bb" ).against (ROBB )).isTrue ();
@@ -310,6 +332,53 @@ void inMatchesNullValuesCorrectly() {
310
332
.isTrue ();
311
333
}
312
334
335
+ @ Test // GH-603
336
+ void notInReturnsMatchCorrectly () {
337
+
338
+ ArrayList <String > list = new ArrayList <>();
339
+ list .add (ROBB .firstname );
340
+
341
+ assertThat (evaluate ("findByFirstnameNotIn" , list ).against (JON )).isTrue ();
342
+ }
343
+
344
+ @ Test // GH-603
345
+ void notInNotMatchingReturnsCorrectly () {
346
+
347
+ ArrayList <String > list = new ArrayList <>();
348
+ list .add (ROBB .firstname );
349
+
350
+ assertThat (evaluate ("findByFirstnameNotIn" , list ).against (ROBB )).isFalse ();
351
+ }
352
+
353
+ @ Test // GH-603
354
+ void notInWithNullCompareValuesCorrectly () {
355
+
356
+ ArrayList <String > list = new ArrayList <>();
357
+ list .add (null );
358
+
359
+ assertThat (evaluate ("findByFirstnameNotIn" , list ).against (JON )).isTrue ();
360
+ }
361
+
362
+ @ Test // GH-603
363
+ void notInWithNullSourceValuesMatchesCorrectly () {
364
+
365
+ ArrayList <String > list = new ArrayList <>();
366
+ list .add (ROBB .firstname );
367
+
368
+ assertThat (evaluate ("findByFirstnameNotIn" , list ).against (new PredicateQueryCreatorUnitTests .Person (null , 10 )))
369
+ .isTrue ();
370
+ }
371
+
372
+ @ Test // GH-603
373
+ void notInMatchesNullValuesCorrectly () {
374
+
375
+ ArrayList <String > list = new ArrayList <>();
376
+ list .add (null );
377
+
378
+ assertThat (evaluate ("findByFirstnameNotIn" , list ).against (new PredicateQueryCreatorUnitTests .Person (null , 10 )))
379
+ .isFalse ();
380
+ }
381
+
313
382
@ Test // DATAKV-185
314
383
void noDerivedQueryArgumentsMatchesAlways () {
315
384
@@ -363,6 +432,9 @@ interface PersonRepository extends CrudRepository<Person, String> {
363
432
// Type.SIMPLE_PROPERTY
364
433
Person findByFirstname (String firstname );
365
434
435
+ // Type.NEGATING_SIMPLE_PROPERTY
436
+ Person findByFirstnameNot (String firstname );
437
+
366
438
// Type.TRUE
367
439
Person findBySkinChangerIsTrue ();
368
440
@@ -404,6 +476,9 @@ interface PersonRepository extends CrudRepository<Person, String> {
404
476
// Type.LIKE
405
477
Person findByFirstnameLike (String firstname );
406
478
479
+ // Type.NOT_LIKE
480
+ Person findByFirstnameNotLike (String firstname );
481
+
407
482
// Type.ENDING_WITH
408
483
Person findByFirstnameEndingWith (String firstname );
409
484
@@ -417,6 +492,9 @@ interface PersonRepository extends CrudRepository<Person, String> {
417
492
// Type.IN
418
493
Person findByFirstnameIn (ArrayList <String > in );
419
494
495
+ // Type.NOT_IN
496
+ Person findByFirstnameNotIn (ArrayList <String > in );
497
+
420
498
}
421
499
422
500
public interface Evaluation {
0 commit comments