singhbaljit commented on a change in pull request #121:
URL: https://github.com/apache/commons-geometry/pull/121#discussion_r544480779
##########
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:
It is safe to replace `Runnable` with
`org.junit.jupiter.api.function.Executable`. Lambda signature is equivalent, so
this is a non-breaking change. You can just pass the along the `r` instead of
creating another lambda instance as `r::run`.
----------------------------------------------------------------
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]