arturobernalg commented on a change in pull request #121:
URL: https://github.com/apache/commons-geometry/pull/121#discussion_r544599428



##########
File path: 
commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java
##########
@@ -50,35 +50,17 @@ public static void assertNegativeInfinity(final double 
value) {
         Assertions.assertTrue(value < 0, msg);
     }
 
-    /** Asserts that the given Runnable throws an exception of the given type.
-     * @param r the Runnable instance
-     * @param exceptionType the expected exception type
-     */
-    public static void assertThrows(final Runnable r, final Class<?> 
exceptionType) {
-        assertThrows(r, exceptionType, (String) null);
-    }
-
     /** Asserts that the given Runnable throws an exception of the given type. 
If
      * {@code message} is not null, the exception message is asserted to equal 
the
      * given value.
      * @param r the Runnable instance
      * @param exceptionType the expected exception type
      * @param message the expected exception message; ignored if null
      */
-    public static void assertThrows(final Runnable r, final Class<?> 
exceptionType, final String message) {
-        try {
-            r.run();
-            Assertions.fail("Operation should have thrown an exception");
-        } catch (final Exception exc) {
-            final Class<?> actualType = exc.getClass();
-
-            Assertions.assertTrue(exceptionType.isAssignableFrom(actualType),
-                    "Expected exception of type " + exceptionType.getName() + 
" but was " + actualType.getName());
-
-            if (message != null) {
-                Assertions.assertEquals(message, exc.getMessage());
-            }
-        }
+    public static <T extends Throwable> void assertThrowsWithMessage(final 
Runnable r, final Class<T> exceptionType, final String message) {
+        final Throwable exc = Assertions.assertThrows(exceptionType, r::run);
+        Assertions.assertNotNull(message);

Review comment:
       changed

##########
File path: 
commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java
##########
@@ -50,35 +50,17 @@ public static void assertNegativeInfinity(final double 
value) {
         Assertions.assertTrue(value < 0, msg);
     }
 
-    /** Asserts that the given Runnable throws an exception of the given type.
-     * @param r the Runnable instance
-     * @param exceptionType the expected exception type
-     */
-    public static void assertThrows(final Runnable r, final Class<?> 
exceptionType) {
-        assertThrows(r, exceptionType, (String) null);
-    }
-
     /** Asserts that the given Runnable throws an exception of the given type. 
If
      * {@code message} is not null, the exception message is asserted to equal 
the
      * given value.
      * @param r the Runnable instance
      * @param exceptionType the expected exception type
      * @param message the expected exception message; ignored if null
      */
-    public static void assertThrows(final Runnable r, final Class<?> 
exceptionType, final String message) {
-        try {
-            r.run();
-            Assertions.fail("Operation should have thrown an exception");
-        } catch (final Exception exc) {
-            final Class<?> actualType = exc.getClass();
-
-            Assertions.assertTrue(exceptionType.isAssignableFrom(actualType),
-                    "Expected exception of type " + exceptionType.getName() + 
" but was " + actualType.getName());
-
-            if (message != null) {
-                Assertions.assertEquals(message, exc.getMessage());
-            }
-        }
+    public static <T extends Throwable> void assertThrowsWithMessage(final 
Runnable r, final Class<T> exceptionType, final String message) {

Review comment:
       changed




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to