alpreu commented on code in PR #19807:
URL: https://github.com/apache/flink/pull/19807#discussion_r891171146


##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/JdbcRowOutputFormatTest.java:
##########
@@ -76,27 +75,23 @@ public void testInvalidDriver() {
                             .finish();
             jdbcOutputFormat.open(0, 1);
         } catch (Exception e) {
-            assertTrue(findThrowable(e, IOException.class).isPresent());
-            assertTrue(findThrowableWithMessage(e, expectedMsg).isPresent());
+            assertThat(findThrowable(e, IOException.class)).isPresent();
+            assertThat(findThrowableWithMessage(e, expectedMsg)).isPresent();
         }
     }
 
     @Test
     public void testInvalidURL() {
         String expectedMsg = "No suitable driver found for 
jdbc:der:iamanerror:mory:ebookshop";
-        try {
-            jdbcOutputFormat =
-                    JdbcRowOutputFormat.buildJdbcOutputFormat()
-                            .setDrivername(DERBY_EBOOKSHOP_DB.getDriverClass())
-                            .setDBUrl("jdbc:der:iamanerror:mory:ebookshop")
-                            .setQuery(String.format(INSERT_TEMPLATE, 
INPUT_TABLE))
-                            .finish();
-            jdbcOutputFormat.open(0, 1);
-            fail("expect exception");
-        } catch (Exception e) {
-            assertTrue(findThrowable(e, IOException.class).isPresent());
-            assertTrue(findThrowableWithMessage(e, expectedMsg).isPresent());
-        }
+
+        jdbcOutputFormat =
+                JdbcRowOutputFormat.buildJdbcOutputFormat()
+                        .setDrivername(DERBY_EBOOKSHOP_DB.getDriverClass())
+                        .setDBUrl("jdbc:der:iamanerror:mory:ebookshop")
+                        .setQuery(String.format(INSERT_TEMPLATE, INPUT_TABLE))
+                        .finish();
+        assertThatThrownBy(() -> jdbcOutputFormat.open(0, 1))
+                .satisfies(anyCauseMatches(SQLException.class, expectedMsg));

Review Comment:
   The changed method has a different check for the class+message of the 
throwable, I believe previously it checked for the first throwables class with 
any method down the stacktrace. Now it checks that in the stacktrace any 
throwable has the given class and message



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to