|
24 | 24 |
|
25 | 25 | import org.junit.jupiter.api.Test;
|
26 | 26 | import org.mybatis.dynamic.sql.SqlBuilder;
|
| 27 | +import org.mybatis.dynamic.sql.util.StringUtilities; |
27 | 28 |
|
28 | 29 | class FilterAndMapTest {
|
29 | 30 | @Test
|
@@ -533,4 +534,40 @@ void testNotBetweenMapWithSingleMapper() {
|
533 | 534 | assertThat(cond.value2()).isEqualTo(4);
|
534 | 535 | }
|
535 | 536 |
|
| 537 | + @Test |
| 538 | + void testMappingAnEmptyListCondition() { |
| 539 | + var cond = SqlBuilder.isNotIn("Fred", "Wilma"); |
| 540 | + var filtered = cond.filter(s -> false); |
| 541 | + var mapped = filtered.map(s -> s); |
| 542 | + assertThat(mapped.isEmpty()).isTrue(); |
| 543 | + assertThat(filtered).isSameAs(mapped); |
| 544 | + } |
| 545 | + |
| 546 | + @Test |
| 547 | + void testIsInCaseInsensitiveWhenPresentMap() { |
| 548 | + var cond = SqlBuilder.isInCaseInsensitiveWhenPresent("Fred", "Wilma"); |
| 549 | + var mapped = cond.map(s -> s + " Flintstone"); |
| 550 | + assertThat(mapped.values().toList()).containsExactly("FRED Flintstone", "WILMA Flintstone"); |
| 551 | + } |
| 552 | + |
| 553 | + @Test |
| 554 | + void testIsInCaseInsensitiveWhenPresentMapCaseInsensitive() { |
| 555 | + var cond = SqlBuilder.isInCaseInsensitiveWhenPresent("Fred", "Wilma"); |
| 556 | + var mapped = cond.map(StringUtilities.mapToUpperCase(s -> s + " Flintstone")); |
| 557 | + assertThat(mapped.values().toList()).containsExactly("FRED FLINTSTONE", "WILMA FLINTSTONE"); |
| 558 | + } |
| 559 | + |
| 560 | + @Test |
| 561 | + void testIsNotInCaseInsensitiveWhenPresentMap() { |
| 562 | + var cond = SqlBuilder.isNotInCaseInsensitiveWhenPresent("Fred", "Wilma"); |
| 563 | + var mapped = cond.map(s -> s + " Flintstone"); |
| 564 | + assertThat(mapped.values().toList()).containsExactly("FRED Flintstone", "WILMA Flintstone"); |
| 565 | + } |
| 566 | + |
| 567 | + @Test |
| 568 | + void testIsNotInCaseInsensitiveWhenPresentMapCaseInsensitive() { |
| 569 | + var cond = SqlBuilder.isNotInCaseInsensitiveWhenPresent("Fred", "Wilma"); |
| 570 | + var mapped = cond.map(StringUtilities.mapToUpperCase(s -> s + " Flintstone")); |
| 571 | + assertThat(mapped.values().toList()).containsExactly("FRED FLINTSTONE", "WILMA FLINTSTONE"); |
| 572 | + } |
536 | 573 | }
|
0 commit comments