Skip to content

Commit 516870f

Browse files
committed
Coverage
1 parent 707dfdb commit 516870f

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

src/test/java/org/mybatis/dynamic/sql/select/SelectStatementTest.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616
package org.mybatis.dynamic.sql.select;
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
1920
import static org.junit.jupiter.api.Assertions.assertAll;
2021
import static org.mybatis.dynamic.sql.SqlBuilder.*;
2122

2223
import java.sql.JDBCType;
24+
import java.util.Collections;
2325
import java.util.Date;
2426
import java.util.Map;
2527

2628
import org.junit.jupiter.api.Test;
29+
import org.mybatis.dynamic.sql.Callback;
2730
import org.mybatis.dynamic.sql.SqlColumn;
2831
import org.mybatis.dynamic.sql.SqlTable;
2932
import org.mybatis.dynamic.sql.render.RenderingStrategies;
@@ -34,6 +37,7 @@ class SelectStatementTest {
3437
static final SqlTable table = SqlTable.of("foo");
3538
static final SqlColumn<Date> column1 = table.column("column1", JDBCType.DATE);
3639
static final SqlColumn<Integer> column2 = table.column("column2", JDBCType.INTEGER);
40+
static final SqlColumn<String> column3 = table.column("column3", JDBCType.VARCHAR);
3741

3842
@Test
3943
void testSimpleCriteria() {
@@ -257,4 +261,56 @@ void testGroupBySingleColumn() {
257261
() -> assertThat(parameters).containsEntry("p1", d)
258262
);
259263
}
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+
}
260316
}

0 commit comments

Comments
 (0)