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



##########
File path: 
commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java
##########
@@ -50,61 +51,28 @@ 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
+    /** Asserts that the given Executable 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 executable the Executable instance
      * @param exceptionType the expected exception type
      * @param message the expected exception message; ignored if null

Review comment:
       true. mi mistake changed

##########
File path: 
commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java
##########
@@ -50,61 +51,28 @@ 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
+    /** Asserts that the given Executable 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 executable the Executable 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 
Executable executable, final Class<T> exceptionType, final String message) {
+        Assertions.assertEquals(message, 
Assertions.assertThrows(exceptionType, executable).getMessage());
     }
 
-    /** Asserts that the given Runnable throws an exception of the given type. 
If
+    /** Asserts that the given Executable throws an exception of the given 
type. If
      * {@code pattern} is not null, the exception message is asserted to match 
the
      * given regex.
-     * @param r the Runnable instance
+     * @param executable the Executable instance
      * @param exceptionType the expected exception type
      * @param pattern regex pattern to match; ignored if null

Review comment:
       idem




----------------------------------------------------------------
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:
[email protected]


Reply via email to