Use assertThrows
diff --git a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
index a86ae4c..dc9ef9b 100644
--- a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
+++ b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
@@ -304,12 +304,8 @@
Assertions.assertEquals(BigInteger.valueOf(1801088541L), ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(7L)));
Assertions.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, BigInteger.ZERO));
- try {
- ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(-7L));
- Assertions.fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // expected behavior
- }
+ Assertions.assertThrows(IllegalArgumentException.class, () ->
+ ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(-7L)));
BigInteger bigOne =
new BigInteger("1543786922199448028351389769265814882661837148" +
diff --git a/commons-numbers-rootfinder/src/test/java/org/apache/commons/numbers/rootfinder/BrentSolverTest.java b/commons-numbers-rootfinder/src/test/java/org/apache/commons/numbers/rootfinder/BrentSolverTest.java
index 516aaef..40cf641 100644
--- a/commons-numbers-rootfinder/src/test/java/org/apache/commons/numbers/rootfinder/BrentSolverTest.java
+++ b/commons-numbers-rootfinder/src/test/java/org/apache/commons/numbers/rootfinder/BrentSolverTest.java
@@ -153,7 +153,7 @@
Assertions.assertTrue(f.getCallsCount() <= 15);
final MonitoredFunction f2 = new MonitoredFunction(func, 10);
- final IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException.class,
+ final IllegalStateException ex = Assertions.assertThrows(IllegalStateException.class,
() -> solver.findRoot(f2, 0.85, 5), "Expected too many calls condition");
// Ensure expected error condition.
Assertions.assertNotEquals(-1, ex.getMessage().indexOf("too many calls"));