rdblue commented on a change in pull request #2948:
URL: https://github.com/apache/iceberg/pull/2948#discussion_r685438317



##########
File path: api/src/test/java/org/apache/iceberg/AssertHelpers.java
##########
@@ -113,6 +113,37 @@ public static void assertThrowsCause(String message,
         .hasMessageContaining(containedInMessage);
   }
 
+  /**
+   * A convenience method to assert both the thrown exception and the cause of 
thrown exception.
+   * @param message A String message to describe this assertion
+   * @param expected  An Exception class that the Runnable should throw
+   * @param expectedContainedInMessage A String that should be contained by 
the thrown exception's message,
+   *                                   will be skipped if null.
+   * @param cause An Exception class that the cause of the Runnable should 
throw
+   * @param causeContainedInMessage A String that should be contained by the 
cause of the thrown exception's message,
+   *                                will be skipped if null.
+   * @param runnable A Runnable that is expected to throw the runtime exception
+   */
+  public static void assertThrowsWithCause(String message,
+                                           Class<? extends Exception> expected,
+                                           String expectedContainedInMessage,
+                                           Class<? extends Exception> cause,
+                                           String causeContainedInMessage,
+                                           Runnable runnable) {
+    AbstractThrowableAssert<?, ?> chain = 
Assertions.assertThatThrownBy(runnable::run)
+        .as(message)
+        .isInstanceOf(expected);
+
+    if (expectedContainedInMessage != null) {

Review comment:
       Why the null checks? I don't think we want anyone pass null in to turn 
off the validation right?




-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to