16
16
package org .mybatis .dynamic .sql .select ;
17
17
18
18
import static org .assertj .core .api .Assertions .assertThat ;
19
+ import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
19
20
import static org .junit .jupiter .api .Assertions .assertAll ;
20
21
import static org .mybatis .dynamic .sql .SqlBuilder .*;
21
22
22
23
import java .sql .JDBCType ;
24
+ import java .util .Collections ;
23
25
import java .util .Date ;
24
26
import java .util .Map ;
25
27
26
28
import org .junit .jupiter .api .Test ;
29
+ import org .mybatis .dynamic .sql .Callback ;
27
30
import org .mybatis .dynamic .sql .SqlColumn ;
28
31
import org .mybatis .dynamic .sql .SqlTable ;
29
32
import org .mybatis .dynamic .sql .render .RenderingStrategies ;
@@ -34,6 +37,7 @@ class SelectStatementTest {
34
37
static final SqlTable table = SqlTable .of ("foo" );
35
38
static final SqlColumn <Date > column1 = table .column ("column1" , JDBCType .DATE );
36
39
static final SqlColumn <Integer > column2 = table .column ("column2" , JDBCType .INTEGER );
40
+ static final SqlColumn <String > column3 = table .column ("column3" , JDBCType .VARCHAR );
37
41
38
42
@ Test
39
43
void testSimpleCriteria () {
@@ -257,4 +261,56 @@ void testGroupBySingleColumn() {
257
261
() -> assertThat (parameters ).containsEntry ("p1" , d )
258
262
);
259
263
}
264
+
265
+ @ Test
266
+ void testInCaseInsensitiveEmptyList () {
267
+ SelectModel selectModel = select (column1 , column3 )
268
+ .from (table , "a" )
269
+ .where (column3 , isInCaseInsensitive (Collections .emptyList ())
270
+ .withListEmptyCallback (Callback .runtimeExceptionThrowingCallback ("Fred" )))
271
+ .build ();
272
+
273
+ assertThatExceptionOfType (RuntimeException .class ).describedAs ("Fred" ).isThrownBy (() ->
274
+ selectModel .render (RenderingStrategies .MYBATIS3 )
275
+ );
276
+ }
277
+
278
+ @ Test
279
+ void testInCaseInsensitiveWhenPresentEmptyList () {
280
+ SelectModel selectModel = select (column1 , column3 )
281
+ .from (table , "a" )
282
+ .where (column3 , isInCaseInsensitiveWhenPresent (Collections .emptyList ())
283
+ .withListEmptyCallback (Callback .runtimeExceptionThrowingCallback ("Fred" )))
284
+ .build ();
285
+
286
+ assertThatExceptionOfType (RuntimeException .class ).describedAs ("Fred" ).isThrownBy (() ->
287
+ selectModel .render (RenderingStrategies .MYBATIS3 )
288
+ );
289
+ }
290
+
291
+ @ Test
292
+ void testNotInCaseInsensitiveEmptyList () {
293
+ SelectModel selectModel = select (column1 , column3 )
294
+ .from (table , "a" )
295
+ .where (column3 , isNotInCaseInsensitive (Collections .emptyList ())
296
+ .withListEmptyCallback (Callback .runtimeExceptionThrowingCallback ("Fred" )))
297
+ .build ();
298
+
299
+ assertThatExceptionOfType (RuntimeException .class ).describedAs ("Fred" ).isThrownBy (() ->
300
+ selectModel .render (RenderingStrategies .MYBATIS3 )
301
+ );
302
+ }
303
+
304
+ @ Test
305
+ void testNotInCaseInsensitiveWhenPresentEmptyList () {
306
+ SelectModel selectModel = select (column1 , column3 )
307
+ .from (table , "a" )
308
+ .where (column3 , isNotInCaseInsensitiveWhenPresent (Collections .emptyList ())
309
+ .withListEmptyCallback (Callback .runtimeExceptionThrowingCallback ("Fred" )))
310
+ .build ();
311
+
312
+ assertThatExceptionOfType (RuntimeException .class ).describedAs ("Fred" ).isThrownBy (() ->
313
+ selectModel .render (RenderingStrategies .MYBATIS3 )
314
+ );
315
+ }
260
316
}
0 commit comments