2828import java .sql .ResultSetMetaData ;
2929import java .sql .SQLException ;
3030import java .sql .Statement ;
31- import java .util .Properties ;
3231import org .junit .jupiter .api .AfterEach ;
3332import org .junit .jupiter .api .BeforeEach ;
3433import org .junit .jupiter .api .Test ;
@@ -110,7 +109,7 @@ void testMysqlIsDialectIncorrectVersionComment() throws SQLException {
110109 @ Test
111110 void testRdsMysqlIsDialectSuccess () throws SQLException {
112111 when (mockStatement .executeQuery (any ())).thenReturn (successResultSet );
113- when (successResultSet .next ()).thenReturn (true , true , true , true );
112+ when (successResultSet .next ()).thenReturn (true , false , true , true );
114113 when (successResultSet .getString (2 )).thenReturn (
115114 "Source distribution" , "Source distribution" , "" );
116115 when (successResultSet .getMetaData ()).thenReturn (mockResultSetMetaData );
@@ -143,11 +142,11 @@ void testRdsMysqlIsDialectSuperIsDialectReturnedTrue() throws SQLException {
143142 @ Test
144143 void testRdsMysqlIsDialectInvalidVersionComment () throws SQLException {
145144 when (mockStatement .executeQuery (any ())).thenReturn (successResultSet );
146- when (successResultSet .next ()).thenReturn (true , true , true , false );
145+ when (successResultSet .next ()).thenReturn (true , false , true , false );
147146 when (successResultSet .getString (2 )).thenReturn ("Invalid" );
148147 when (successResultSet .getMetaData ()).thenReturn (mockResultSetMetaData );
149148 assertFalse (rdsMysqlDialect .isDialect (mockConnection ));
150- verify (successResultSet , times (2 )).next ();
149+ verify (successResultSet , times (3 )).next ();
151150 }
152151
153152 // RDS MULTI A-Z DB CLUSTER MYSQL DIALECT
@@ -170,7 +169,7 @@ void testRdsTazMysqlIsDialectExceptionThrown() throws SQLException {
170169 void testRdsTazMysqlIsDialectQueryReturnedEmptyResultSet () throws SQLException {
171170 when (mockStatement .executeQuery (any ())).thenReturn (failResultSet );
172171 assertFalse (rdsTazMysqlDialect .isDialect (mockConnection ));
173- verify (failResultSet , times (2 )).next ();
172+ verify (failResultSet , times (1 )).next ();
174173 }
175174
176175 // AURORA MYSQL DIALECT
@@ -191,15 +190,14 @@ void testAuroraMysqlIsDialectExceptionThrown() throws SQLException {
191190 void testAuroraMysqlIsDialectQueryReturnedEmptyResultSet () throws SQLException {
192191 when (mockStatement .executeQuery (any ())).thenReturn (failResultSet );
193192 assertFalse (auroraMysqlDialect .isDialect (mockConnection ));
194- verify (failResultSet , times (2 )).next ();
193+ verify (failResultSet , times (1 )).next ();
195194 }
196195
197196 // PG DIALECT
198197 @ Test
199198 void testPgIsDialectSuccess () throws SQLException {
200199 when (mockStatement .executeQuery (any ())).thenReturn (successResultSet );
201200 when (successResultSet .next ()).thenReturn (true );
202- when (successResultSet .getString (2 )).thenReturn ("postgresql" );
203201 assertTrue (pgDialect .isDialect (mockConnection ));
204202 }
205203
@@ -221,7 +219,6 @@ void testPgIsDialectQueryReturnedEmptyResultSet() throws SQLException {
221219 void testRdsPgIsDialectSuccess () throws SQLException {
222220 when (mockStatement .executeQuery (any ())).thenReturn (successResultSet );
223221 when (successResultSet .next ()).thenReturn (true );
224- when (successResultSet .getString (2 )).thenReturn ("postgresql" );
225222 when (successResultSet .getBoolean ("rds_tools" )).thenReturn (true );
226223 when (successResultSet .getBoolean ("aurora_stat_utils" )).thenReturn (false );
227224 assertTrue (rdsPgDialect .isDialect (mockConnection ));
@@ -255,7 +252,6 @@ void testRdsTazPgIsDialectSuccess() throws SQLException {
255252 when (mockStatement .executeQuery (any ())).thenReturn (successResultSet );
256253 when (successResultSet .next ()).thenReturn (true );
257254 when (successResultSet .getString (1 )).thenReturn ("id" );
258- when (successResultSet .getString (2 )).thenReturn ("postgresql" );
259255 assertTrue (rdsTazPgDialect .isDialect (mockConnection ));
260256 }
261257
@@ -285,7 +281,6 @@ void testRdsTazPgIsDialectIsRdsClusterQueryFailed() throws SQLException {
285281 void testAuroraPgIsDialectSuccess () throws SQLException {
286282 when (mockStatement .executeQuery (any ())).thenReturn (successResultSet );
287283 when (successResultSet .next ()).thenReturn (true );
288- when (successResultSet .getString (2 )).thenReturn ("postgresql" );
289284 when (successResultSet .getBoolean ("aurora_stat_utils" )).thenReturn (true );
290285 assertTrue (auroraPgDialect .isDialect (mockConnection ));
291286 }
@@ -316,7 +311,7 @@ void testAuroraPgIsDialectMissingAuroraStatUtils() throws SQLException {
316311 void testMariaDbIsDialectSuccess () throws SQLException {
317312 when (mockStatement .executeQuery (any ())).thenReturn (successResultSet );
318313 when (successResultSet .next ()).thenReturn (true );
319- when (successResultSet .getString (2 )).thenReturn ("mariadb" );
314+ when (successResultSet .getString (1 )).thenReturn ("mariadb" );
320315 assertTrue (mariaDbDialect .isDialect (mockConnection ));
321316 }
322317
@@ -337,7 +332,7 @@ void testMariaDbIsDialectQueryReturnedEmptyResultSet() throws SQLException {
337332 void testMariaDbIsDialectIncorrectVersion () throws SQLException {
338333 when (mockStatement .executeQuery (any ())).thenReturn (successResultSet );
339334 when (successResultSet .next ()).thenReturn (true , false );
340- when (successResultSet .getString (2 )).thenReturn ("Invalid" );
335+ when (successResultSet .getString (1 )).thenReturn ("Invalid" );
341336 assertFalse (mariaDbDialect .isDialect (mockConnection ));
342337 }
343338}
0 commit comments