77import java .sql .SQLException ;
88
99import static org .junit .jupiter .api .Assertions .assertEquals ;
10- import static org .mockito .Mockito .mock ;
11- import static org .mockito .Mockito .verify ;
10+ import static org .mockito .Mockito .*;
1211
1312public class DynamicParameterListTest {
1413
1514 @ Test
16- void callWithThreeDifferentTypes () throws SQLException {
15+ void call_with_three_different_types () throws SQLException {
1716
1817 CallableStatement mockedStatement = mock (CallableStatement .class );
1918 OracleConnection mockedConn = mock (OracleConnection .class );
@@ -29,9 +28,31 @@ void callWithThreeDifferentTypes() throws SQLException {
2928 assertEquals ("a_object_owner = ?, a_num_param = ?, a_num_array = ?" , parameterList .getSql ());
3029
3130 parameterList .setParamsStartWithIndex (mockedStatement , 5 );
31+
3232 verify (mockedStatement ).setString (5 , "MyOwner" );
3333 verify (mockedStatement ).setInt (6 , 123 );
3434 verify (mockedConn ).createOracleArray ("MY_NUM_ARR" , numArr );
3535 verify (mockedStatement ).setArray (7 , null );
3636 }
37+
38+ @ Test
39+ void when_not_accept_empty_filter_empty_elements () throws SQLException {
40+
41+ CallableStatement mockedStatement = mock (CallableStatement .class );
42+ OracleConnection mockedConn = mock (OracleConnection .class );
43+
44+ DynamicParameterList parameterList = DynamicParameterListBuilder .create ()
45+ .onlyAddIfNotEmpty ()
46+ .add ("a_object_owner" , (String )null )
47+ .add ("a_num_param" , (Integer )null )
48+ .add ("a_num_array" , new Object []{}, "MY_NUM_ARR" , mockedConn )
49+ .build ();
50+
51+ assertEquals ("" , parameterList .getSql ());
52+
53+ parameterList .setParamsStartWithIndex (mockedStatement , 2 );
54+
55+ verifyNoMoreInteractions (mockedStatement );
56+ verifyNoMoreInteractions (mockedConn );
57+ }
3758}
0 commit comments