3030import java .sql .Connection ;
3131import java .sql .DriverManager ;
3232import java .util .List ;
33- import java .util .Objects ;
3433
3534import org .apache .ibatis .datasource .unpooled .UnpooledDataSource ;
3635import org .apache .ibatis .jdbc .ScriptRunner ;
@@ -94,26 +93,6 @@ void testAllIgnored() {
9493 }
9594 }
9695
97- @ Test
98- void testSelectByNull () {
99- // this method demonstrates that ignoring the null value warning will still work
100- try (SqlSession sqlSession = sqlSessionFactory .openSession ()) {
101- AnimalDataMapper mapper = sqlSession .getMapper (AnimalDataMapper .class );
102- SelectStatementProvider selectStatement = select (id , animalName , bodyWeight , brainWeight )
103- .from (animalData )
104- .where (id , isGreaterThan (NULL_INTEGER )) // should be an IDE warning about passing null to a nonnull method
105- .orderBy (id )
106- .build ()
107- .render (RenderingStrategies .MYBATIS3 );
108- List <AnimalData > animals = mapper .selectMany (selectStatement );
109- assertAll (
110- () -> assertThat (selectStatement .getSelectStatement ()).isEqualTo ("select id, animal_name, body_weight, brain_weight from AnimalData where id > #{parameters.p1,jdbcType=INTEGER} order by id" ),
111- () -> assertThat (selectStatement .getParameters ()).containsEntry ("p1" , null ),
112- () -> assertThat (animals ).isEmpty ()
113- );
114- }
115- }
116-
11796 @ Test
11897 void testIgnoredBetweenRendered () {
11998 try (SqlSession sqlSession = sqlSessionFactory .openSession ()) {
@@ -122,7 +101,7 @@ void testIgnoredBetweenRendered() {
122101 .from (animalData )
123102 .where (id , isEqualTo (3 ))
124103 .and (id , isNotEqualToWhenPresent (NULL_INTEGER ))
125- .or (id , isEqualTo (4 ). filter ( Objects :: nonNull ) )
104+ .or (id , isEqualTo (4 ))
126105 .orderBy (id )
127106 .build ()
128107 .render (RenderingStrategies .MYBATIS3 );
@@ -143,8 +122,8 @@ void testIgnoredInWhere() {
143122 SelectStatementProvider selectStatement = select (id , animalName , bodyWeight , brainWeight )
144123 .from (animalData )
145124 .where (id , isLessThanWhenPresent (NULL_INTEGER ))
146- .and (id , isEqualTo (3 ). filter ( Objects :: nonNull ) )
147- .or (id , isEqualTo (4 ). filter ( Objects :: nonNull ) )
125+ .and (id , isEqualTo (3 ))
126+ .or (id , isEqualTo (4 ))
148127 .orderBy (id )
149128 .build ()
150129 .render (RenderingStrategies .MYBATIS3 );
@@ -187,8 +166,8 @@ void testIgnoredInitialWhere() {
187166 AnimalDataMapper mapper = sqlSession .getMapper (AnimalDataMapper .class );
188167 SelectStatementProvider selectStatement = select (id , animalName , bodyWeight , brainWeight )
189168 .from (animalData )
190- .where (id , isLessThanWhenPresent (NULL_INTEGER ), and (id , isEqualTo (3 ). filter ( Objects :: nonNull ) ))
191- .or (id , isEqualTo (4 ). filter ( Objects :: nonNull ) )
169+ .where (id , isLessThanWhenPresent (NULL_INTEGER ), and (id , isEqualTo (3 )))
170+ .or (id , isEqualTo (4 ))
192171 .orderBy (id )
193172 .build ()
194173 .render (RenderingStrategies .MYBATIS3 );
@@ -802,7 +781,7 @@ void testIsLikeWhenWithValue() {
802781 AnimalDataMapper mapper = sqlSession .getMapper (AnimalDataMapper .class );
803782 SelectStatementProvider selectStatement = select (id , animalName , bodyWeight , brainWeight )
804783 .from (animalData )
805- .where (animalName , isLike ("%mole" ). filter ( Objects :: nonNull ) )
784+ .where (animalName , isLike ("%mole" ))
806785 .and (id , isLessThanOrEqualTo (10 ))
807786 .orderBy (id )
808787 .build ()
@@ -882,7 +861,7 @@ void testIsNotLikeWhenWithValue() {
882861 AnimalDataMapper mapper = sqlSession .getMapper (AnimalDataMapper .class );
883862 SelectStatementProvider selectStatement = select (id , animalName , bodyWeight , brainWeight )
884863 .from (animalData )
885- .where (animalName , isNotLike ("%mole" ). filter ( Objects :: nonNull ) )
864+ .where (animalName , isNotLike ("%mole" ))
886865 .and (id , isLessThanOrEqualTo (10 ))
887866 .orderBy (id )
888867 .build ()
0 commit comments