You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2020/12/18 12:46:37 UTC
[commons-geometry] 01/03: GEOMETRY-105 - Replace the try-catch
pattern with assertThrows()
This is an automated email from the ASF dual-hosted git repository.
mattjuntunen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
commit 5403a8d96e01d5bf8846d36955db35e618a139f7
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Wed Dec 16 16:30:04 2020 +0100
GEOMETRY-105 - Replace the try-catch pattern with assertThrows()
---
.../commons/geometry/core/GeometryTestUtils.java | 54 ++-----
.../core/internal/IteratorTransformTest.java | 3 +-
.../AbstractConvexHyperplaneBoundedRegionTest.java | 21 +--
.../bsp/AbstractPartitionedRegionBuilderTest.java | 4 +-
.../bsp/AbstractRegionBSPTreeTest.java | 4 +-
.../EpsilonDoublePrecisionContextTest.java | 11 +-
.../geometry/enclosing/EnclosingBallTest.java | 3 +-
.../euclidean/threed/WelzlEncloser3DTest.java | 4 +-
.../euclidean/twod/WelzlEncloser2DTest.java | 4 +-
.../geometry/euclidean/internal/MatricesTest.java | 14 +-
.../geometry/euclidean/internal/VectorsTest.java | 16 +-
.../oned/AffineTransformMatrix1DTest.java | 31 ++--
.../geometry/euclidean/oned/IntervalTest.java | 113 +++++---------
.../geometry/euclidean/oned/OrientedPointTest.java | 6 +-
.../geometry/euclidean/oned/Vector1DTest.java | 87 ++++-------
.../threed/AffineTransformMatrix3DTest.java | 31 ++--
.../geometry/euclidean/threed/Bounds3DTest.java | 21 ++-
.../euclidean/threed/ConvexVolumeTest.java | 4 +-
.../threed/EmbeddedAreaPlaneConvexSubsetTest.java | 6 +-
.../threed/EmbeddedTreePlaneSubsetTest.java | 23 ++-
.../euclidean/threed/EmbeddingPlaneTest.java | 20 +--
.../geometry/euclidean/threed/PlaneTest.java | 108 +++++---------
.../geometry/euclidean/threed/PlanesTest.java | 88 +++++------
.../euclidean/threed/RegionBSPTree3DTest.java | 13 +-
.../euclidean/threed/SimpleTriangle3DTest.java | 5 +-
.../euclidean/threed/SphericalCoordinatesTest.java | 3 +-
.../geometry/euclidean/threed/Vector3DTest.java | 162 ++++++++-------------
.../threed/VertexListConvexPolygon3DTest.java | 7 +-
.../geometry/euclidean/threed/line/Line3DTest.java | 7 +-
.../threed/line/LineConvexSubset3DTest.java | 8 +-
.../geometry/euclidean/threed/line/Ray3DTest.java | 8 +-
.../euclidean/threed/line/ReverseRay3DTest.java | 8 +-
.../euclidean/threed/line/Segment3DTest.java | 20 +--
.../threed/mesh/SimpleTriangleMeshTest.java | 43 +++---
.../threed/rotation/QuaternionRotationTest.java | 97 +++++-------
.../euclidean/threed/shape/ParallelepipedTest.java | 36 ++---
.../euclidean/threed/shape/SphereTest.java | 31 ++--
.../twod/AffineTransformMatrix2DTest.java | 31 ++--
.../geometry/euclidean/twod/Bounds2DTest.java | 20 ++-
.../geometry/euclidean/twod/ConvexAreaTest.java | 45 +++---
.../euclidean/twod/EmbeddedTreeLineSubsetTest.java | 10 +-
.../euclidean/twod/LineConvexSubsetTest.java | 12 +-
.../commons/geometry/euclidean/twod/LineTest.java | 10 +-
.../euclidean/twod/PolarCoordinatesTest.java | 3 +-
.../commons/geometry/euclidean/twod/RayTest.java | 14 +-
.../euclidean/twod/RegionBSPTree2DTest.java | 13 +-
.../geometry/euclidean/twod/ReverseRayTest.java | 14 +-
.../geometry/euclidean/twod/SegmentTest.java | 20 +--
.../geometry/euclidean/twod/Vector2DTest.java | 161 ++++++++------------
.../geometry/euclidean/twod/path/LinePathTest.java | 53 ++-----
.../euclidean/twod/rotation/Rotation2DTest.java | 36 ++---
.../geometry/euclidean/twod/shape/CircleTest.java | 27 ++--
.../euclidean/twod/shape/ParallelogramTest.java | 29 ++--
.../io/threed/ModelIOHandlerRegistryTest.java | 16 +-
.../io/threed/obj/OBJModelIOHandlerTest.java | 12 +-
.../examples/io/threed/obj/OBJReaderTest.java | 4 +-
.../examples/io/threed/obj/OBJWriterTest.java | 4 +-
.../hull/euclidean/twod/ConvexHull2DTest.java | 6 +-
.../hull/euclidean/twod/MonotoneChainTest.java | 4 +-
.../spherical/oned/AngularIntervalTest.java | 139 ++++--------------
.../geometry/spherical/oned/Point1STest.java | 45 ++----
.../geometry/spherical/twod/ConvexArea2STest.java | 11 +-
.../twod/EmbeddedTreeSubGreatCircleTest.java | 5 +-
.../geometry/spherical/twod/GreatArcPathTest.java | 18 +--
.../geometry/spherical/twod/GreatArcTest.java | 10 +-
.../geometry/spherical/twod/GreatCircleTest.java | 26 +---
.../geometry/spherical/twod/Point2STest.java | 3 +-
.../spherical/twod/RegionBSPTree2STest.java | 6 +-
68 files changed, 711 insertions(+), 1220 deletions(-)
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java
index 908cc02..0ae6ec3 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java
@@ -23,6 +23,7 @@ import java.io.ObjectOutputStream;
import java.util.regex.Pattern;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.function.Executable;
/** Class containing various geometry-related test utilities.
*/
@@ -50,61 +51,28 @@ public final class GeometryTestUtils {
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
*/
- public static void assertThrows(final Runnable r, final Class<?> exceptionType, final Pattern pattern) {
- 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 (pattern != null) {
- final String message = exc.getMessage();
-
- final String err = "Expected exception message to match /" + pattern + "/ but was [" + message + "]";
- Assertions.assertTrue(pattern.matcher(message).matches(), err);
- }
- }
+ public static <T extends Throwable> void assertThrowsWithMessage(final Executable executable, final Class<T> exceptionType, final Pattern pattern) {
+ final String message = Assertions.assertThrows(exceptionType, executable).getMessage();
+ Assertions.assertTrue(pattern.matcher(message).matches(),
+ "Expected exception message to match /" + pattern + "/ but was [" + message + "]");
}
/** Assert that a string contains a given substring value.
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/IteratorTransformTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/IteratorTransformTest.java
index 827c117..c52f1fc 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/IteratorTransformTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/IteratorTransformTest.java
@@ -26,7 +26,6 @@ import java.util.NoSuchElementException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertThrows;
public class IteratorTransformTest {
@@ -50,7 +49,7 @@ public class IteratorTransformTest {
// act/assert
Assertions.assertFalse(it.hasNext());
- assertThrows(NoSuchElementException.class, it::next);
+ Assertions.assertThrows(NoSuchElementException.class, it::next);
}
private static <T> List<T> toList(final Iterator<T> it) {
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java
index 750287d..f537c1f 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java
@@ -33,6 +33,7 @@ import org.apache.commons.geometry.core.partitioning.test.TestTransform2D;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class AbstractConvexHyperplaneBoundedRegionTest {
@Test
@@ -41,9 +42,7 @@ public class AbstractConvexHyperplaneBoundedRegionTest {
final StubRegion region = new StubRegion(new ArrayList<>());
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- region.getBoundaries().add(TestLine.X_AXIS.span());
- }, UnsupportedOperationException.class);
+ Assertions.assertThrows(UnsupportedOperationException.class, () -> region.getBoundaries().add(TestLine.X_AXIS.span()));
}
@Test
@@ -631,17 +630,13 @@ public class AbstractConvexHyperplaneBoundedRegionTest {
@Test
public void testConvexRegionBoundaryBuilder() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- StubRegion.fromBounds(Arrays.asList(TestLine.X_AXIS, TestLine.X_AXIS.reverse()));
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> StubRegion.fromBounds(Arrays.asList(TestLine.X_AXIS, TestLine.X_AXIS.reverse())));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> StubRegion.fromBounds(Arrays.asList(
+ TestLine.X_AXIS,
+ TestLine.Y_AXIS,
+ new TestLine(new TestPoint2D(1, 0), new TestPoint2D(0, -1)),
+ new TestLine(new TestPoint2D(1, 0), new TestPoint2D(0, -2)))));
- GeometryTestUtils.assertThrows(() -> {
- StubRegion.fromBounds(Arrays.asList(
- TestLine.X_AXIS,
- TestLine.Y_AXIS,
- new TestLine(new TestPoint2D(1, 0), new TestPoint2D(0, -1)),
- new TestLine(new TestPoint2D(1, 0), new TestPoint2D(0, -2))));
- }, IllegalArgumentException.class);
}
@Test
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractPartitionedRegionBuilderTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractPartitionedRegionBuilderTest.java
index 74b510b..3892782 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractPartitionedRegionBuilderTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractPartitionedRegionBuilderTest.java
@@ -38,7 +38,7 @@ public class AbstractPartitionedRegionBuilderTest {
final TestRegionBSPTree tree = new TestRegionBSPTree(true);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
new TestRegionBuilder(tree);
}, IllegalArgumentException.class, "Tree must be empty");
}
@@ -65,7 +65,7 @@ public class AbstractPartitionedRegionBuilderTest {
builder.insertBoundary(new TestLineSegment(new TestPoint2D(0, 0), new TestPoint2D(1, 0)));
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.insertPartition(new TestLine(new TestPoint2D(0, 0), new TestPoint2D(1, 0)).span());
}, IllegalStateException.class, "Cannot insert partitions after boundaries have been inserted");
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java
index 8385a78..a6130c4 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java
@@ -317,9 +317,9 @@ public class AbstractRegionBSPTreeTest {
@Test
public void testSetLocation_invalidArgs() {
// act/assert
- GeometryTestUtils.assertThrows(() -> root.setLocation(null),
+ GeometryTestUtils.assertThrowsWithMessage(() -> root.setLocation(null),
IllegalArgumentException.class, "Invalid node location: null");
- GeometryTestUtils.assertThrows(() -> root.setLocation(RegionLocation.BOUNDARY),
+ GeometryTestUtils.assertThrowsWithMessage(() -> root.setLocation(RegionLocation.BOUNDARY),
IllegalArgumentException.class, "Invalid node location: BOUNDARY");
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/EpsilonDoublePrecisionContextTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/EpsilonDoublePrecisionContextTest.java
index 956c17c..846b779 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/EpsilonDoublePrecisionContextTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/EpsilonDoublePrecisionContextTest.java
@@ -20,6 +20,7 @@ import org.apache.commons.geometry.core.GeometryTestUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class EpsilonDoublePrecisionContextTest {
@Test
@@ -38,19 +39,17 @@ public class EpsilonDoublePrecisionContextTest {
@Test
public void testInvalidEpsilonValues() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- new EpsilonDoublePrecisionContext(-1.0);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new EpsilonDoublePrecisionContext(-1.0));
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
new EpsilonDoublePrecisionContext(Double.NaN);
}, IllegalArgumentException.class, "Invalid epsilon value: NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
new EpsilonDoublePrecisionContext(Double.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid epsilon value: Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
new EpsilonDoublePrecisionContext(Double.NEGATIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid epsilon value: -Infinity");
}
diff --git a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/EnclosingBallTest.java b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/EnclosingBallTest.java
index 303e1b8..566d356 100644
--- a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/EnclosingBallTest.java
+++ b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/EnclosingBallTest.java
@@ -27,7 +27,6 @@ import org.apache.commons.geometry.euclidean.twod.Vector2D;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertThrows;
public class EnclosingBallTest {
@@ -81,7 +80,7 @@ public class EnclosingBallTest {
final EnclosingBall<Vector2D> ball = new EnclosingBall<>(Vector2D.of(1, 1), 4, support);
// act/assert
- assertThrows(UnsupportedOperationException.class, () -> ball.getSupport().add(Vector2D.Unit.PLUS_X));
+ Assertions.assertThrows(UnsupportedOperationException.class, () -> ball.getSupport().add(Vector2D.Unit.PLUS_X));
}
@Test
diff --git a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/threed/WelzlEncloser3DTest.java b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/threed/WelzlEncloser3DTest.java
index 25f9ca6..2d7107e 100644
--- a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/threed/WelzlEncloser3DTest.java
+++ b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/threed/WelzlEncloser3DTest.java
@@ -46,11 +46,11 @@ public class WelzlEncloser3DTest {
final String msg = "Unable to generate enclosing ball: no points given";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
encloser.enclose(null);
}, IllegalArgumentException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
encloser.enclose(new ArrayList<Vector3D>());
}, IllegalArgumentException.class, msg);
}
diff --git a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/twod/WelzlEncloser2DTest.java b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/twod/WelzlEncloser2DTest.java
index 4bccde8..416bed2 100755
--- a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/twod/WelzlEncloser2DTest.java
+++ b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/twod/WelzlEncloser2DTest.java
@@ -46,11 +46,11 @@ public class WelzlEncloser2DTest {
final String msg = "Unable to generate enclosing ball: no points given";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
encloser.enclose(null);
}, IllegalArgumentException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
encloser.enclose(new ArrayList<Vector2D>());
}, IllegalArgumentException.class, msg);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/MatricesTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/MatricesTest.java
index aaf395e..e12fd2d 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/MatricesTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/MatricesTest.java
@@ -92,19 +92,19 @@ public class MatricesTest {
@Test
public void testCheckDeterminantForInverse_invalid() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Matrices.checkDeterminantForInverse(0);
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is 0.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Matrices.checkDeterminantForInverse(Double.NaN);
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Matrices.checkDeterminantForInverse(Double.POSITIVE_INFINITY);
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Matrices.checkDeterminantForInverse(Double.NEGATIVE_INFINITY);
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is -Infinity");
}
@@ -121,15 +121,15 @@ public class MatricesTest {
@Test
public void testCheckElementForInverse_invalid() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Matrices.checkElementForInverse(Double.NaN);
}, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Matrices.checkElementForInverse(Double.POSITIVE_INFINITY);
}, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Matrices.checkElementForInverse(Double.NEGATIVE_INFINITY);
}, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: -Infinity");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/VectorsTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/VectorsTest.java
index 1f382e6..0109a7d 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/VectorsTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/VectorsTest.java
@@ -53,13 +53,13 @@ public class VectorsTest {
Assertions.assertEquals(-23.12, Vectors.checkedNorm(-23.12), EPS);
Assertions.assertEquals(-2e-12, Vectors.checkedNorm(-2e-12), EPS);
- GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(0.0),
+ GeometryTestUtils.assertThrowsWithMessage(() -> Vectors.checkedNorm(0.0),
IllegalArgumentException.class, "Illegal norm: 0.0");
- GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Double.NaN),
+ GeometryTestUtils.assertThrowsWithMessage(() -> Vectors.checkedNorm(Double.NaN),
IllegalArgumentException.class, "Illegal norm: NaN");
- GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Double.POSITIVE_INFINITY),
+ GeometryTestUtils.assertThrowsWithMessage(() -> Vectors.checkedNorm(Double.POSITIVE_INFINITY),
IllegalArgumentException.class, "Illegal norm: Infinity");
- GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Double.NEGATIVE_INFINITY),
+ GeometryTestUtils.assertThrowsWithMessage(() -> Vectors.checkedNorm(Double.NEGATIVE_INFINITY),
IllegalArgumentException.class, "Illegal norm: -Infinity");
}
@@ -74,13 +74,13 @@ public class VectorsTest {
Assertions.assertEquals(23.12, Vectors.checkedNorm(Vector1D.of(-23.12)), EPS);
Assertions.assertEquals(2e-12, Vectors.checkedNorm(Vector1D.of(-2e-12)), EPS);
- GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Vector3D.ZERO),
+ GeometryTestUtils.assertThrowsWithMessage(() -> Vectors.checkedNorm(Vector3D.ZERO),
IllegalArgumentException.class, "Illegal norm: 0.0");
- GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Vector3D.NaN),
+ GeometryTestUtils.assertThrowsWithMessage(() -> Vectors.checkedNorm(Vector3D.NaN),
IllegalArgumentException.class, "Illegal norm: NaN");
- GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Vector3D.POSITIVE_INFINITY),
+ GeometryTestUtils.assertThrowsWithMessage(() -> Vectors.checkedNorm(Vector3D.POSITIVE_INFINITY),
IllegalArgumentException.class, "Illegal norm: NaN");
- GeometryTestUtils.assertThrows(() -> Vectors.checkedNorm(Vector3D.NEGATIVE_INFINITY),
+ GeometryTestUtils.assertThrowsWithMessage(() -> Vectors.checkedNorm(Vector3D.NEGATIVE_INFINITY),
IllegalArgumentException.class, "Illegal norm: NaN");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java
index 68d9944..dd2c0df 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java
@@ -24,6 +24,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class AffineTransformMatrix1DTest {
private static final double EPS = 1e-12;
@@ -43,7 +44,7 @@ public class AffineTransformMatrix1DTest {
@Test
public void testOf_invalidDimensions() {
// act/assert
- GeometryTestUtils.assertThrows(() -> AffineTransformMatrix1D.of(1),
+ GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix1D.of(1),
IllegalArgumentException.class, "Dimension mismatch: 1 != 2");
}
@@ -63,9 +64,7 @@ public class AffineTransformMatrix1DTest {
@Test
public void testFrom_invalidFunction() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- AffineTransformMatrix1D.from(v -> v.multiply(0));
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AffineTransformMatrix1D.from(v -> v.multiply(0)));
}
@Test
@@ -426,10 +425,8 @@ public class AffineTransformMatrix1DTest {
@Test
public void testApplyDirection_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> AffineTransformMatrix1D.createScale(0).applyDirection(Vector1D.Unit.PLUS),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> AffineTransformMatrix1D.createScale(2).applyDirection(Vector1D.ZERO),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AffineTransformMatrix1D.createScale(0).applyDirection(Vector1D.Unit.PLUS));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AffineTransformMatrix1D.createScale(2).applyDirection(Vector1D.ZERO));
}
@Test
@@ -593,9 +590,7 @@ public class AffineTransformMatrix1DTest {
@Test
public void testNormalTransform_nonInvertible() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- AffineTransformMatrix1D.createScale(0).normalTransform();
- }, IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> AffineTransformMatrix1D.createScale(0).normalTransform());
}
@Test
@@ -676,31 +671,31 @@ public class AffineTransformMatrix1DTest {
@Test
public void testInverse_nonInvertible() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix1D.of(0, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is 0.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix1D.of(Double.NaN, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix1D.of(Double.NEGATIVE_INFINITY, 0.0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is -Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix1D.of(Double.POSITIVE_INFINITY, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix1D.of(1, Double.NaN).inverse();
}, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix1D.of(1, Double.NEGATIVE_INFINITY).inverse();
}, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: -Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix1D.of(1, Double.POSITIVE_INFINITY).inverse();
}, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: Infinity");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java
index 01681ce..d40691b 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.geometry.euclidean.oned;
-import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SplitLocation;
@@ -26,6 +25,7 @@ import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class IntervalTest {
private static final double TEST_EPS = 1e-15;
@@ -63,18 +63,13 @@ public class IntervalTest {
@Test
public void testOf_doubles_invalidIntervals() {
- // arrange
- final Class<?> excType = IllegalArgumentException.class;
// act/assert
- GeometryTestUtils.assertThrows(() -> Interval.of(1, Double.NaN, TEST_PRECISION), excType);
- GeometryTestUtils.assertThrows(() -> Interval.of(Double.NaN, 1, TEST_PRECISION), excType);
- GeometryTestUtils.assertThrows(() -> Interval.of(Double.NaN, Double.NaN, TEST_PRECISION), excType);
-
- GeometryTestUtils.assertThrows(
- () -> Interval.of(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, TEST_PRECISION), excType);
- GeometryTestUtils.assertThrows(
- () -> Interval.of(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, TEST_PRECISION), excType);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(1, Double.NaN, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(Double.NaN, 1, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(Double.NaN, Double.NaN, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, TEST_PRECISION));
}
@Test
@@ -87,14 +82,10 @@ public class IntervalTest {
@Test
public void testOf_points_invalidIntervals() {
- // arrange
- final Class<?> excType = IllegalArgumentException.class;
// act/assert
- GeometryTestUtils.assertThrows(
- () -> Interval.of(Vector1D.of(1), Vector1D.of(Double.NaN), TEST_PRECISION), excType);
- GeometryTestUtils.assertThrows(
- () -> Interval.of(Vector1D.of(Double.POSITIVE_INFINITY), Vector1D.of(Double.POSITIVE_INFINITY), TEST_PRECISION), excType);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(Vector1D.of(1), Vector1D.of(Double.NaN), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(Vector1D.of(Double.POSITIVE_INFINITY), Vector1D.of(Double.POSITIVE_INFINITY), TEST_PRECISION));
}
@Test
@@ -139,44 +130,28 @@ public class IntervalTest {
@Test
public void testOf_hyperplanes_invalidArgs() {
- // arrange
- final Class<?> excType = IllegalArgumentException.class;
-
// act/assert
- GeometryTestUtils.assertThrows(
- () -> Interval.of(
- OrientedPoints.fromLocationAndDirection(1, false, TEST_PRECISION),
- OrientedPoints.fromLocationAndDirection(1, false, TEST_PRECISION)), excType);
-
- GeometryTestUtils.assertThrows(
- () -> Interval.of(
- OrientedPoints.fromLocationAndDirection(2, false, TEST_PRECISION),
- OrientedPoints.fromLocationAndDirection(1, true, TEST_PRECISION)), excType);
-
- GeometryTestUtils.assertThrows(
- () -> Interval.of(
- OrientedPoints.fromLocationAndDirection(Double.POSITIVE_INFINITY, false, TEST_PRECISION),
- OrientedPoints.fromLocationAndDirection(Double.POSITIVE_INFINITY, true, TEST_PRECISION)), excType);
-
- GeometryTestUtils.assertThrows(
- () -> Interval.of(
- OrientedPoints.fromLocationAndDirection(Double.NaN, false, TEST_PRECISION),
- OrientedPoints.fromLocationAndDirection(1, true, TEST_PRECISION)), excType);
-
- GeometryTestUtils.assertThrows(
- () -> Interval.of(
- OrientedPoints.fromLocationAndDirection(1, false, TEST_PRECISION),
- OrientedPoints.fromLocationAndDirection(Double.NaN, true, TEST_PRECISION)), excType);
-
- GeometryTestUtils.assertThrows(
- () -> Interval.of(
- OrientedPoints.fromLocationAndDirection(Double.NaN, false, TEST_PRECISION),
- OrientedPoints.fromLocationAndDirection(Double.NaN, true, TEST_PRECISION)), excType);
-
- GeometryTestUtils.assertThrows(
- () -> Interval.of(
- null,
- OrientedPoints.fromLocationAndDirection(Double.NaN, true, TEST_PRECISION)), excType);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(
+ OrientedPoints.fromLocationAndDirection(1, false, TEST_PRECISION),
+ OrientedPoints.fromLocationAndDirection(1, false, TEST_PRECISION)));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(
+ OrientedPoints.fromLocationAndDirection(2, false, TEST_PRECISION),
+ OrientedPoints.fromLocationAndDirection(1, true, TEST_PRECISION)));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(
+ OrientedPoints.fromLocationAndDirection(Double.POSITIVE_INFINITY, false, TEST_PRECISION),
+ OrientedPoints.fromLocationAndDirection(Double.POSITIVE_INFINITY, true, TEST_PRECISION)));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(
+ OrientedPoints.fromLocationAndDirection(Double.NaN, false, TEST_PRECISION),
+ OrientedPoints.fromLocationAndDirection(1, true, TEST_PRECISION)));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(
+ OrientedPoints.fromLocationAndDirection(1, false, TEST_PRECISION),
+ OrientedPoints.fromLocationAndDirection(Double.NaN, true, TEST_PRECISION)));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(
+ OrientedPoints.fromLocationAndDirection(Double.NaN, false, TEST_PRECISION),
+ OrientedPoints.fromLocationAndDirection(Double.NaN, true, TEST_PRECISION)));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.of(
+ null,
+ OrientedPoints.fromLocationAndDirection(Double.NaN, true, TEST_PRECISION)));
}
@Test
@@ -189,16 +164,10 @@ public class IntervalTest {
@Test
public void testPoint_invalidArgs() {
- // arrange
- final Class<?> excType = IllegalArgumentException.class;
-
// act/assert
- GeometryTestUtils.assertThrows(
- () -> Interval.point(Double.NEGATIVE_INFINITY, TEST_PRECISION), excType);
- GeometryTestUtils.assertThrows(
- () -> Interval.point(Double.POSITIVE_INFINITY, TEST_PRECISION), excType);
- GeometryTestUtils.assertThrows(
- () -> Interval.point(Double.NaN, TEST_PRECISION), excType);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.point(Double.NEGATIVE_INFINITY, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.point(Double.POSITIVE_INFINITY, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.point(Double.NaN, TEST_PRECISION));
}
@Test
@@ -214,14 +183,9 @@ public class IntervalTest {
@Test
public void testMin_invalidArgs() {
- // arrange
- final Class<?> excType = IllegalArgumentException.class;
-
// act/assert
- GeometryTestUtils.assertThrows(
- () -> Interval.min(Double.POSITIVE_INFINITY, TEST_PRECISION), excType);
- GeometryTestUtils.assertThrows(
- () -> Interval.min(Double.NaN, TEST_PRECISION), excType);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.min(Double.POSITIVE_INFINITY, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.min(Double.NaN, TEST_PRECISION));
}
@Test
@@ -237,14 +201,9 @@ public class IntervalTest {
@Test
public void testMax_invalidArgs() {
- // arrange
- final Class<?> excType = IllegalArgumentException.class;
-
// act/assert
- GeometryTestUtils.assertThrows(
- () -> Interval.max(Double.NEGATIVE_INFINITY, TEST_PRECISION), excType);
- GeometryTestUtils.assertThrows(
- () -> Interval.max(Double.NaN, TEST_PRECISION), excType);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.max(Double.NEGATIVE_INFINITY, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Interval.max(Double.NaN, TEST_PRECISION));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java
index be4842b..39b78d6 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java
@@ -112,7 +112,7 @@ public class OrientedPointTest {
final OrientedPoint pt = OrientedPoints.createPositiveFacing(Vector1D.of(2.0), TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(
+ GeometryTestUtils.assertThrowsWithMessage(
() -> pt.transform(zeroScale),
IllegalArgumentException.class, "Oriented point direction cannot be zero");
}
@@ -364,10 +364,10 @@ public class OrientedPointTest {
final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(0.1);
// act/assert
- GeometryTestUtils.assertThrows(
+ GeometryTestUtils.assertThrowsWithMessage(
() -> OrientedPoints.fromPointAndDirection(Vector1D.of(2.0), Vector1D.of(0.09), precision),
IllegalArgumentException.class, "Oriented point direction cannot be zero");
- GeometryTestUtils.assertThrows(
+ GeometryTestUtils.assertThrowsWithMessage(
() -> OrientedPoints.fromPointAndDirection(Vector1D.of(2.0), Vector1D.of(-0.09), precision),
IllegalArgumentException.class, "Oriented point direction cannot be zero");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
index f36c632..085eb9d 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
@@ -27,7 +27,6 @@ import org.apache.commons.numbers.core.Precision;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertThrows;
public class Vector1DTest {
@@ -47,10 +46,10 @@ public class Vector1DTest {
@Test
public void testConstants_normalize() {
// act/assert
- GeometryTestUtils.assertThrows(Vector1D.ZERO::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector1D.NaN::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector1D.POSITIVE_INFINITY::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector1D.NEGATIVE_INFINITY::normalize, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector1D.ZERO::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector1D.NaN::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector1D.POSITIVE_INFINITY::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector1D.NEGATIVE_INFINITY::normalize);
Assertions.assertSame(Vector1D.Unit.PLUS, Vector1D.Unit.PLUS.normalize());
Assertions.assertSame(Vector1D.Unit.MINUS, Vector1D.Unit.MINUS.normalize());
@@ -182,14 +181,10 @@ public class Vector1DTest {
@Test
public void testWithNorm_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector1D.ZERO.withNorm(2.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.NaN.withNorm(2.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.POSITIVE_INFINITY.withNorm(2.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.NEGATIVE_INFINITY.withNorm(2.0),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.ZERO.withNorm(2.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.NaN.withNorm(2.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.POSITIVE_INFINITY.withNorm(2.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.NEGATIVE_INFINITY.withNorm(2.0));
}
@Test
@@ -280,14 +275,10 @@ public class Vector1DTest {
@Test
public void testNormalize_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector1D.of(0.0).normalize(),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.of(Double.NaN).normalize(),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.of(Double.POSITIVE_INFINITY).normalize(),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.of(Double.NEGATIVE_INFINITY).normalize(),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.of(0.0).normalize());
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.of(Double.NaN).normalize());
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.of(Double.POSITIVE_INFINITY).normalize());
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.of(Double.NEGATIVE_INFINITY).normalize());
}
@Test
@@ -407,23 +398,14 @@ public class Vector1DTest {
final Vector1D v = Vector1D.of(1.0);
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector1D.ZERO.angle(v),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.NaN.angle(v),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.POSITIVE_INFINITY.angle(v),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.NEGATIVE_INFINITY.angle(v),
- IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> v.angle(Vector1D.ZERO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.angle(Vector1D.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.angle(Vector1D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.angle(Vector1D.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.ZERO.angle(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.NaN.angle(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.POSITIVE_INFINITY.angle(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.NEGATIVE_INFINITY.angle(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.angle(Vector1D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.angle(Vector1D.NaN));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.angle(Vector1D.POSITIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.angle(Vector1D.NEGATIVE_INFINITY));
}
@Test
@@ -469,16 +451,11 @@ public class Vector1DTest {
final Vector1D v = Vector1D.of(2);
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector1D.ZERO.directionTo(Vector1D.ZERO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.directionTo(v),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.directionTo(Vector1D.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.NEGATIVE_INFINITY.directionTo(v),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.directionTo(Vector1D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.ZERO.directionTo(Vector1D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.directionTo(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.directionTo(Vector1D.NaN));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.NEGATIVE_INFINITY.directionTo(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.directionTo(Vector1D.POSITIVE_INFINITY));
}
@Test
@@ -647,7 +624,7 @@ public class Vector1DTest {
@Test
public void testParse_failure() {
// act/assert
- assertThrows(IllegalArgumentException.class, () -> Vector1D.parse("abc"));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.parse("abc"));
}
@Test
@@ -682,14 +659,10 @@ public class Vector1DTest {
@Test
public void testUnitFrom_illegalNorm() {
- GeometryTestUtils.assertThrows(() -> Vector1D.Unit.from(0.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.Unit.from(Double.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.Unit.from(Double.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector1D.Unit.from(Double.POSITIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.Unit.from(0.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.Unit.from(Double.NaN));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.Unit.from(Double.NEGATIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector1D.Unit.from(Double.POSITIVE_INFINITY));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java
index 7669812..525aae7 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java
@@ -29,6 +29,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class AffineTransformMatrix3DTest {
private static final double EPS = 1e-12;
@@ -57,7 +58,7 @@ public class AffineTransformMatrix3DTest {
@Test
public void testOf_invalidDimensions() {
// act/assert
- GeometryTestUtils.assertThrows(() -> AffineTransformMatrix3D.of(1, 2),
+ GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix3D.of(1, 2),
IllegalArgumentException.class, "Dimension mismatch: 2 != 12");
}
@@ -126,9 +127,7 @@ public class AffineTransformMatrix3DTest {
@Test
public void testFrom_invalidFunction() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- AffineTransformMatrix3D.from(v -> v.multiply(0));
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AffineTransformMatrix3D.from(v -> v.multiply(0)));
}
@Test
@@ -663,10 +662,8 @@ public class AffineTransformMatrix3DTest {
@Test
public void testApplyDirection_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> AffineTransformMatrix3D.createScale(1, 0, 1).applyDirection(Vector3D.Unit.PLUS_Y),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> AffineTransformMatrix3D.createScale(2).applyDirection(Vector3D.ZERO),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AffineTransformMatrix3D.createScale(1, 0, 1).applyDirection(Vector3D.Unit.PLUS_Y));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AffineTransformMatrix3D.createScale(2).applyDirection(Vector3D.ZERO));
}
@Test
@@ -974,49 +971,49 @@ public class AffineTransformMatrix3DTest {
@Test
public void testInverse_nonInvertible() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix3D.of(
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is 0.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix3D.of(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, Double.NaN, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix3D.of(
1, 0, 0, 0,
0, Double.NEGATIVE_INFINITY, 0, 0,
0, 0, 1, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix3D.of(
Double.POSITIVE_INFINITY, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix3D.of(
1, 0, 0, Double.NaN,
0, 1, 0, 0,
0, 0, 1, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix3D.of(
1, 0, 0, 0,
0, 1, 0, Double.POSITIVE_INFINITY,
0, 0, 1, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix3D.of(
1, 0, 0, 0,
0, 1, 0, 0,
@@ -1121,9 +1118,7 @@ public class AffineTransformMatrix3DTest {
@Test
public void testNormalTransform_nonInvertible() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- AffineTransformMatrix3D.createScale(0).normalTransform();
- }, IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> AffineTransformMatrix3D.createScale(0).normalTransform());
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Bounds3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Bounds3DTest.java
index f95ae10..636de3f 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Bounds3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Bounds3DTest.java
@@ -31,6 +31,7 @@ import org.apache.commons.geometry.euclidean.threed.shape.Parallelepiped;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class Bounds3DTest {
private static final double TEST_EPS = 1e-10;
@@ -110,7 +111,7 @@ public class Bounds3DTest {
@Test
public void testFrom_iterable_noPoints() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds3D.from(new ArrayList<>());
}, IllegalStateException.class, NO_POINTS_MESSAGE);
}
@@ -125,27 +126,27 @@ public class Bounds3DTest {
final Vector3D negInf = Vector3D.of(1, 1, Double.NEGATIVE_INFINITY);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds3D.from(Vector3D.NaN);
}, IllegalStateException.class, INVALID_BOUNDS_PATTERN);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds3D.from(Vector3D.POSITIVE_INFINITY);
}, IllegalStateException.class, INVALID_BOUNDS_PATTERN);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds3D.from(Vector3D.NEGATIVE_INFINITY);
}, IllegalStateException.class, INVALID_BOUNDS_PATTERN);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds3D.from(good, nan);
}, IllegalStateException.class, INVALID_BOUNDS_PATTERN);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds3D.from(posInf, good);
}, IllegalStateException.class, INVALID_BOUNDS_PATTERN);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds3D.from(good, negInf, good);
}, IllegalStateException.class, INVALID_BOUNDS_PATTERN);
}
@@ -381,10 +382,8 @@ public class Bounds3DTest {
@Test
public void toRegion_boundingBoxTooSmall() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Bounds3D.from(Vector3D.ZERO, Vector3D.of(1e-12, 1e-12, 1e-12))
- .toRegion(TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Bounds3D.from(Vector3D.ZERO, Vector3D.of(1e-12, 1e-12, 1e-12))
+ .toRegion(TEST_PRECISION));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexVolumeTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexVolumeTest.java
index 3070724..c81e19c 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexVolumeTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexVolumeTest.java
@@ -115,11 +115,11 @@ public class ConvexVolumeTest {
);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
half.triangleStream().collect(Collectors.toList());
}, IllegalStateException.class, pattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
quadrant.triangleStream().collect(Collectors.toList());
}, IllegalStateException.class, pattern);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddedAreaPlaneConvexSubsetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddedAreaPlaneConvexSubsetTest.java
index 76a95ef..844d819 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddedAreaPlaneConvexSubsetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddedAreaPlaneConvexSubsetTest.java
@@ -149,18 +149,18 @@ public class EmbeddedAreaPlaneConvexSubsetTest {
final Pattern pattern = Pattern.compile("^Cannot convert infinite plane subset to triangles: .*");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
new EmbeddedAreaPlaneConvexSubset(XY_PLANE_Z1, ConvexArea.full()).toTriangles();
}, IllegalStateException.class, pattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
final ConvexArea area = ConvexArea.fromBounds(Lines.fromPointAndAngle(Vector2D.ZERO, 0, TEST_PRECISION));
final EmbeddedAreaPlaneConvexSubset halfSpace = new EmbeddedAreaPlaneConvexSubset(XY_PLANE_Z1, area);
halfSpace.toTriangles();
}, IllegalStateException.class, pattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
final ConvexArea area = ConvexArea.fromBounds(
Lines.fromPointAndAngle(Vector2D.ZERO, 0, TEST_PRECISION),
Lines.fromPointAndAngle(Vector2D.ZERO, 0.5 * Math.PI, TEST_PRECISION));
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddedTreePlaneSubsetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddedTreePlaneSubsetTest.java
index 83b5fd8..858fd2c 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddedTreePlaneSubsetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddedTreePlaneSubsetTest.java
@@ -165,11 +165,11 @@ public class EmbeddedTreePlaneSubsetTest {
final Pattern pattern = Pattern.compile("^Cannot convert infinite plane subset to triangles: .*");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
new EmbeddedTreePlaneSubset(XY_PLANE, true).toTriangles();
}, IllegalStateException.class, pattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
final EmbeddedTreePlaneSubset halfSpace = new EmbeddedTreePlaneSubset(XY_PLANE, false);
halfSpace.getSubspaceRegion().getRoot()
.insertCut(Lines.fromPointAndAngle(Vector2D.ZERO, 0, TEST_PRECISION));
@@ -177,7 +177,7 @@ public class EmbeddedTreePlaneSubsetTest {
halfSpace.toTriangles();
}, IllegalStateException.class, pattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
final RegionBSPTree2D tree = RegionBSPTree2D.empty();
tree.insert(Lines.segmentFromPoints(Vector2D.ZERO, Vector2D.of(1, 0), TEST_PRECISION));
tree.insert(Lines.segmentFromPoints(Vector2D.ZERO, Vector2D.of(0, 1), TEST_PRECISION));
@@ -660,17 +660,12 @@ public class EmbeddedTreePlaneSubsetTest {
final EmbeddedTreePlaneSubset ps = new EmbeddedTreePlaneSubset(XY_PLANE, false);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- ps.add(Planes.subsetFromConvexArea(
- Planes.fromPointAndPlaneVectors(Vector3D.ZERO, Vector3D.Unit.PLUS_X, Vector3D.Unit.MINUS_Z, TEST_PRECISION),
- ConvexArea.full()));
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- ps.add(new EmbeddedTreePlaneSubset(
- Planes.fromPointAndPlaneVectors(Vector3D.of(0, 0, -1), Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, TEST_PRECISION),
- false));
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> ps.add(Planes.subsetFromConvexArea(
+ Planes.fromPointAndPlaneVectors(Vector3D.ZERO, Vector3D.Unit.PLUS_X, Vector3D.Unit.MINUS_Z, TEST_PRECISION),
+ ConvexArea.full())));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> ps.add(new EmbeddedTreePlaneSubset(
+ Planes.fromPointAndPlaneVectors(Vector3D.of(0, 0, -1), Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, TEST_PRECISION),
+ false)));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddingPlaneTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddingPlaneTest.java
index 5c0e90d..2deaf74 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddingPlaneTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddingPlaneTest.java
@@ -28,6 +28,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class EmbeddingPlaneTest {
private static final double TEST_EPS = 1e-10;
@@ -59,24 +60,13 @@ public class EmbeddingPlaneTest {
// act/assert
// identical vectors
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPointAndPlaneVectors(pt, Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 1), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPointAndPlaneVectors(pt, Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 1), TEST_PRECISION));
// zero vector
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPointAndPlaneVectors(pt, Vector3D.of(0, 0, 1), Vector3D.ZERO, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPointAndPlaneVectors(pt, Vector3D.of(0, 0, 1), Vector3D.ZERO, TEST_PRECISION));
// collinear vectors
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPointAndPlaneVectors(pt, Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 2), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPointAndPlaneVectors(pt, Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 2), TEST_PRECISION));
// collinear vectors - reversed
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPointAndPlaneVectors(pt, Vector3D.of(0, 0, 1), Vector3D.of(0, 0, -2), TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPointAndPlaneVectors(pt, Vector3D.of(0, 0, 1), Vector3D.of(0, 0, -2), TEST_PRECISION));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
index 4d59789..8254e04 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
@@ -32,6 +32,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class PlaneTest {
private static final double TEST_EPS = 1e-10;
@@ -55,9 +56,7 @@ public class PlaneTest {
@Test
public void testFromNormal_illegalArguments() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromNormal(Vector3D.ZERO, TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromNormal(Vector3D.ZERO, TEST_PRECISION));
}
@Test
@@ -80,9 +79,7 @@ public class PlaneTest {
final Vector3D pt = Vector3D.of(1, 2, 3);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPointAndNormal(pt, Vector3D.ZERO, TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPointAndNormal(pt, Vector3D.ZERO, TEST_PRECISION));
}
@Test
@@ -123,21 +120,11 @@ public class PlaneTest {
final Vector3D b = Vector3D.of(0, 1, 0);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPoints(a, a, a, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPoints(a, a, b, TEST_PRECISION);
- }, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPoints(a, b, a, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPoints(b, a, a, TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPoints(a, a, a, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPoints(a, a, b, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPoints(a, b, a, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPoints(b, a, a, TEST_PRECISION));
}
@Test
@@ -287,72 +274,53 @@ public class PlaneTest {
final Vector3D b = Vector3D.Unit.PLUS_X;
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPoints(Collections.emptyList(), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPoints(Collections.singletonList(a), TEST_PRECISION);
- }, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPoints(Arrays.asList(a, b), TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPoints(Collections.emptyList(), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPoints(Collections.singletonList(a), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPoints(Arrays.asList(a, b), TEST_PRECISION));
}
@Test
public void testFromPoints_collection_allPointsCollinear() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPoints(Arrays.asList(
- Vector3D.ZERO,
- Vector3D.Unit.PLUS_X,
- Vector3D.of(2, 0, 0)
- ), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPoints(Arrays.asList(
- Vector3D.ZERO,
- Vector3D.Unit.PLUS_X,
- Vector3D.of(2, 0, 0),
- Vector3D.of(3, 0, 0)
- ), TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPoints(Arrays.asList(
+ Vector3D.ZERO,
+ Vector3D.Unit.PLUS_X,
+ Vector3D.of(2, 0, 0)
+ ), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPoints(Arrays.asList(
+ Vector3D.ZERO,
+ Vector3D.Unit.PLUS_X,
+ Vector3D.of(2, 0, 0),
+ Vector3D.of(3, 0, 0)
+ ), TEST_PRECISION));
}
@Test
public void testFromPoints_collection_notEnoughUniquePoints() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPoints(Arrays.asList(
- Vector3D.ZERO,
- Vector3D.ZERO,
- Vector3D.of(1e-12, 1e-12, 0),
- Vector3D.Unit.PLUS_X
- ), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPoints(Arrays.asList(
- Vector3D.ZERO,
- Vector3D.of(1e-12, 0, 0),
- Vector3D.ZERO
- ), TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPoints(Arrays.asList(
+ Vector3D.ZERO,
+ Vector3D.ZERO,
+ Vector3D.of(1e-12, 1e-12, 0),
+ Vector3D.Unit.PLUS_X
+ ), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPoints(Arrays.asList(
+ Vector3D.ZERO,
+ Vector3D.of(1e-12, 0, 0),
+ Vector3D.ZERO
+ ), TEST_PRECISION));
}
@Test
public void testFromPoints_collection_pointsNotOnSamePlane() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Planes.fromPoints(Arrays.asList(
- Vector3D.ZERO,
- Vector3D.Unit.PLUS_X,
- Vector3D.Unit.PLUS_Y,
- Vector3D.Unit.PLUS_Z
- ), TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Planes.fromPoints(Arrays.asList(
+ Vector3D.ZERO,
+ Vector3D.Unit.PLUS_X,
+ Vector3D.Unit.PLUS_Y,
+ Vector3D.Unit.PLUS_Z
+ ), TEST_PRECISION));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlanesTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlanesTest.java
index f6e798a..2f08f97 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlanesTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlanesTest.java
@@ -40,6 +40,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class PlanesTest {
private static final double TEST_EPS = 1e-10;
@@ -181,24 +182,24 @@ public class PlanesTest {
final Pattern nonPlanarPattern = Pattern.compile("Points do not define a plane.*");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.convexPolygonFromVertices(Collections.emptyList(), TEST_PRECISION);
}, IllegalArgumentException.class, nonPlanarPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.convexPolygonFromVertices(Collections.singletonList(Vector3D.ZERO), TEST_PRECISION);
}, IllegalArgumentException.class, nonPlanarPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.convexPolygonFromVertices(Arrays.asList(Vector3D.ZERO, Vector3D.of(1, 0, 0)), TEST_PRECISION);
}, IllegalArgumentException.class, nonPlanarPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.convexPolygonFromVertices(
Arrays.asList(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(1, 1e-15, 0)), TEST_PRECISION);
}, IllegalArgumentException.class, nonPlanarPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.convexPolygonFromVertices(Arrays.asList(
Vector3D.ZERO,
Vector3D.of(1, 0, 1),
@@ -214,7 +215,7 @@ public class PlanesTest {
final Pattern nonConvexPattern = Pattern.compile("Points do not define a convex region.*");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.convexPolygonFromVertices(Arrays.asList(
Vector3D.ZERO,
Vector3D.of(2, 0, 0),
@@ -245,7 +246,7 @@ public class PlanesTest {
final Pattern msg = Pattern.compile("^Points do not define a plane.*");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.triangleFromVertices(
Vector3D.ZERO,
Vector3D.of(1e-11, 0, 0),
@@ -253,7 +254,7 @@ public class PlanesTest {
TEST_PRECISION);
}, IllegalArgumentException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.triangleFromVertices(
Vector3D.ZERO,
Vector3D.of(1, 0, 0),
@@ -343,37 +344,32 @@ public class PlanesTest {
};
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.indexedTriangles(vertices, new int[][] {
{0}
}, TEST_PRECISION);
}, IllegalArgumentException.class,
"Invalid number of vertex indices for face at index 0: expected 3 but found 1");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.indexedTriangles(vertices, new int[][] {
{0, 1, 2, 0}
}, TEST_PRECISION);
}, IllegalArgumentException.class,
"Invalid number of vertex indices for face at index 0: expected 3 but found 4");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.indexedTriangles(new ArrayList<>(Arrays.asList(vertices)), new int[][] {
{0, 1, 3}
}, TEST_PRECISION);
}, IllegalArgumentException.class, Pattern.compile("^Points do not define a plane: .*"));
- GeometryTestUtils.assertThrows(() -> {
- Planes.indexedTriangles(vertices, new int[][] {
+ Assertions.assertThrows(IndexOutOfBoundsException.class, () -> Planes.indexedTriangles(vertices, new int[][] {
{0, 1, 10}
- }, TEST_PRECISION);
- }, IndexOutOfBoundsException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Planes.indexedTriangles(new ArrayList<>(Arrays.asList(vertices)), new int[][] {
+ }, TEST_PRECISION));
+ Assertions.assertThrows(IndexOutOfBoundsException.class, () -> Planes.indexedTriangles(new ArrayList<>(Arrays.asList(vertices)), new int[][] {
{0, 1, 10}
- }, TEST_PRECISION);
- }, IndexOutOfBoundsException.class);
+ }, TEST_PRECISION));
}
@Test
@@ -499,30 +495,25 @@ public class PlanesTest {
};
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.indexedConvexPolygons(vertices, new int[][] {
{0}
}, TEST_PRECISION);
}, IllegalArgumentException.class,
"Invalid number of vertex indices for face at index 0: required at least 3 but found 1");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.indexedConvexPolygons(new ArrayList<>(Arrays.asList(vertices)), new int[][] {
{0, 1, 3}
}, TEST_PRECISION);
}, IllegalArgumentException.class, Pattern.compile("^Points do not define a plane: .*"));
- GeometryTestUtils.assertThrows(() -> {
- Planes.indexedConvexPolygons(vertices, new int[][] {
+ Assertions.assertThrows(IndexOutOfBoundsException.class, () -> Planes.indexedConvexPolygons(vertices, new int[][] {
{0, 1, 10}
- }, TEST_PRECISION);
- }, IndexOutOfBoundsException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Planes.indexedConvexPolygons(new ArrayList<>(Arrays.asList(vertices)), new int[][] {
+ }, TEST_PRECISION));
+ Assertions.assertThrows(IndexOutOfBoundsException.class, () -> Planes.indexedConvexPolygons(new ArrayList<>(Arrays.asList(vertices)), new int[][] {
{0, 1, 10}
- }, TEST_PRECISION);
- }, IndexOutOfBoundsException.class);
+ }, TEST_PRECISION));
}
@Test
@@ -662,15 +653,15 @@ public class PlanesTest {
final Plane plane = Planes.fromNormal(Vector3D.Unit.PLUS_Z, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.convexPolygonToTriangleFan(plane, Collections.emptyList());
}, IllegalArgumentException.class, baseMsg + "0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.convexPolygonToTriangleFan(plane, Collections.singletonList(Vector3D.ZERO));
}, IllegalArgumentException.class, baseMsg + "1");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.convexPolygonToTriangleFan(plane, Arrays.asList(Vector3D.ZERO, Vector3D.of(1, 0, 0)));
}, IllegalArgumentException.class, baseMsg + "2");
}
@@ -822,14 +813,9 @@ public class PlanesTest {
final Vector3D extrusionVector = Vector3D.of(0, 0, 2);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Planes.extrudeVertexLoop(Collections.singletonList(Vector2D.ZERO), plane, extrusionVector, TEST_PRECISION);
- }, IllegalStateException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Planes.extrudeVertexLoop(Arrays.asList(Vector2D.ZERO, Vector2D.of(0, 1e-16)), plane,
- extrusionVector, TEST_PRECISION);
- }, IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> Planes.extrudeVertexLoop(Collections.singletonList(Vector2D.ZERO), plane, extrusionVector, TEST_PRECISION));
+ Assertions.assertThrows(IllegalStateException.class, () -> Planes.extrudeVertexLoop(Arrays.asList(Vector2D.ZERO, Vector2D.of(0, 1e-16)), plane,
+ extrusionVector, TEST_PRECISION));
}
@Test
@@ -1339,33 +1325,33 @@ public class PlanesTest {
final Pattern errorPattern = Pattern.compile("^Extrusion vector produces regions of zero size.*");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.extrudeVertexLoop(vertices, plane, Vector3D.of(1e-16, 0, 0), TEST_PRECISION);
}, IllegalArgumentException.class, errorPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.extrudeVertexLoop(vertices, plane, Vector3D.of(4, 1e-16, 0), TEST_PRECISION);
}, IllegalArgumentException.class, errorPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.extrudeVertexLoop(vertices, plane, Vector3D.of(1e-16, 5, 0), TEST_PRECISION);
}, IllegalArgumentException.class, errorPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.extrude(path, plane, Vector3D.of(1e-16, 0, 0), TEST_PRECISION);
}, IllegalArgumentException.class, errorPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.extrude(path, plane, Vector3D.of(4, 1e-16, 0), TEST_PRECISION);
}, IllegalArgumentException.class, errorPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.extrude(path, plane, Vector3D.of(1e-16, 5, 0), TEST_PRECISION);
}, IllegalArgumentException.class, errorPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.extrude(tree, plane, Vector3D.of(1e-16, 0, 0), TEST_PRECISION);
}, IllegalArgumentException.class, errorPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.extrude(tree, plane, Vector3D.of(4, 1e-16, 0), TEST_PRECISION);
}, IllegalArgumentException.class, errorPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Planes.extrude(tree, plane, Vector3D.of(1e-16, 5, 0), TEST_PRECISION);
}, IllegalArgumentException.class, errorPattern);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java
index 0b37c06..7eae12e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java
@@ -44,6 +44,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class RegionBSPTree3DTest {
private static final double TEST_EPS = 1e-10;
@@ -253,19 +254,19 @@ public class RegionBSPTree3DTest {
final String msg = "Cannot insert partitions after boundaries have been inserted";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.insertPartition(partition);
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.insertPartition(partition.span());
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.insertAxisAlignedPartitions(Vector3D.ZERO, TEST_PRECISION);
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.insertAxisAlignedGrid(Bounds3D.from(Vector3D.ZERO, Vector3D.of(1, 1, 1)), 1, TEST_PRECISION);
}, IllegalStateException.class, msg);
}
@@ -432,9 +433,7 @@ public class RegionBSPTree3DTest {
tree.getRoot().insertCut(Planes.fromNormal(Vector3D.Unit.PLUS_Z, TEST_PRECISION));
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- tree.toTriangleMesh(TEST_PRECISION);
- }, IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> tree.toTriangleMesh(TEST_PRECISION));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SimpleTriangle3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SimpleTriangle3DTest.java
index 6b0c7fa..497512a 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SimpleTriangle3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SimpleTriangle3DTest.java
@@ -32,6 +32,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class SimpleTriangle3DTest {
private static final double TEST_EPS = 1e-10;
@@ -86,9 +87,7 @@ public class SimpleTriangle3DTest {
Vector3D.of(0, 0, 1), Vector3D.of(1, 0, 1), Vector3D.of(0, 1, 1));
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- tri.getVertices().add(Vector3D.of(-1, 0, 1));
- }, UnsupportedOperationException.class);
+ Assertions.assertThrows(UnsupportedOperationException.class, () -> tri.getVertices().add(Vector3D.of(-1, 0, 1)));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SphericalCoordinatesTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SphericalCoordinatesTest.java
index 429918e..25068bb 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SphericalCoordinatesTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SphericalCoordinatesTest.java
@@ -23,7 +23,6 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertThrows;
public class SphericalCoordinatesTest {
@@ -363,7 +362,7 @@ public class SphericalCoordinatesTest {
@Test
public void testParse_failure() {
// act/assert
- assertThrows(IllegalArgumentException.class, () -> SphericalCoordinates.parse("abc"));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> SphericalCoordinates.parse("abc"));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
index d1a1a9e..b378665 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
@@ -34,7 +34,6 @@ import org.apache.commons.rng.simple.RandomSource;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertThrows;
public class Vector3DTest {
@@ -62,10 +61,13 @@ public class Vector3DTest {
@Test
public void testConstants_normalize() {
// act/assert
- GeometryTestUtils.assertThrows(Vector3D.ZERO::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector3D.NaN::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector3D.POSITIVE_INFINITY::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector3D.NEGATIVE_INFINITY::normalize, IllegalArgumentException.class);
+
+
+ Assertions.assertThrows(IllegalArgumentException.class, Vector3D.ZERO::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector3D.NaN::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector3D.POSITIVE_INFINITY::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector3D.NEGATIVE_INFINITY::normalize);
+
Assertions.assertSame(Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_X.normalize());
Assertions.assertSame(Vector3D.Unit.MINUS_X, Vector3D.Unit.MINUS_X.normalize());
@@ -268,14 +270,10 @@ public class Vector3DTest {
@Test
public void testWithNorm_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.withNorm(2.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.NaN.withNorm(2.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.POSITIVE_INFINITY.withNorm(2.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.withNorm(2.0),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.ZERO.withNorm(2.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.NaN.withNorm(2.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.POSITIVE_INFINITY.withNorm(2.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.NEGATIVE_INFINITY.withNorm(2.0));
}
@Test
@@ -407,10 +405,10 @@ public class Vector3DTest {
@Test
public void testNormalize_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(Vector3D.ZERO::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector3D.NaN::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector3D.POSITIVE_INFINITY::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector3D.NEGATIVE_INFINITY::normalize, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector3D.ZERO::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector3D.NaN::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector3D.POSITIVE_INFINITY::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector3D.NEGATIVE_INFINITY::normalize);
}
@Test
@@ -442,10 +440,10 @@ public class Vector3DTest {
@Test
public void testOrthogonal_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(Vector3D.ZERO::orthogonal, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector3D.NaN::orthogonal, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector3D.POSITIVE_INFINITY::orthogonal, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector3D.NEGATIVE_INFINITY::orthogonal, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector3D.ZERO::orthogonal);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector3D.NaN::orthogonal);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector3D.POSITIVE_INFINITY::orthogonal);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector3D.NEGATIVE_INFINITY::orthogonal);
}
@Test
@@ -464,36 +462,24 @@ public class Vector3DTest {
@Test
public void testOrthogonal_givenDirection_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.orthogonal(Vector3D.Unit.PLUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.NaN.orthogonal(Vector3D.Unit.PLUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.POSITIVE_INFINITY.orthogonal(Vector3D.Unit.PLUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.orthogonal(Vector3D.Unit.PLUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.ZERO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.ZERO.orthogonal(Vector3D.Unit.PLUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.NaN.orthogonal(Vector3D.Unit.PLUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.POSITIVE_INFINITY.orthogonal(Vector3D.Unit.PLUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.NEGATIVE_INFINITY.orthogonal(Vector3D.Unit.PLUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.NaN));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.POSITIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.NEGATIVE_INFINITY));
}
@Test
public void testOrthogonal_givenDirection_directionIsCollinear() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.Unit.PLUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.Unit.MINUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.of(1.0, 1.0, 1.0).orthogonal(Vector3D.of(2.0, 2.0, 2.0)),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.of(-1.01, -1.01, -1.01).orthogonal(Vector3D.of(20.1, 20.1, 20.1)),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.Unit.PLUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.Unit.MINUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.of(1.0, 1.0, 1.0).orthogonal(Vector3D.of(2.0, 2.0, 2.0)));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.of(-1.01, -1.01, -1.01).orthogonal(Vector3D.of(20.1, 20.1, 20.1)));
}
@Test
@@ -524,23 +510,15 @@ public class Vector3DTest {
final Vector3D v = Vector3D.of(1.0, 1.0, 1.0);
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.angle(v),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.NaN.angle(v),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.POSITIVE_INFINITY.angle(v),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.angle(v),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.angle(Vector3D.ZERO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.angle(Vector3D.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.angle(Vector3D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.angle(Vector3D.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.ZERO.angle(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.NaN.angle(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.POSITIVE_INFINITY.angle(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.NEGATIVE_INFINITY.angle(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.angle(Vector3D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.angle(Vector3D.NaN));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.angle(Vector3D.POSITIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.angle(Vector3D.NEGATIVE_INFINITY));
}
@Test
@@ -796,14 +774,10 @@ public class Vector3DTest {
final Vector3D v = Vector3D.of(1.0, 1.0, 1.0);
// act/assert
- GeometryTestUtils.assertThrows(() -> v.project(Vector3D.ZERO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.project(Vector3D.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.project(Vector3D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.project(Vector3D.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.project(Vector3D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.project(Vector3D.NaN));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.project(Vector3D.POSITIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.project(Vector3D.NEGATIVE_INFINITY));
}
@Test
@@ -842,14 +816,12 @@ public class Vector3DTest {
final Vector3D v = Vector3D.of(1.0, 1.0, 1.0);
// act/assert
- GeometryTestUtils.assertThrows(() -> v.reject(Vector3D.ZERO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.reject(Vector3D.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.reject(Vector3D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.reject(Vector3D.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
+
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.reject(Vector3D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.reject(Vector3D.NaN));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.reject(Vector3D.POSITIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.reject(Vector3D.NEGATIVE_INFINITY));
+
}
@Test
@@ -943,16 +915,10 @@ public class Vector3DTest {
final Vector3D p = Vector3D.of(1, 2, 3);
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.directionTo(Vector3D.ZERO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> p.directionTo(p),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> p.directionTo(Vector3D.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.directionTo(p),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> p.directionTo(Vector3D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.ZERO.directionTo(Vector3D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> p.directionTo(p));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.NEGATIVE_INFINITY.directionTo(p));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> p.directionTo(Vector3D.POSITIVE_INFINITY));
}
@Test
@@ -1150,7 +1116,7 @@ public class Vector3DTest {
@Test
public void testParse_failure() {
// act/assert
- assertThrows(IllegalArgumentException.class, () -> Vector3D.parse("abc"));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.parse("abc"));
}
@Test
@@ -1178,7 +1144,7 @@ public class Vector3DTest {
@Test
public void testOf_arrayArg_invalidDimensions() {
// act/assert
- assertThrows(IllegalArgumentException.class, () -> Vector3D.of(new double[] {0.0, 0.0}));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.of(new double[] {0.0, 0.0}));
}
@Test
@@ -1205,14 +1171,10 @@ public class Vector3DTest {
@Test
public void testUnitFrom_static_illegalNorm() {
- GeometryTestUtils.assertThrows(() -> Vector3D.Unit.from(0.0, 0.0, 0.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.Unit.from(Double.NaN, 1.0, 1.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.Unit.from(1.0, Double.NEGATIVE_INFINITY, 1.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.Unit.from(1.0, 1.0, Double.POSITIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.Unit.from(0.0, 0.0, 0.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.Unit.from(Double.NaN, 1.0, 1.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.Unit.from(1.0, Double.NEGATIVE_INFINITY, 1.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector3D.Unit.from(1.0, 1.0, Double.POSITIVE_INFINITY));
}
@Test
@@ -1234,7 +1196,7 @@ public class Vector3DTest {
final String msg = "Cannot compute vector max: no vectors given";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Vector3D.max(new ArrayList<>());
}, IllegalArgumentException.class, msg);
}
@@ -1258,7 +1220,7 @@ public class Vector3DTest {
final String msg = "Cannot compute vector min: no vectors given";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Vector3D.min(new ArrayList<>());
}, IllegalArgumentException.class, msg);
}
@@ -1287,7 +1249,7 @@ public class Vector3DTest {
final String msg = "Cannot compute centroid: no points given";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Vector3D.centroid(new ArrayList<>());
}, IllegalArgumentException.class, msg);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/VertexListConvexPolygon3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/VertexListConvexPolygon3DTest.java
index 8b4c499..ef5a7dc 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/VertexListConvexPolygon3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/VertexListConvexPolygon3DTest.java
@@ -34,6 +34,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class VertexListConvexPolygon3DTest {
private static final double TEST_EPS = 1e-10;
@@ -76,7 +77,7 @@ public class VertexListConvexPolygon3DTest {
@Test
public void testCtor_validatesVertexListSize() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
new VertexListConvexPolygon3D(XY_PLANE_Z1, Arrays.asList(Vector3D.ZERO, Vector3D.Unit.PLUS_X));
}, IllegalArgumentException.class, "Convex polygon requires at least 3 points; found 2");
}
@@ -88,9 +89,7 @@ public class VertexListConvexPolygon3DTest {
final VertexListConvexPolygon3D p = new VertexListConvexPolygon3D(XY_PLANE_Z1, vertices);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- p.getVertices().add(Vector3D.of(-1, 0, 1));
- }, UnsupportedOperationException.class);
+ Assertions.assertThrows(UnsupportedOperationException.class, () -> p.getVertices().add(Vector3D.of(-1, 0, 1)));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Line3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Line3DTest.java
index 5461bc1..b0f6e23 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Line3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Line3DTest.java
@@ -29,7 +29,6 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertThrows;
public class Line3DTest {
@@ -65,11 +64,11 @@ public class Line3DTest {
@Test
public void testFromPointAndDirection_illegalDirectionNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.fromPointAndDirection(Vector3D.ZERO, Vector3D.ZERO, TEST_PRECISION);
}, IllegalArgumentException.class, "Line direction cannot be zero");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.fromPointAndDirection(Vector3D.ZERO, Vector3D.of(1e-12, 1e-12, 1e-12), TEST_PRECISION);
}, IllegalArgumentException.class, "Line direction cannot be zero");
}
@@ -88,7 +87,7 @@ public class Line3DTest {
@Test
public void testFromPoints_pointsTooClose() {
// act/assert
- assertThrows(IllegalArgumentException.class, () -> Lines3D.fromPoints(Vector3D.of(1, 1, 1),
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Lines3D.fromPoints(Vector3D.of(1, 1, 1),
Vector3D.of(1, 1, 1 + 1e-16), TEST_PRECISION));
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/LineConvexSubset3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/LineConvexSubset3DTest.java
index ee63b81..620770e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/LineConvexSubset3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/LineConvexSubset3DTest.java
@@ -194,19 +194,19 @@ public class LineConvexSubset3DTest {
final Line3D line = Lines3D.fromPointAndDirection(Vector3D.ZERO, Vector3D.of(1, 1, 1), TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.subsetFromInterval(line, Double.NaN, 0);
}, IllegalArgumentException.class, "Invalid line convex subset interval: NaN, 0.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.subsetFromInterval(line, 0, Double.NaN);
}, IllegalArgumentException.class, "Invalid line convex subset interval: 0.0, NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.subsetFromInterval(line, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid line convex subset interval: Infinity, Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.subsetFromInterval(line, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid line convex subset interval: -Infinity, -Infinity");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Ray3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Ray3DTest.java
index 92c79ae..ce6e0bc 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Ray3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Ray3DTest.java
@@ -67,7 +67,7 @@ public class Ray3DTest {
final Vector3D dir = Vector3D.of(1e-11, 0, 0);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.rayFromPointAndDirection(pt, dir, TEST_PRECISION);
}, IllegalArgumentException.class, "Line direction cannot be zero");
}
@@ -104,15 +104,15 @@ public class Ray3DTest {
final Line3D line = Lines3D.fromPointAndDirection(Vector3D.ZERO, Vector3D.Unit.PLUS_X, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.rayFromPoint(line, Vector3D.NaN);
}, IllegalArgumentException.class, "Invalid ray start location: NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.rayFromPoint(line, Vector3D.NEGATIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid ray start location: NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.rayFromPoint(line, Vector3D.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid ray start location: NaN");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/ReverseRay3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/ReverseRay3DTest.java
index b58af5c..dbfceb0 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/ReverseRay3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/ReverseRay3DTest.java
@@ -67,7 +67,7 @@ public class ReverseRay3DTest {
final Vector3D dir = Vector3D.of(1e-11, 0, 0);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.reverseRayFromPointAndDirection(pt, dir, TEST_PRECISION);
}, IllegalArgumentException.class, "Line direction cannot be zero");
}
@@ -104,15 +104,15 @@ public class ReverseRay3DTest {
final Line3D line = Lines3D.fromPointAndDirection(Vector3D.ZERO, Vector3D.Unit.PLUS_X, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.reverseRayFromPoint(line, Vector3D.NaN);
}, IllegalArgumentException.class, "Invalid reverse ray end location: NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.reverseRayFromPoint(line, Vector3D.NEGATIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid reverse ray end location: NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.reverseRayFromPoint(line, Vector3D.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid reverse ray end location: NaN");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Segment3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Segment3DTest.java
index fc846db..2b37c01 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Segment3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Segment3DTest.java
@@ -69,11 +69,11 @@ public class Segment3DTest {
final Vector3D p2 = Vector3D.of(1e-17, 2, 4);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.segmentFromPoints(p1, p1, TEST_PRECISION);
}, IllegalArgumentException.class, "Line direction cannot be zero");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.segmentFromPoints(p1, p2, TEST_PRECISION);
}, IllegalArgumentException.class, "Line direction cannot be zero");
}
@@ -144,19 +144,19 @@ public class Segment3DTest {
final Line3D line = Lines3D.fromPointAndDirection(Vector3D.ZERO, Vector3D.Unit.PLUS_X, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.segmentFromPoints(line, Vector3D.NaN, p1);
}, IllegalArgumentException.class, "Invalid line segment locations: NaN, 2.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.segmentFromPoints(line, p0, Vector3D.NaN);
}, IllegalArgumentException.class, "Invalid line segment locations: 1.0, NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.segmentFromPoints(line, Vector3D.NEGATIVE_INFINITY, p1);
}, IllegalArgumentException.class, "Invalid line segment locations: NaN, 2.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.segmentFromPoints(line, p0, Vector3D.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid line segment locations: 1.0, NaN");
}
@@ -245,19 +245,19 @@ public class Segment3DTest {
final Line3D line = Lines3D.fromPointAndDirection(Vector3D.ZERO, Vector3D.Unit.MINUS_Z, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.segmentFromLocations(line, Double.NaN, 2);
}, IllegalArgumentException.class, "Invalid line segment locations: NaN, 2.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.segmentFromLocations(line, 1, Double.NaN);
}, IllegalArgumentException.class, "Invalid line segment locations: 1.0, NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.segmentFromLocations(line, Double.NEGATIVE_INFINITY, 2);
}, IllegalArgumentException.class, "Invalid line segment locations: -Infinity, 2.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines3D.segmentFromLocations(line, 1, Double.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid line segment locations: 1.0, Infinity");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/mesh/SimpleTriangleMeshTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/mesh/SimpleTriangleMeshTest.java
index 24e6533..89189b4 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/mesh/SimpleTriangleMeshTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/mesh/SimpleTriangleMeshTest.java
@@ -40,6 +40,7 @@ import org.apache.commons.geometry.euclidean.threed.shape.Parallelepiped;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class SimpleTriangleMeshTest {
private static final double TEST_EPS = 1e-10;
@@ -274,7 +275,7 @@ public class SimpleTriangleMeshTest {
Assertions.assertEquals(0, it.next().getIndex());
Assertions.assertFalse(it.hasNext());
- GeometryTestUtils.assertThrows(() -> it.next(), NoSuchElementException.class);
+ Assertions.assertThrows(NoSuchElementException.class, it::next);
}
@Test
@@ -355,12 +356,12 @@ public class SimpleTriangleMeshTest {
final Pattern msgPattern = Pattern.compile("^Points do not define a plane: .*");
Assertions.assertFalse(mesh.getFace(0).definesPolygon());
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
mesh.getFace(0).getPolygon();
}, IllegalArgumentException.class, msgPattern);
Assertions.assertFalse(mesh.getFace(1).definesPolygon());
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
mesh.getFace(1).getPolygon();
}, IllegalArgumentException.class, msgPattern);
}
@@ -515,27 +516,27 @@ public class SimpleTriangleMeshTest {
final String msgBase = "Invalid vertex index: ";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFace(-1, 1, 2);
}, IllegalArgumentException.class, msgBase + "-1");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFace(0, 3, 2);
}, IllegalArgumentException.class, msgBase + "3");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFace(0, 1, 4);
}, IllegalArgumentException.class, msgBase + "4");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFaces(new int[][] {{-1, 1, 2}});
}, IllegalArgumentException.class, msgBase + "-1");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFaces(new int[][] {{0, 3, 2}});
}, IllegalArgumentException.class, msgBase + "3");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFaces(new int[][] {{0, 1, 4}});
}, IllegalArgumentException.class, msgBase + "4");
}
@@ -552,19 +553,19 @@ public class SimpleTriangleMeshTest {
final String msgBase = "Face must contain 3 vertex indices; found ";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFaces(new int[][] {{}});
}, IllegalArgumentException.class, msgBase + "0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFaces(new int[][] {{0}});
}, IllegalArgumentException.class, msgBase + "1");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFaces(new int[][] {{0, 1}});
}, IllegalArgumentException.class, msgBase + "2");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFaces(new int[][] {{0, 1, 2, 3}});
}, IllegalArgumentException.class, msgBase + "4");
}
@@ -586,35 +587,35 @@ public class SimpleTriangleMeshTest {
final String msg = "Builder instance cannot be modified: mesh construction is complete";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.useVertex(Vector3D.ZERO);
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addVertex(Vector3D.ZERO);
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addVertices(Collections.singletonList(Vector3D.ZERO));
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addVertices(new Vector3D[] {Vector3D.ZERO});
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFaceUsingVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0));
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFace(0, 1, 2);
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFaces(Collections.singletonList(new int[]{0, 1, 2}));
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.addFaces(new int[][] {{0, 1, 2}});
}, IllegalStateException.class, msg);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
index ea3a83f..74e4752 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
@@ -35,6 +35,7 @@ import org.apache.commons.rng.simple.RandomSource;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class QuaternionRotationTest {
private static final double EPS = 1e-12;
@@ -71,16 +72,11 @@ public class QuaternionRotationTest {
@Test
public void testOf_quaternion_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() ->
- QuaternionRotation.of(Quaternion.of(0, 0, 0, 0)), IllegalStateException.class);
- GeometryTestUtils.assertThrows(() ->
- QuaternionRotation.of(Quaternion.of(1, 1, 1, Double.NaN)), IllegalStateException.class);
- GeometryTestUtils.assertThrows(() ->
- QuaternionRotation.of(Quaternion.of(1, 1, Double.POSITIVE_INFINITY, 1)), IllegalStateException.class);
- GeometryTestUtils.assertThrows(() ->
- QuaternionRotation.of(Quaternion.of(1, Double.NEGATIVE_INFINITY, 1, 1)), IllegalStateException.class);
- GeometryTestUtils.assertThrows(() ->
- QuaternionRotation.of(Quaternion.of(Double.NaN, 1, 1, 1)), IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> QuaternionRotation.of(Quaternion.of(0, 0, 0, 0)));
+ Assertions.assertThrows(IllegalStateException.class, () -> QuaternionRotation.of(Quaternion.of(1, 1, 1, Double.NaN)));
+ Assertions.assertThrows(IllegalStateException.class, () -> QuaternionRotation.of(Quaternion.of(1, 1, Double.POSITIVE_INFINITY, 1)));
+ Assertions.assertThrows(IllegalStateException.class, () -> QuaternionRotation.of(Quaternion.of(1, Double.NEGATIVE_INFINITY, 1, 1)));
+ Assertions.assertThrows(IllegalStateException.class, () -> QuaternionRotation.of(Quaternion.of(Double.NaN, 1, 1, 1)));
}
@Test
@@ -99,11 +95,11 @@ public class QuaternionRotationTest {
@Test
public void testOf_components_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.of(0, 0, 0, 0), IllegalStateException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.of(1, 1, 1, Double.NaN), IllegalStateException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.of(1, 1, Double.POSITIVE_INFINITY, 1), IllegalStateException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.of(1, Double.NEGATIVE_INFINITY, 1, 1), IllegalStateException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.of(Double.NaN, 1, 1, 1), IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> QuaternionRotation.of(0, 0, 0, 0));
+ Assertions.assertThrows(IllegalStateException.class, () -> QuaternionRotation.of(1, 1, 1, Double.NaN));
+ Assertions.assertThrows(IllegalStateException.class, () -> QuaternionRotation.of(1, 1, Double.POSITIVE_INFINITY, 1));
+ Assertions.assertThrows(IllegalStateException.class, () -> QuaternionRotation.of(1, Double.NEGATIVE_INFINITY, 1, 1));
+ Assertions.assertThrows(IllegalStateException.class, () -> QuaternionRotation.of(Double.NaN, 1, 1, 1));
}
@Test
@@ -254,24 +250,21 @@ public class QuaternionRotationTest {
@Test
public void testFromAxisAngle_invalidAxisNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.ZERO, PlaneAngleRadians.PI_OVER_TWO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.NaN, PlaneAngleRadians.PI_OVER_TWO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.POSITIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.NEGATIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO),
- IllegalArgumentException.class);
+
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.fromAxisAngle(Vector3D.ZERO, PlaneAngleRadians.PI_OVER_TWO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.fromAxisAngle(Vector3D.NaN, PlaneAngleRadians.PI_OVER_TWO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.fromAxisAngle(Vector3D.POSITIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.fromAxisAngle(Vector3D.NEGATIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO));
}
@Test
public void testFromAxisAngle_invalidAngle() {
// act/assert
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.NaN),
+ GeometryTestUtils.assertThrowsWithMessage(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.NaN),
IllegalArgumentException.class, "Invalid angle: NaN");
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.POSITIVE_INFINITY),
+ GeometryTestUtils.assertThrowsWithMessage(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.POSITIVE_INFINITY),
IllegalArgumentException.class, "Invalid angle: Infinity");
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.NEGATIVE_INFINITY),
+ GeometryTestUtils.assertThrowsWithMessage(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.NEGATIVE_INFINITY),
IllegalArgumentException.class, "Invalid angle: -Infinity");
}
@@ -977,8 +970,8 @@ public class QuaternionRotationTest {
final QuaternionRotation q = QuaternionRotation.identity();
// act/assert
- GeometryTestUtils.assertThrows(() -> q.toAxisAngleSequence(null, AxisSequence.XYZ), IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> q.toAxisAngleSequence(AxisReferenceFrame.ABSOLUTE, null), IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> q.toAxisAngleSequence(null, AxisSequence.XYZ));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> q.toAxisAngleSequence(AxisReferenceFrame.ABSOLUTE, null));
}
@Test
@@ -1159,17 +1152,11 @@ public class QuaternionRotationTest {
@Test
public void testCreateVectorRotation_invalidArgs() {
// act/assert
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.ZERO, Vector3D.Unit.PLUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.Unit.PLUS_X, Vector3D.ZERO),
- IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.NaN, Vector3D.Unit.PLUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.Unit.PLUS_X, Vector3D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.Unit.PLUS_X, Vector3D.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.createVectorRotation(Vector3D.ZERO, Vector3D.Unit.PLUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.createVectorRotation(Vector3D.Unit.PLUS_X, Vector3D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.createVectorRotation(Vector3D.NaN, Vector3D.Unit.PLUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.createVectorRotation(Vector3D.Unit.PLUS_X, Vector3D.POSITIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.createVectorRotation(Vector3D.Unit.PLUS_X, Vector3D.NEGATIVE_INFINITY));
}
@Test
@@ -1343,26 +1330,18 @@ public class QuaternionRotationTest {
@Test
public void testCreateBasisRotation_invalidArgs() {
// act/assert
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
- Vector3D.ZERO, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
- Vector3D.Unit.PLUS_X, Vector3D.NaN, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
- Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.POSITIVE_INFINITY, Vector3D.Unit.MINUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
- Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Y, Vector3D.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
- Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X),
- IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
- Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_Y),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.createBasisRotation(
+ Vector3D.ZERO, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.createBasisRotation(
+ Vector3D.Unit.PLUS_X, Vector3D.NaN, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.createBasisRotation(
+ Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.POSITIVE_INFINITY, Vector3D.Unit.MINUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.createBasisRotation(
+ Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Y, Vector3D.NEGATIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.createBasisRotation(
+ Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> QuaternionRotation.createBasisRotation(
+ Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_Y));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/ParallelepipedTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/ParallelepipedTest.java
index a7be6da..47545fd 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/ParallelepipedTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/ParallelepipedTest.java
@@ -22,7 +22,6 @@ import java.util.List;
import java.util.Set;
import java.util.TreeSet;
-import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
@@ -35,6 +34,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class ParallelepipedTest {
private static final double TEST_EPS = 1e-10;
@@ -146,20 +146,12 @@ public class ParallelepipedTest {
@Test
public void testFromTransformedUnitCube_zeroSizeRegion() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Parallelepiped.fromTransformedUnitCube(AffineTransformMatrix3D.createScale(Vector3D.of(1e-16, 1, 1)),
- TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Parallelepiped.fromTransformedUnitCube(AffineTransformMatrix3D.createScale(Vector3D.of(1, 1e-16, 1)),
- TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Parallelepiped.fromTransformedUnitCube(AffineTransformMatrix3D.createScale(Vector3D.of(1, 1, 1e-16)),
- TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Parallelepiped.fromTransformedUnitCube(AffineTransformMatrix3D.createScale(Vector3D.of(1e-16, 1, 1)),
+ TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Parallelepiped.fromTransformedUnitCube(AffineTransformMatrix3D.createScale(Vector3D.of(1, 1e-16, 1)),
+ TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Parallelepiped.fromTransformedUnitCube(AffineTransformMatrix3D.createScale(Vector3D.of(1, 1, 1e-16)),
+ TEST_PRECISION));
}
@Test
@@ -209,17 +201,9 @@ public class ParallelepipedTest {
@Test
public void testAxisAligned_illegalArgs() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Parallelepiped.axisAligned(Vector3D.of(1, 2, 3), Vector3D.of(1, 5, 6), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Parallelepiped.axisAligned(Vector3D.of(1, 2, 3), Vector3D.of(4, 2, 6), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Parallelepiped.axisAligned(Vector3D.of(1, 2, 3), Vector3D.of(1, 5, 3), TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Parallelepiped.axisAligned(Vector3D.of(1, 2, 3), Vector3D.of(1, 5, 6), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Parallelepiped.axisAligned(Vector3D.of(1, 2, 3), Vector3D.of(4, 2, 6), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Parallelepiped.axisAligned(Vector3D.of(1, 2, 3), Vector3D.of(1, 5, 3), TEST_PRECISION));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/SphereTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/SphereTest.java
index f093cad..0108da0 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/SphereTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/SphereTest.java
@@ -44,6 +44,7 @@ import org.apache.commons.rng.simple.RandomSource;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class SphereTest {
private static final double TEST_EPS = 1e-10;
@@ -74,12 +75,8 @@ public class SphereTest {
@Test
public void testFrom_illegalCenter() {
// act/assert
- GeometryTestUtils.assertThrows(
- () -> Sphere.from(Vector3D.of(Double.POSITIVE_INFINITY, 1, 2), 1, TEST_PRECISION),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(
- () -> Sphere.from(Vector3D.of(Double.NaN, 1, 2), 1, TEST_PRECISION),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Sphere.from(Vector3D.of(Double.POSITIVE_INFINITY, 1, 2), 1, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Sphere.from(Vector3D.of(Double.NaN, 1, 2), 1, TEST_PRECISION));
}
@Test
@@ -88,17 +85,11 @@ public class SphereTest {
final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-2);
// act/assert
- GeometryTestUtils.assertThrows(() -> Sphere.from(Vector3D.ZERO, -1, TEST_PRECISION),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Sphere.from(Vector3D.ZERO, 0, TEST_PRECISION),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Sphere.from(Vector3D.ZERO, Double.POSITIVE_INFINITY, TEST_PRECISION),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Sphere.from(Vector3D.ZERO, Double.NaN, TEST_PRECISION),
- IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> Sphere.from(Vector3D.ZERO, 1e-3, precision),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Sphere.from(Vector3D.ZERO, -1, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Sphere.from(Vector3D.ZERO, 0, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Sphere.from(Vector3D.ZERO, Double.POSITIVE_INFINITY, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Sphere.from(Vector3D.ZERO, Double.NaN, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Sphere.from(Vector3D.ZERO, 1e-3, precision));
}
@Test
@@ -428,7 +419,7 @@ public class SphereTest {
final Sphere s = Sphere.from(Vector3D.ZERO, 1, precision);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
s.toTree(6);
}, IllegalStateException.class,
Pattern.compile("^Failed to construct sphere approximation with subdivision count 6:.*"));
@@ -440,7 +431,7 @@ public class SphereTest {
final Sphere s = Sphere.from(Vector3D.of(2, 1, 3), 2, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
s.toTree(-1);
}, IllegalArgumentException.class,
"Number of sphere approximation subdivisions must be greater than or equal to zero; was -1");
@@ -501,7 +492,7 @@ public class SphereTest {
final Sphere s = Sphere.from(Vector3D.of(2, 1, 3), 2, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
s.toTriangleMesh(-1);
}, IllegalArgumentException.class,
"Number of sphere approximation subdivisions must be greater than or equal to zero; was -1");
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java
index 4cc9fc6..e17ee8f 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java
@@ -27,6 +27,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class AffineTransformMatrix2DTest {
private static final double EPS = 1e-12;
@@ -54,7 +55,7 @@ public class AffineTransformMatrix2DTest {
@Test
public void testOf_invalidDimensions() {
// act/assert
- GeometryTestUtils.assertThrows(() -> AffineTransformMatrix2D.of(1, 2),
+ GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix2D.of(1, 2),
IllegalArgumentException.class, "Dimension mismatch: 2 != 6");
}
@@ -128,9 +129,7 @@ public class AffineTransformMatrix2DTest {
@Test
public void testFrom_invalidFunction() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- AffineTransformMatrix2D.from(v -> v.multiply(0));
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AffineTransformMatrix2D.from(v -> v.multiply(0)));
}
@Test
@@ -719,10 +718,8 @@ public class AffineTransformMatrix2DTest {
@Test
public void testApplyDirection_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> AffineTransformMatrix2D.createScale(1, 0).applyDirection(Vector2D.Unit.PLUS_Y),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> AffineTransformMatrix2D.createScale(2).applyDirection(Vector2D.ZERO),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AffineTransformMatrix2D.createScale(1, 0).applyDirection(Vector2D.Unit.PLUS_Y));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AffineTransformMatrix2D.createScale(2).applyDirection(Vector2D.ZERO));
}
@Test
@@ -1002,43 +999,43 @@ public class AffineTransformMatrix2DTest {
@Test
public void testInverse_nonInvertible() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix2D.of(
0, 0, 0,
0, 0, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is 0.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix2D.of(
1, 0, 0,
0, Double.NaN, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix2D.of(
1, 0, 0,
0, Double.NEGATIVE_INFINITY, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is -Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix2D.of(
Double.POSITIVE_INFINITY, 0, 0,
0, 1, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; matrix determinant is Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix2D.of(
1, 0, Double.NaN,
0, 1, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix2D.of(
1, 0, Double.POSITIVE_INFINITY,
0, 1, 0).inverse();
}, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
AffineTransformMatrix2D.of(
1, 0, Double.NEGATIVE_INFINITY,
0, 1, 0).inverse();
@@ -1130,9 +1127,7 @@ public class AffineTransformMatrix2DTest {
@Test
public void testNormalTransform_nonInvertible() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- AffineTransformMatrix2D.createScale(0).normalTransform();
- }, IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> AffineTransformMatrix2D.createScale(0).normalTransform());
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Bounds2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Bounds2DTest.java
index 4695dcc..b36ac2f 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Bounds2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Bounds2DTest.java
@@ -31,6 +31,7 @@ import org.apache.commons.geometry.euclidean.twod.shape.Parallelogram;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class Bounds2DTest {
private static final double TEST_EPS = 1e-10;
@@ -110,7 +111,7 @@ public class Bounds2DTest {
@Test
public void testFrom_iterable_noPoints() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds2D.from(new ArrayList<>());
}, IllegalStateException.class, NO_POINTS_MESSAGE);
}
@@ -125,27 +126,27 @@ public class Bounds2DTest {
final Vector2D negInf = Vector2D.of(1, Double.NEGATIVE_INFINITY);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds2D.from(Vector2D.NaN);
}, IllegalStateException.class, INVALID_BOUNDS_PATTERN);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds2D.from(Vector2D.POSITIVE_INFINITY);
}, IllegalStateException.class, INVALID_BOUNDS_PATTERN);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds2D.from(Vector2D.NEGATIVE_INFINITY);
}, IllegalStateException.class, INVALID_BOUNDS_PATTERN);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds2D.from(good, nan);
}, IllegalStateException.class, INVALID_BOUNDS_PATTERN);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds2D.from(posInf, good);
}, IllegalStateException.class, INVALID_BOUNDS_PATTERN);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Bounds2D.from(good, negInf, good);
}, IllegalStateException.class, INVALID_BOUNDS_PATTERN);
}
@@ -353,10 +354,7 @@ public class Bounds2DTest {
@Test
public void toRegion_boundingBoxTooSmall() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Bounds2D.from(Vector2D.ZERO, Vector2D.of(1e-12, 1e-12))
- .toRegion(TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Bounds2D.from(Vector2D.ZERO, Vector2D.of(1e-12, 1e-12)).toRegion(TEST_PRECISION));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java
index 2806eb1..634c60c 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java
@@ -35,6 +35,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class ConvexAreaTest {
private static final double TEST_EPS = 1e-10;
@@ -864,28 +865,28 @@ public class ConvexAreaTest {
Pattern.compile("Unable to create line path; only a single unique vertex provided.*");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromVertices(Collections.emptyList(), precision);
}, IllegalArgumentException.class, unclosedPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromVertices(Collections.singletonList(Vector2D.ZERO), precision);
}, IllegalStateException.class, singleVertexPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromVertices(Arrays.asList(Vector2D.ZERO, Vector2D.of(1e-4, 1e-4)), precision);
}, IllegalStateException.class, singleVertexPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromVertices(Arrays.asList(Vector2D.ZERO, Vector2D.Unit.PLUS_X), precision);
}, IllegalArgumentException.class, notEnoughElementsPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromVertices(
Arrays.asList(Vector2D.ZERO, Vector2D.Unit.PLUS_X, Vector2D.of(1, 1e-4)), precision);
}, IllegalArgumentException.class, notEnoughElementsPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromVertices(
Arrays.asList(Vector2D.ZERO, Vector2D.Unit.PLUS_X, Vector2D.of(1, -1)), precision);
}, IllegalArgumentException.class, nonConvexPattern);
@@ -1002,19 +1003,19 @@ public class ConvexAreaTest {
final Pattern msgPattern = Pattern.compile("Cannot construct convex polygon from non-convex path.*");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromVertices(Arrays.asList(
Vector2D.ZERO, Vector2D.of(1, 0), Vector2D.of(2, 0)
), TEST_PRECISION);
}, IllegalArgumentException.class, msgPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromVertices(Arrays.asList(
Vector2D.ZERO, Vector2D.of(1, 0), Vector2D.of(1, -1)
), TEST_PRECISION);
}, IllegalArgumentException.class, msgPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromVertices(
Arrays.asList(
Vector2D.ZERO,
@@ -1024,7 +1025,7 @@ public class ConvexAreaTest {
), TEST_PRECISION);
}, IllegalArgumentException.class, msgPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromVertices(Arrays.asList(
Vector2D.ZERO, Vector2D.of(2, 0),
Vector2D.of(2, 2), Vector2D.of(1, 1),
@@ -1042,21 +1043,21 @@ public class ConvexAreaTest {
final Pattern nonConvexPattern = Pattern.compile("Cannot construct convex polygon from non-convex path.*");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromPath(LinePath.empty());
}, IllegalArgumentException.class, unclosedPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromPath(LinePath.fromVertices(
Arrays.asList(Vector2D.ZERO, Vector2D.Unit.PLUS_X), TEST_PRECISION));
}, IllegalArgumentException.class, unclosedPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromPath(LinePath.fromVertices(
Arrays.asList(Vector2D.ZERO, Vector2D.Unit.PLUS_X, Vector2D.ZERO), TEST_PRECISION));
}, IllegalArgumentException.class, notEnoughElementsPattern);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
ConvexArea.convexPolygonFromPath(LinePath.fromVertexLoop(
Arrays.asList(
Vector2D.ZERO,
@@ -1280,21 +1281,17 @@ public class ConvexAreaTest {
final Line c = Lines.fromPointAndAngle(Vector2D.of(0, 1), 0.0, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- ConvexArea.fromBounds(a, b, c);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> ConvexArea.fromBounds(a, b, c));
}
@Test
public void testFromBounds_boundsDoNotProduceAConvexRegion() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- ConvexArea.fromBounds(Arrays.asList(
- Lines.fromPointAndAngle(Vector2D.ZERO, 0.0, TEST_PRECISION),
- Lines.fromPointAndAngle(Vector2D.of(0, -1), PlaneAngleRadians.PI, TEST_PRECISION),
- Lines.fromPointAndAngle(Vector2D.ZERO, PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)
- ));
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> ConvexArea.fromBounds(Arrays.asList(
+ Lines.fromPointAndAngle(Vector2D.ZERO, 0.0, TEST_PRECISION),
+ Lines.fromPointAndAngle(Vector2D.of(0, -1), PlaneAngleRadians.PI, TEST_PRECISION),
+ Lines.fromPointAndAngle(Vector2D.ZERO, PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)
+ )));
}
private static List<Line> createSquareBoundingLines(final Vector2D lowerLeft, final double width, final double height) {
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubsetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubsetTest.java
index ebc386c..cdf5704 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubsetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubsetTest.java
@@ -30,6 +30,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class EmbeddedTreeLineSubsetTest {
private static final double TEST_EPS = 1e-10;
@@ -229,13 +230,8 @@ public class EmbeddedTreeLineSubsetTest {
final EmbeddedTreeLineSubset subset = new EmbeddedTreeLineSubset(line);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- subset.add(Lines.subsetFromInterval(otherLine, 0, 1));
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- subset.add(new EmbeddedTreeLineSubset(otherLine));
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> subset.add(Lines.subsetFromInterval(otherLine, 0, 1)));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> subset.add(new EmbeddedTreeLineSubset(otherLine)));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineConvexSubsetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineConvexSubsetTest.java
index f982972..cdcb3a7 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineConvexSubsetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineConvexSubsetTest.java
@@ -200,27 +200,27 @@ public class LineConvexSubsetTest {
final Line line = Lines.fromPointAndAngle(Vector2D.ZERO, 0, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.subsetFromInterval(line, 0, Double.NaN);
}, IllegalArgumentException.class, "Invalid line subset interval: 0.0, NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.subsetFromInterval(line, Double.NaN, 0.0);
}, IllegalArgumentException.class, "Invalid line subset interval: NaN, 0.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.subsetFromInterval(line, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid line subset interval: Infinity, Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.subsetFromInterval(line, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid line subset interval: -Infinity, -Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.subsetFromInterval(line, Double.POSITIVE_INFINITY, Double.NaN);
}, IllegalArgumentException.class, "Invalid line subset interval: Infinity, NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.subsetFromInterval(line, Double.NaN, Double.NEGATIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid line subset interval: NaN, -Infinity");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java
index 4e5a75c..4272042 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java
@@ -55,9 +55,9 @@ public class LineTest {
@Test
public void testFromPoints_pointsTooClose() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Lines.fromPoints(Vector2D.Unit.PLUS_X, Vector2D.Unit.PLUS_X, TEST_PRECISION),
+ GeometryTestUtils.assertThrowsWithMessage(() -> Lines.fromPoints(Vector2D.Unit.PLUS_X, Vector2D.Unit.PLUS_X, TEST_PRECISION),
IllegalArgumentException.class, "Line direction cannot be zero");
- GeometryTestUtils.assertThrows(() -> Lines.fromPoints(Vector2D.Unit.PLUS_X, Vector2D.of(1 + 1e-11, 1e-11), TEST_PRECISION),
+ GeometryTestUtils.assertThrowsWithMessage(() -> Lines.fromPoints(Vector2D.Unit.PLUS_X, Vector2D.of(1 + 1e-11, 1e-11), TEST_PRECISION),
IllegalArgumentException.class, "Line direction cannot be zero");
}
@@ -80,9 +80,9 @@ public class LineTest {
@Test
public void testFromPointAndDirection_directionIsZero() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Lines.fromPointAndDirection(Vector2D.Unit.PLUS_X, Vector2D.ZERO, TEST_PRECISION),
+ GeometryTestUtils.assertThrowsWithMessage(() -> Lines.fromPointAndDirection(Vector2D.Unit.PLUS_X, Vector2D.ZERO, TEST_PRECISION),
IllegalArgumentException.class, "Line direction cannot be zero");
- GeometryTestUtils.assertThrows(() -> Lines.fromPointAndDirection(Vector2D.Unit.PLUS_X, Vector2D.of(1e-11, -1e-12), TEST_PRECISION),
+ GeometryTestUtils.assertThrowsWithMessage(() -> Lines.fromPointAndDirection(Vector2D.Unit.PLUS_X, Vector2D.of(1e-11, -1e-12), TEST_PRECISION),
IllegalArgumentException.class, "Line direction cannot be zero");
}
@@ -1064,7 +1064,7 @@ public class LineTest {
final Line line = Lines.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
line.transform(scaleCollapse);
}, IllegalArgumentException.class, "Line direction cannot be zero");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolarCoordinatesTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolarCoordinatesTest.java
index 985515d..a5e9be9 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolarCoordinatesTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolarCoordinatesTest.java
@@ -23,7 +23,6 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertThrows;
public class PolarCoordinatesTest {
@@ -351,7 +350,7 @@ public class PolarCoordinatesTest {
@Test
public void testParse_failure() {
// act/assert
- assertThrows(IllegalArgumentException.class, () -> PolarCoordinates.parse("abc"));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> PolarCoordinates.parse("abc"));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RayTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RayTest.java
index efe209c..da33dd6 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RayTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RayTest.java
@@ -69,7 +69,7 @@ public class RayTest {
final Vector2D d = Vector2D.of(1e-17, -1e-12);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.rayFromPointAndDirection(p, d, TEST_PRECISION);
}, IllegalArgumentException.class, "Line direction cannot be zero");
}
@@ -113,15 +113,15 @@ public class RayTest {
final Line line = Lines.fromPointAndDirection(p, d, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.rayFromPoint(line, Vector2D.NaN);
}, IllegalArgumentException.class, "Invalid ray start point: (NaN, NaN)");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.rayFromPoint(line, Vector2D.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid ray start point: (Infinity, Infinity)");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.rayFromPoint(line, Vector2D.NEGATIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid ray start point: (-Infinity, -Infinity)");
}
@@ -164,15 +164,15 @@ public class RayTest {
final Line line = Lines.fromPointAndDirection(p, d, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.rayFromLocation(line, Double.NaN);
}, IllegalArgumentException.class, "Invalid ray start location: NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.rayFromLocation(line, Double.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid ray start location: Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.rayFromLocation(line, Double.NEGATIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid ray start location: -Infinity");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java
index 70d8ae1..341476f 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java
@@ -40,6 +40,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class RegionBSPTree2DTest {
private static final double TEST_EPS = 1e-10;
@@ -244,19 +245,19 @@ public class RegionBSPTree2DTest {
final String msg = "Cannot insert partitions after boundaries have been inserted";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.insertPartition(partition);
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.insertPartition(partition.span());
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.insertAxisAlignedPartitions(Vector2D.ZERO, TEST_PRECISION);
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.insertAxisAlignedGrid(Bounds2D.from(Vector2D.ZERO, Vector2D.of(1, 1)), 1, TEST_PRECISION);
}, IllegalStateException.class, msg);
}
@@ -388,9 +389,7 @@ public class RegionBSPTree2DTest {
tree.insert(Lines.segmentFromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION));
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- tree.getBoundaryPaths().add(LinePath.builder(null).build());
- }, UnsupportedOperationException.class);
+ Assertions.assertThrows(UnsupportedOperationException.class, () -> tree.getBoundaryPaths().add(LinePath.builder(null).build()));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ReverseRayTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ReverseRayTest.java
index 48c6f52..c3c0994 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ReverseRayTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ReverseRayTest.java
@@ -67,7 +67,7 @@ public class ReverseRayTest {
final Vector2D d = Vector2D.of(1e-17, -1e-12);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.reverseRayFromPointAndDirection(p, d, TEST_PRECISION);
}, IllegalArgumentException.class, "Line direction cannot be zero");
}
@@ -109,15 +109,15 @@ public class ReverseRayTest {
final Line line = Lines.fromPointAndDirection(p, d, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.reverseRayFromPoint(line, Vector2D.NaN);
}, IllegalArgumentException.class, "Invalid reverse ray end point: (NaN, NaN)");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.reverseRayFromPoint(line, Vector2D.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid reverse ray end point: (Infinity, Infinity)");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.reverseRayFromPoint(line, Vector2D.NEGATIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid reverse ray end point: (-Infinity, -Infinity)");
}
@@ -158,15 +158,15 @@ public class ReverseRayTest {
final Line line = Lines.fromPointAndDirection(p, d, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.reverseRayFromLocation(line, Double.NaN);
}, IllegalArgumentException.class, "Invalid reverse ray end location: NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.reverseRayFromLocation(line, Double.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid reverse ray end location: Infinity");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.reverseRayFromLocation(line, Double.NEGATIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid reverse ray end location: -Infinity");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java
index 90ae6be..424541c 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java
@@ -66,11 +66,11 @@ public class SegmentTest {
final Vector2D p2 = Vector2D.of(1e-17, 2);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.segmentFromPoints(p1, p1, TEST_PRECISION);
}, IllegalArgumentException.class, "Line direction cannot be zero");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.segmentFromPoints(p1, p2, TEST_PRECISION);
}, IllegalArgumentException.class, "Line direction cannot be zero");
}
@@ -137,19 +137,19 @@ public class SegmentTest {
final Line line = Lines.fromPointAndAngle(Vector2D.ZERO, 0, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.segmentFromPoints(line, Vector2D.NaN, p1);
}, IllegalArgumentException.class, "Invalid line segment locations: NaN, 2.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.segmentFromPoints(line, p0, Vector2D.NaN);
}, IllegalArgumentException.class, "Invalid line segment locations: 1.0, NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.segmentFromPoints(line, Vector2D.NEGATIVE_INFINITY, p1);
}, IllegalArgumentException.class, "Invalid line segment locations: NaN, 2.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.segmentFromPoints(line, p0, Vector2D.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid line segment locations: 1.0, NaN");
}
@@ -232,19 +232,19 @@ public class SegmentTest {
final Line line = Lines.fromPointAndAngle(Vector2D.ZERO, 0, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.segmentFromLocations(line, Double.NaN, 2);
}, IllegalArgumentException.class, "Invalid line segment locations: NaN, 2.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.segmentFromLocations(line, 1, Double.NaN);
}, IllegalArgumentException.class, "Invalid line segment locations: 1.0, NaN");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.segmentFromLocations(line, Double.NEGATIVE_INFINITY, 2);
}, IllegalArgumentException.class, "Invalid line segment locations: -Infinity, 2.0");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Lines.segmentFromLocations(line, 1, Double.POSITIVE_INFINITY);
}, IllegalArgumentException.class, "Invalid line segment locations: 1.0, Infinity");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
index 5f3b500..4231fec 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
@@ -31,7 +31,6 @@ import org.apache.commons.numbers.core.Precision;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertThrows;
public class Vector2DTest {
@@ -53,10 +52,10 @@ public class Vector2DTest {
@Test
public void testConstants_normalize() {
// act/assert
- GeometryTestUtils.assertThrows(Vector2D.ZERO::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector2D.NaN::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector2D.POSITIVE_INFINITY::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector2D.NEGATIVE_INFINITY::normalize, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector2D.ZERO::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector2D.NaN::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector2D.POSITIVE_INFINITY::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector2D.NEGATIVE_INFINITY::normalize);
Assertions.assertSame(Vector2D.Unit.PLUS_X, Vector2D.Unit.PLUS_X.normalize());
Assertions.assertSame(Vector2D.Unit.MINUS_X, Vector2D.Unit.MINUS_X.normalize());
@@ -228,14 +227,10 @@ public class Vector2DTest {
@Test
public void testWithNorm_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.withNorm(2.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.NaN.withNorm(2.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.POSITIVE_INFINITY.withNorm(2.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.withNorm(2.0),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.ZERO.withNorm(2.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.NaN.withNorm(2.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.POSITIVE_INFINITY.withNorm(2.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.NEGATIVE_INFINITY.withNorm(2.0));
}
@Test
@@ -334,10 +329,10 @@ public class Vector2DTest {
@Test
public void testNormalize_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(Vector2D.ZERO::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector2D.NaN::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector2D.POSITIVE_INFINITY::normalize, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector2D.NEGATIVE_INFINITY::normalize, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector2D.ZERO::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector2D.NaN::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector2D.POSITIVE_INFINITY::normalize);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector2D.NEGATIVE_INFINITY::normalize);
}
@Test
@@ -479,10 +474,10 @@ public class Vector2DTest {
@Test
public void testOrthogonal_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(Vector2D.ZERO::orthogonal, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector2D.NaN::orthogonal, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector2D.POSITIVE_INFINITY::orthogonal, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(Vector2D.NEGATIVE_INFINITY::orthogonal, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector2D.ZERO::orthogonal);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector2D.NaN::orthogonal);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector2D.POSITIVE_INFINITY::orthogonal);
+ Assertions.assertThrows(IllegalArgumentException.class, Vector2D.NEGATIVE_INFINITY::orthogonal);
}
@Test
@@ -501,36 +496,23 @@ public class Vector2DTest {
@Test
public void testOrthogonal_givenDirection_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.orthogonal(Vector2D.Unit.PLUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.NaN.orthogonal(Vector2D.Unit.PLUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.POSITIVE_INFINITY.orthogonal(Vector2D.Unit.PLUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.orthogonal(Vector2D.Unit.PLUS_X),
- IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.ZERO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.ZERO.orthogonal(Vector2D.Unit.PLUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.NaN.orthogonal(Vector2D.Unit.PLUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.POSITIVE_INFINITY.orthogonal(Vector2D.Unit.PLUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.NEGATIVE_INFINITY.orthogonal(Vector2D.Unit.PLUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.NaN));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.POSITIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.NEGATIVE_INFINITY));
}
@Test
public void testOrthogonal_givenDirection_directionIsCollinear() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.Unit.PLUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.Unit.MINUS_X),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.of(1.0, 1.0).orthogonal(Vector2D.of(2.0, 2.0)),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.of(-1.01, -1.01).orthogonal(Vector2D.of(20.1, 20.1)),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.Unit.PLUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.Unit.MINUS_X));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.of(1.0, 1.0).orthogonal(Vector2D.of(2.0, 2.0)));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.of(-1.01, -1.01).orthogonal(Vector2D.of(20.1, 20.1)));
}
@Test
@@ -555,23 +537,14 @@ public class Vector2DTest {
final Vector2D v = Vector2D.of(1.0, 1.0);
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.angle(v),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.NaN.angle(v),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.POSITIVE_INFINITY.angle(v),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.angle(v),
- IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> v.angle(Vector2D.ZERO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.angle(Vector2D.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.angle(Vector2D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.angle(Vector2D.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.ZERO.angle(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.NaN.angle(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.POSITIVE_INFINITY.angle(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.NEGATIVE_INFINITY.angle(v));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.angle(Vector2D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.angle(Vector2D.NaN));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.angle(Vector2D.POSITIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.angle(Vector2D.NEGATIVE_INFINITY));
}
@Test
@@ -644,14 +617,10 @@ public class Vector2DTest {
final Vector2D v = Vector2D.of(1.0, 1.0);
// act/assert
- GeometryTestUtils.assertThrows(() -> v.project(Vector2D.ZERO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.project(Vector2D.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.project(Vector2D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.project(Vector2D.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.project(Vector2D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.project(Vector2D.NaN));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.project(Vector2D.POSITIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.project(Vector2D.NEGATIVE_INFINITY));
}
@Test
@@ -681,14 +650,10 @@ public class Vector2DTest {
final Vector2D v = Vector2D.of(1.0, 1.0);
// act/assert
- GeometryTestUtils.assertThrows(() -> v.reject(Vector2D.ZERO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.reject(Vector2D.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.reject(Vector2D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> v.reject(Vector2D.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.reject(Vector2D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.reject(Vector2D.NaN));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.reject(Vector2D.POSITIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> v.reject(Vector2D.NEGATIVE_INFINITY));
}
@Test
@@ -775,16 +740,11 @@ public class Vector2DTest {
final Vector2D p = Vector2D.of(1, 2);
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.directionTo(Vector2D.ZERO),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> p.directionTo(p),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> p.directionTo(Vector2D.NaN),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.directionTo(p),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> p.directionTo(Vector2D.POSITIVE_INFINITY),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.ZERO.directionTo(Vector2D.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> p.directionTo(p));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> p.directionTo(Vector2D.NaN));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.NEGATIVE_INFINITY.directionTo(p));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> p.directionTo(Vector2D.POSITIVE_INFINITY));
}
@Test
@@ -965,7 +925,7 @@ public class Vector2DTest {
@Test
public void testParse_failure() {
// act/assert
- assertThrows(IllegalArgumentException.class, () -> Vector2D.parse("abc"));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.parse("abc"));
}
@Test
@@ -989,7 +949,7 @@ public class Vector2DTest {
@Test
public void testOf_arrayArg_invalidDimensions() {
// act/assert
- assertThrows(IllegalArgumentException.class, () -> Vector2D.of(new double[] {0.0}));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.of(new double[] {0.0}));
}
@Test
@@ -1016,14 +976,11 @@ public class Vector2DTest {
@Test
public void testUnitFrom_illegalNorm() {
- GeometryTestUtils.assertThrows(() -> Vector2D.Unit.from(0.0, 0.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.Unit.from(Double.NaN, 1.0),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.Unit.from(1.0, Double.NEGATIVE_INFINITY),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.Unit.from(1.0, Double.POSITIVE_INFINITY),
- IllegalArgumentException.class);
+
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.Unit.from(0.0, 0.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.Unit.from(Double.NaN, 1.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.Unit.from(1.0, Double.NEGATIVE_INFINITY));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Vector2D.Unit.from(1.0, Double.POSITIVE_INFINITY));
}
@Test
@@ -1045,7 +1002,7 @@ public class Vector2DTest {
final String msg = "Cannot compute vector max: no vectors given";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Vector2D.max(new ArrayList<>());
}, IllegalArgumentException.class, msg);
}
@@ -1069,7 +1026,7 @@ public class Vector2DTest {
final String msg = "Cannot compute vector min: no vectors given";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Vector2D.min(new ArrayList<>());
}, IllegalArgumentException.class, msg);
}
@@ -1098,7 +1055,7 @@ public class Vector2DTest {
final String msg = "Cannot compute centroid: no points given";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
Vector2D.centroid(new ArrayList<>());
}, IllegalArgumentException.class, msg);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/path/LinePathTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/path/LinePathTest.java
index a482a2a..a492dd3 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/path/LinePathTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/path/LinePathTest.java
@@ -43,6 +43,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class LinePathTest {
private static final double TEST_EPS = 1e-10;
@@ -282,17 +283,9 @@ public class LinePathTest {
final LineConvexSubset d = Lines.fromPointAndAngle(Vector2D.of(1, 0), PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION).span();
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- LinePath.from(a, b);
- }, IllegalStateException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- LinePath.from(c, b);
- }, IllegalStateException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- LinePath.from(a, d);
- }, IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> LinePath.from(a, b));
+ Assertions.assertThrows(IllegalStateException.class, () -> LinePath.from(c, b));
+ Assertions.assertThrows(IllegalStateException.class, () -> LinePath.from(a, d));
}
@Test
@@ -317,9 +310,7 @@ public class LinePathTest {
@Test
public void testFromVertices_singleVertex_failsToCreatePath() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- LinePath.fromVertices(Collections.singletonList(Vector2D.ZERO), TEST_PRECISION);
- }, IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> LinePath.fromVertices(Collections.singletonList(Vector2D.ZERO), TEST_PRECISION));
}
@Test
@@ -428,9 +419,7 @@ public class LinePathTest {
@Test
public void testFromVertexLoop_singleVertex_failsToCreatePath() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- LinePath.fromVertexLoop(Collections.singletonList(Vector2D.ZERO), TEST_PRECISION);
- }, IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> LinePath.fromVertexLoop(Collections.singletonList(Vector2D.ZERO), TEST_PRECISION));
}
@Test
@@ -526,9 +515,7 @@ public class LinePathTest {
Assertions.assertNotSame(inputSegments, path.getElements());
Assertions.assertEquals(1, path.getElements().size());
- GeometryTestUtils.assertThrows(() -> {
- path.getElements().add(a);
- }, UnsupportedOperationException.class);
+ Assertions.assertThrows(UnsupportedOperationException.class, () -> path.getElements().add(a));
}
@Test
@@ -1052,13 +1039,8 @@ public class LinePathTest {
builder.append(a);
// act
- GeometryTestUtils.assertThrows(() -> {
- builder.append(a);
- }, IllegalStateException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- builder.prepend(a);
- }, IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> builder.append(a));
+ Assertions.assertThrows(IllegalStateException.class, () -> builder.prepend(a));
}
@Test
@@ -1098,11 +1080,11 @@ public class LinePathTest {
final String msg = "Unable to create line segment: no vertex precision specified";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.append(p);
}, IllegalStateException.class, msg);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
builder.prepend(p);
}, IllegalStateException.class, msg);
}
@@ -1116,13 +1098,8 @@ public class LinePathTest {
builder.append(Lines.fromPointAndAngle(Vector2D.ZERO, 0.0, TEST_PRECISION).span());
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- builder.append(p);
- }, IllegalStateException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- builder.prepend(p);
- }, IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> builder.prepend(p));
+ Assertions.assertThrows(IllegalStateException.class, () -> builder.prepend(p));
}
@Test
@@ -1289,7 +1266,7 @@ public class LinePathTest {
.append(Vector2D.of(1, 1));
// act/assert
- GeometryTestUtils.assertThrows(builder::close, IllegalStateException.class,
+ GeometryTestUtils.assertThrowsWithMessage(builder::close, IllegalStateException.class,
"Unable to close line path: line path is infinite");
}
@@ -1305,7 +1282,7 @@ public class LinePathTest {
.rayFrom(0));
// act/assert
- GeometryTestUtils.assertThrows(builder::close, IllegalStateException.class,
+ GeometryTestUtils.assertThrowsWithMessage(builder::close, IllegalStateException.class,
"Unable to close line path: line path is infinite");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/rotation/Rotation2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/rotation/Rotation2DTest.java
index 060c522..84c34f4 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/rotation/Rotation2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/rotation/Rotation2DTest.java
@@ -32,6 +32,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class Rotation2DTest {
private static final double TEST_EPS = 1e-10;
@@ -177,33 +178,14 @@ public class Rotation2DTest {
final Vector2D negInf = Vector2D.POSITIVE_INFINITY;
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Rotation2D.createVectorRotation(zero, vec);
- }, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> {
- Rotation2D.createVectorRotation(vec, zero);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Rotation2D.createVectorRotation(nan, vec);
- }, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> {
- Rotation2D.createVectorRotation(vec, nan);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Rotation2D.createVectorRotation(posInf, vec);
- }, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> {
- Rotation2D.createVectorRotation(vec, negInf);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Rotation2D.createVectorRotation(zero, nan);
- }, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> {
- Rotation2D.createVectorRotation(negInf, posInf);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Rotation2D.createVectorRotation(zero, vec));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Rotation2D.createVectorRotation(vec, zero));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Rotation2D.createVectorRotation(nan, vec));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Rotation2D.createVectorRotation(vec, nan));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Rotation2D.createVectorRotation(posInf, vec));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Rotation2D.createVectorRotation(vec, negInf));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Rotation2D.createVectorRotation(zero, nan));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Rotation2D.createVectorRotation(negInf, posInf));
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/CircleTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/CircleTest.java
index 9cfe4c5..4b54709 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/CircleTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/CircleTest.java
@@ -37,6 +37,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class CircleTest {
private static final double TEST_EPS = 1e-10;
@@ -72,10 +73,8 @@ public class CircleTest {
@Test
public void testFrom_illegalCenter() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Circle.from(Vector2D.of(Double.POSITIVE_INFINITY, 1), 1, TEST_PRECISION),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Circle.from(Vector2D.of(Double.NaN, 1), 1, TEST_PRECISION),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Circle.from(Vector2D.of(Double.POSITIVE_INFINITY, 1), 1, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Circle.from(Vector2D.of(Double.NaN, 1), 1, TEST_PRECISION));
}
@Test
@@ -84,17 +83,11 @@ public class CircleTest {
final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-2);
// act/assert
- GeometryTestUtils.assertThrows(() -> Circle.from(Vector2D.ZERO, -1, TEST_PRECISION),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Circle.from(Vector2D.ZERO, 0, TEST_PRECISION),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Circle.from(Vector2D.ZERO, Double.POSITIVE_INFINITY, TEST_PRECISION),
- IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> Circle.from(Vector2D.ZERO, Double.NaN, TEST_PRECISION),
- IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> Circle.from(Vector2D.ZERO, 1e-3, precision),
- IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Circle.from(Vector2D.ZERO, -1, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Circle.from(Vector2D.ZERO, 0, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Circle.from(Vector2D.ZERO, Double.POSITIVE_INFINITY, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Circle.from(Vector2D.ZERO, Double.NaN, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Circle.from(Vector2D.ZERO, 1e-3, precision));
}
@Test
@@ -382,10 +375,10 @@ public class CircleTest {
final String baseMsg = "Circle approximation segment number must be greater than or equal to 3; was ";
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
c.toTree(2);
}, IllegalArgumentException.class, baseMsg + "2");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
c.toTree(-1);
}, IllegalArgumentException.class, baseMsg + "-1");
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/ParallelogramTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/ParallelogramTest.java
index fbc7c23..d151acd 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/ParallelogramTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/ParallelogramTest.java
@@ -18,7 +18,6 @@ package org.apache.commons.geometry.euclidean.twod.shape;
import java.util.List;
-import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.EuclideanTestUtils;
@@ -31,6 +30,7 @@ import org.apache.commons.geometry.euclidean.twod.rotation.Rotation2D;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class ParallelogramTest {
private static final double TEST_EPS = 1e-10;
@@ -111,15 +111,11 @@ public class ParallelogramTest {
@Test
public void testFromTransformedUnitSquare_zeroSizeRegion() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Parallelogram.fromTransformedUnitSquare(AffineTransformMatrix2D.createScale(Vector2D.of(1e-16, 1)),
- TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Parallelogram.fromTransformedUnitSquare(AffineTransformMatrix2D.createScale(Vector2D.of(1, 1e-16)),
- TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Parallelogram.fromTransformedUnitSquare(AffineTransformMatrix2D.createScale(Vector2D.of(1e-16, 1)),
+ TEST_PRECISION));
+
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Parallelogram.fromTransformedUnitSquare(AffineTransformMatrix2D.createScale(Vector2D.of(1, 1e-16)),
+ TEST_PRECISION));
}
@Test
@@ -161,17 +157,10 @@ public class ParallelogramTest {
@Test
public void testAxisAligned_illegalArgs() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Parallelogram.axisAligned(Vector2D.of(1, 1), Vector2D.of(1, 3), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Parallelogram.axisAligned(Vector2D.of(1, 1), Vector2D.of(3, 1), TEST_PRECISION);
- }, IllegalArgumentException.class);
- GeometryTestUtils.assertThrows(() -> {
- Parallelogram.axisAligned(Vector2D.of(2, 3), Vector2D.of(2, 3), TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Parallelogram.axisAligned(Vector2D.of(1, 1), Vector2D.of(1, 3), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Parallelogram.axisAligned(Vector2D.of(1, 1), Vector2D.of(3, 1), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Parallelogram.axisAligned(Vector2D.of(2, 3), Vector2D.of(2, 3), TEST_PRECISION));
}
@Test
diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOHandlerRegistryTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOHandlerRegistryTest.java
index d687868..dcb8fd1 100644
--- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOHandlerRegistryTest.java
+++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOHandlerRegistryTest.java
@@ -138,7 +138,7 @@ public class ModelIOHandlerRegistryTest {
final File file = new File("file.B");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
registry.read(file, TEST_PRECISION);
}, IllegalArgumentException.class, "No handler found for type \"b\"");
}
@@ -149,7 +149,7 @@ public class ModelIOHandlerRegistryTest {
final File file = new File("file");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
registry.read(file, TEST_PRECISION);
}, IllegalArgumentException.class,
"Cannot determine target file type: \"file\" does not have a file extension");
@@ -176,7 +176,7 @@ public class ModelIOHandlerRegistryTest {
final File file = new File("file");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
registry.read("nope", file, TEST_PRECISION);
}, IllegalArgumentException.class, "No handler found for type \"nope\"");
}
@@ -199,7 +199,7 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testRead_typeAndInputStream_unknownType() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
registry.read("nope", new ByteArrayInputStream(new byte[0]), TEST_PRECISION);
}, IllegalArgumentException.class, "No handler found for type \"nope\"");
}
@@ -228,7 +228,7 @@ public class ModelIOHandlerRegistryTest {
final File file = new File("file.B");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
registry.write(SRC_A, file);
}, IllegalArgumentException.class, "No handler found for type \"b\"");
}
@@ -239,7 +239,7 @@ public class ModelIOHandlerRegistryTest {
final File file = new File("file");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
registry.write(SRC_A, file);
}, IllegalArgumentException.class,
"Cannot determine target file type: \"file\" does not have a file extension");
@@ -269,7 +269,7 @@ public class ModelIOHandlerRegistryTest {
final File file = new File("file");
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
registry.write(SRC_A, "nope", file);
}, IllegalArgumentException.class, "No handler found for type \"nope\"");
}
@@ -293,7 +293,7 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testWrite_typeAndOutputStream_unknownType() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
registry.write(SRC_A, "nope", new ByteArrayOutputStream());
}, IllegalArgumentException.class, "No handler found for type \"nope\"");
}
diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJModelIOHandlerTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJModelIOHandlerTest.java
index 40020b1..5c2513e 100644
--- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJModelIOHandlerTest.java
+++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJModelIOHandlerTest.java
@@ -86,7 +86,7 @@ public class OBJModelIOHandlerTest {
final File file = cubeMinusSphereFile();
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
handler.read("stl", file, TEST_PRECISION);
}, IllegalArgumentException.class, "File type is not supported by this handler: stl");
}
@@ -123,7 +123,7 @@ public class OBJModelIOHandlerTest {
// act/assert
try (InputStream in = Files.newInputStream(file.toPath())) {
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
handler.read("stl", in, TEST_PRECISION);
}, IllegalArgumentException.class, "File type is not supported by this handler: stl");
}
@@ -132,7 +132,7 @@ public class OBJModelIOHandlerTest {
@Test
public void testRead_fromStream_ioException() throws Exception {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
handler.read("obj", new FailingInputStream(), TEST_PRECISION);
}, UncheckedIOException.class, "IOException: test");
}
@@ -164,7 +164,7 @@ public class OBJModelIOHandlerTest {
);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
handler.write(src, "stl", out);
}, IllegalArgumentException.class, "File type is not supported by this handler: stl");
}
@@ -212,7 +212,7 @@ public class OBJModelIOHandlerTest {
// act/assert
try (OutputStream out = Files.newOutputStream(file.toPath())) {
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
handler.write(src, "stl", out);
}, IllegalArgumentException.class, "File type is not supported by this handler: stl");
}
@@ -226,7 +226,7 @@ public class OBJModelIOHandlerTest {
);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
handler.write(src, "OBJ", new FailingOutputStream());
}, UncheckedIOException.class, "IOException: test");
}
diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJReaderTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJReaderTest.java
index 195d0ee..95fd42e 100644
--- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJReaderTest.java
+++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJReaderTest.java
@@ -171,7 +171,7 @@ public class OBJReaderTest {
}
}, NumberFormatException.class);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
try {
reader.readTriangleMesh(new StringReader(notEnoughVertices), TEST_PRECISION);
} catch (final IOException exc) {
@@ -204,7 +204,7 @@ public class OBJReaderTest {
}
}, NumberFormatException.class);
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
try {
reader.readTriangleMesh(new StringReader(notEnoughIndices), TEST_PRECISION);
} catch (final IOException exc) {
diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJWriterTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJWriterTest.java
index 6c440c1..d3b86db 100644
--- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJWriterTest.java
+++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJWriterTest.java
@@ -208,7 +208,7 @@ public class OBJWriterTest {
final StringWriter writer = new StringWriter();
// act
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
try (OBJWriter meshWriter = new OBJWriter(writer)) {
meshWriter.writeFace(1, 2);
} catch (final IOException exc) {
@@ -305,7 +305,7 @@ public class OBJWriterTest {
final StringWriter writer = new StringWriter();
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
try (OBJWriter meshWriter = new OBJWriter(writer)) {
meshWriter.writeBoundaries(src);
} catch (final IOException exc) {
diff --git a/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/ConvexHull2DTest.java b/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/ConvexHull2DTest.java
index 87950b0..937f25b 100644
--- a/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/ConvexHull2DTest.java
+++ b/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/ConvexHull2DTest.java
@@ -30,6 +30,7 @@ import org.apache.commons.geometry.euclidean.twod.path.LinePath;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class ConvexHull2DTest {
private static final double TEST_EPS = 1e-10;
@@ -159,9 +160,8 @@ public class ConvexHull2DTest {
// assert
Assertions.assertNotSame(vertices, hullVertices);
- GeometryTestUtils.assertThrows(() -> {
- hullVertices.add(Vector2D.Unit.PLUS_Y);
- }, UnsupportedOperationException.class);
+
+ Assertions.assertThrows(UnsupportedOperationException.class, () -> hullVertices.add(Vector2D.Unit.PLUS_Y));
}
@Test
diff --git a/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/MonotoneChainTest.java b/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/MonotoneChainTest.java
index 3b10f81..a13c52d 100644
--- a/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/MonotoneChainTest.java
+++ b/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/MonotoneChainTest.java
@@ -21,9 +21,9 @@ import java.util.Collection;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.apache.commons.geometry.euclidean.twod.Vector2D;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Test class for MonotoneChain.
@@ -52,6 +52,6 @@ public class MonotoneChainTest extends ConvexHullGenerator2DAbstractTest {
points.add(Vector2D.of(40, 1));
// act/assert
- assertThrows(IllegalStateException.class, () -> new MonotoneChain(true, new EpsilonDoublePrecisionContext(1)).generate(points));
+ Assertions.assertThrows(IllegalStateException.class, () -> new MonotoneChain(true, new EpsilonDoublePrecisionContext(1)).generate(points));
}
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java
index f7ae171..b93ea0b 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java
@@ -18,7 +18,6 @@ package org.apache.commons.geometry.spherical.oned;
import java.util.List;
-import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.Region;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.partitioning.Split;
@@ -29,6 +28,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class AngularIntervalTest {
private static final double TEST_EPS = 1e-10;
@@ -53,29 +53,12 @@ public class AngularIntervalTest {
@Test
public void testOf_doubles_invalidArgs() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(Double.NEGATIVE_INFINITY, 0, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(0, Double.POSITIVE_INFINITY, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(Double.NaN, 0, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(0, Double.NaN, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(Double.NaN, Double.NaN, TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(Double.NEGATIVE_INFINITY, 0, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(0, Double.POSITIVE_INFINITY, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(Double.NaN, 0, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(0, Double.NaN, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(Double.NaN, Double.NaN, TEST_PRECISION));
}
@Test
@@ -94,29 +77,12 @@ public class AngularIntervalTest {
@Test
public void testOf_points_invalidArgs() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(Point1S.of(Double.NEGATIVE_INFINITY), Point1S.ZERO, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(Point1S.ZERO, Point1S.of(Double.POSITIVE_INFINITY), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(Point1S.of(Double.POSITIVE_INFINITY), Point1S.of(Double.NEGATIVE_INFINITY), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(Point1S.NaN, Point1S.ZERO, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(Point1S.ZERO, Point1S.NaN, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(Point1S.NaN, Point1S.NaN, TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(Point1S.of(Double.NEGATIVE_INFINITY), Point1S.ZERO, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(Point1S.ZERO, Point1S.of(Double.POSITIVE_INFINITY), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(Point1S.of(Double.POSITIVE_INFINITY), Point1S.of(Double.NEGATIVE_INFINITY), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(Point1S.NaN, Point1S.ZERO, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(Point1S.ZERO, Point1S.NaN, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(Point1S.NaN, Point1S.NaN, TEST_PRECISION));
}
@Test
@@ -152,17 +118,9 @@ public class AngularIntervalTest {
final CutAngle nan = CutAngles.createPositiveFacing(Point1S.NaN, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(pt, nan);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(nan, pt);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.of(nan, nan);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(pt, nan));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(nan, pt));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.of(nan, nan));
}
@Test
@@ -541,21 +499,10 @@ public class AngularIntervalTest {
@Test
public void testConvex_of_doubles_invalidArgs() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.Convex.of(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.Convex.of(0, PlaneAngleRadians.PI + 1e-1, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.Convex.of(PlaneAngleRadians.PI_OVER_TWO, -PlaneAngleRadians.PI_OVER_TWO + 1, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.Convex.of(0, -0.5, TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.Convex.of(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.Convex.of(0, PlaneAngleRadians.PI + 1e-1, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.Convex.of(PlaneAngleRadians.PI_OVER_TWO, -PlaneAngleRadians.PI_OVER_TWO + 1, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.Convex.of(0, -0.5, TEST_PRECISION));
}
@Test
@@ -577,23 +524,12 @@ public class AngularIntervalTest {
@Test
public void testConvex_of_points_invalidArgs() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.Convex.of(Point1S.of(Double.NEGATIVE_INFINITY),
- Point1S.of(Double.POSITIVE_INFINITY), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.Convex.of(Point1S.of(0), Point1S.of(PlaneAngleRadians.PI + 1e-1), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.Convex.of(Point1S.of(PlaneAngleRadians.PI_OVER_TWO),
- Point1S.of(-PlaneAngleRadians.PI_OVER_TWO + 1), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.Convex.of(Point1S.of(0), Point1S.of(-0.5), TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.Convex.of(Point1S.of(Double.NEGATIVE_INFINITY),
+ Point1S.of(Double.POSITIVE_INFINITY), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.Convex.of(Point1S.of(0), Point1S.of(PlaneAngleRadians.PI + 1e-1), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.Convex.of(Point1S.of(PlaneAngleRadians.PI_OVER_TWO),
+ Point1S.of(-PlaneAngleRadians.PI_OVER_TWO + 1), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.Convex.of(Point1S.of(0), Point1S.of(-0.5), TEST_PRECISION));
}
@Test
@@ -629,23 +565,12 @@ public class AngularIntervalTest {
final CutAngle nan = CutAngles.createPositiveFacing(Point1S.NaN, TEST_PRECISION);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.Convex.of(pt, nan);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.Convex.of(nan, pt);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.Convex.of(nan, nan);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- AngularInterval.Convex.of(
- CutAngles.createNegativeFacing(1, TEST_PRECISION),
- CutAngles.createPositiveFacing(0.5, TEST_PRECISION));
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.Convex.of(pt, nan));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.Convex.of(nan, pt));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.Convex.of(nan, nan));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> AngularInterval.Convex.of(
+ CutAngles.createNegativeFacing(1, TEST_PRECISION),
+ CutAngles.createPositiveFacing(0.5, TEST_PRECISION)));
}
@Test
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/Point1STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/Point1STest.java
index 205f4b7..8809632 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/Point1STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/Point1STest.java
@@ -28,7 +28,6 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertThrows;
public class Point1STest {
@@ -361,17 +360,9 @@ public class Point1STest {
@Test
public void testNormalize_nonFinite() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Point1S.of(Double.POSITIVE_INFINITY).normalize(0.0);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Point1S.of(Double.NEGATIVE_INFINITY).normalize(0.0);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Point1S.of(Double.NaN).normalize(Point1S.ZERO);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Point1S.of(Double.POSITIVE_INFINITY).normalize(0.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Point1S.of(Double.NEGATIVE_INFINITY).normalize(0.0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Point1S.of(Double.NaN).normalize(Point1S.ZERO));
}
@Test
@@ -400,17 +391,9 @@ public class Point1STest {
@Test
public void testAbove_nonFinite() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Point1S.of(Double.POSITIVE_INFINITY).above(Point1S.ZERO);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Point1S.of(Double.NEGATIVE_INFINITY).above(Point1S.ZERO);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Point1S.of(Double.NaN).above(Point1S.ZERO);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Point1S.of(Double.POSITIVE_INFINITY).above(Point1S.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Point1S.of(Double.NEGATIVE_INFINITY).above(Point1S.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Point1S.of(Double.NaN).above(Point1S.ZERO));
}
@Test
@@ -439,17 +422,9 @@ public class Point1STest {
@Test
public void testBelow_nonFinite() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- Point1S.of(Double.POSITIVE_INFINITY).below(Point1S.ZERO);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Point1S.of(Double.NEGATIVE_INFINITY).below(Point1S.ZERO);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- Point1S.of(Double.NaN).below(Point1S.ZERO);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Point1S.of(Double.POSITIVE_INFINITY).below(Point1S.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Point1S.of(Double.NEGATIVE_INFINITY).below(Point1S.ZERO));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Point1S.of(Double.NaN).below(Point1S.ZERO));
}
@Test
@@ -469,7 +444,7 @@ public class Point1STest {
@Test
public void testParse_failure() {
// act/assert
- assertThrows(IllegalArgumentException.class, () -> Point1S.parse("abc"));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Point1S.parse("abc"));
}
private static void checkPoint(final Point1S pt, final double az) {
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/ConvexArea2STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/ConvexArea2STest.java
index fb0d71f..8d9430f 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/ConvexArea2STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/ConvexArea2STest.java
@@ -22,7 +22,6 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
-import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SplitLocation;
@@ -35,6 +34,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class ConvexArea2STest {
private static final double TEST_EPS = 1e-10;
@@ -480,13 +480,8 @@ public class ConvexArea2STest {
@Test
public void testFromVertices_invalidArguments() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- ConvexArea2S.fromVertices(Collections.singletonList(Point2S.PLUS_I), TEST_PRECISION);
- }, IllegalStateException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- ConvexArea2S.fromVertices(Arrays.asList(Point2S.PLUS_I, Point2S.of(1e-16, PlaneAngleRadians.PI_OVER_TWO)), TEST_PRECISION);
- }, IllegalStateException.class);
+ Assertions.assertThrows(IllegalStateException.class, () -> ConvexArea2S.fromVertices(Collections.singletonList(Point2S.PLUS_I), TEST_PRECISION));
+ Assertions.assertThrows(IllegalStateException.class, () -> ConvexArea2S.fromVertices(Arrays.asList(Point2S.PLUS_I, Point2S.of(1e-16, PlaneAngleRadians.PI_OVER_TWO)), TEST_PRECISION));
}
@Test
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/EmbeddedTreeSubGreatCircleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/EmbeddedTreeSubGreatCircleTest.java
index a420448..83a7135 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/EmbeddedTreeSubGreatCircleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/EmbeddedTreeSubGreatCircleTest.java
@@ -33,7 +33,6 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertThrows;
public class EmbeddedTreeSubGreatCircleTest {
@@ -344,7 +343,7 @@ public class EmbeddedTreeSubGreatCircleTest {
final EmbeddedTreeGreatCircleSubset sub = new EmbeddedTreeGreatCircleSubset(circle);
// act/assert
- assertThrows(IllegalArgumentException.class, () -> sub.add(otherCircle.arc(Point2S.PLUS_J, Point2S.of(1.5 * PlaneAngleRadians.PI, 0.75 * PlaneAngleRadians.PI))));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> sub.add(otherCircle.arc(Point2S.PLUS_J, Point2S.of(1.5 * PlaneAngleRadians.PI, 0.75 * PlaneAngleRadians.PI))));
}
@Test
@@ -384,7 +383,7 @@ public class EmbeddedTreeSubGreatCircleTest {
final EmbeddedTreeGreatCircleSubset sub = new EmbeddedTreeGreatCircleSubset(circle);
// act/assert
- assertThrows(IllegalArgumentException.class, () -> sub.add(new EmbeddedTreeGreatCircleSubset(otherCircle, RegionBSPTree1S.full())));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> sub.add(new EmbeddedTreeGreatCircleSubset(otherCircle, RegionBSPTree1S.full())));
}
@Test
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcPathTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcPathTest.java
index 1657450..ffc64d9 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcPathTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcPathTest.java
@@ -518,13 +518,13 @@ public class GreatArcPathTest {
@Test
public void testBuilder_points_noPrecisionGiven() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
GreatArcPath.builder(null)
.append(Point2S.PLUS_I)
.append(Point2S.PLUS_J);
}, IllegalStateException.class, "Unable to create arc: no point precision specified");
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
GreatArcPath.builder(null)
.prepend(Point2S.PLUS_I)
.prepend(Point2S.PLUS_J);
@@ -534,14 +534,14 @@ public class GreatArcPathTest {
@Test
public void testBuilder_arcsNotConnected() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
GreatArcPath.builder(TEST_PRECISION)
.append(Point2S.PLUS_I)
.append(Point2S.PLUS_J)
.append(GreatCircles.arcFromPoints(Point2S.PLUS_K, Point2S.MINUS_J, TEST_PRECISION));
}, IllegalStateException.class, Pattern.compile("^Path arcs are not connected.*"));
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
GreatArcPath.builder(TEST_PRECISION)
.prepend(Point2S.PLUS_I)
.prepend(Point2S.PLUS_J)
@@ -552,13 +552,13 @@ public class GreatArcPathTest {
@Test
public void testBuilder_addToFullArc() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
GreatArcPath.builder(TEST_PRECISION)
.append(GreatCircles.fromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION).span())
.append(Point2S.PLUS_J);
}, IllegalStateException.class, Pattern.compile("^Cannot add point .* after full arc.*"));
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
GreatArcPath.builder(TEST_PRECISION)
.prepend(GreatCircles.fromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION).span())
.prepend(Point2S.PLUS_J);
@@ -568,13 +568,13 @@ public class GreatArcPathTest {
@Test
public void testBuilder_onlySinglePointGiven() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
GreatArcPath.builder(TEST_PRECISION)
.append(Point2S.PLUS_J)
.build();
}, IllegalStateException.class, Pattern.compile("^Unable to create path; only a single point provided.*"));
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
GreatArcPath.builder(TEST_PRECISION)
.prepend(Point2S.PLUS_J)
.build();
@@ -584,7 +584,7 @@ public class GreatArcPathTest {
@Test
public void testBuilder_cannotClose() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
GreatArcPath.builder(TEST_PRECISION)
.append(GreatCircles.fromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION).span())
.close();
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java
index c225867..da3c941 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java
@@ -31,6 +31,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class GreatArcTest {
private static final double TEST_EPS = 1e-10;
@@ -153,13 +154,8 @@ public class GreatArcTest {
@Test
public void testFromPoints_invalidPoints() {
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- GreatCircles.arcFromPoints(Point2S.PLUS_I, Point2S.of(1e-12, PlaneAngleRadians.PI_OVER_TWO), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- GreatCircles.arcFromPoints(Point2S.PLUS_I, Point2S.MINUS_I, TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> GreatCircles.arcFromPoints(Point2S.PLUS_I, Point2S.of(1e-12, PlaneAngleRadians.PI_OVER_TWO), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> GreatCircles.arcFromPoints(Point2S.PLUS_I, Point2S.MINUS_I, TEST_PRECISION));
}
@Test
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleTest.java
index 8e1be7d..47d1a81 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleTest.java
@@ -30,6 +30,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class GreatCircleTest {
private static final double TEST_EPS = 1e-10;
@@ -92,36 +93,25 @@ public class GreatCircleTest {
final Point2S p2 = Point2S.of(PlaneAngleRadians.PI, PlaneAngleRadians.PI_OVER_TWO);
// act/assert
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
GreatCircles.fromPoints(p1, p1, TEST_PRECISION);
}, IllegalArgumentException.class, Pattern.compile("^.*points are equal$"));
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
GreatCircles.fromPoints(p1, Point2S.of(1e-12, PlaneAngleRadians.PI_OVER_TWO), TEST_PRECISION);
}, IllegalArgumentException.class, Pattern.compile("^.*points are equal$"));
- GeometryTestUtils.assertThrows(() -> {
+ GeometryTestUtils.assertThrowsWithMessage(() -> {
GreatCircles.fromPoints(
Point2S.from(Vector3D.Unit.PLUS_X),
Point2S.from(Vector3D.Unit.MINUS_X),
TEST_PRECISION);
}, IllegalArgumentException.class, Pattern.compile("^.*points are antipodal$"));
- GeometryTestUtils.assertThrows(() -> {
- GreatCircles.fromPoints(p1, Point2S.NaN, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- GreatCircles.fromPoints(Point2S.NaN, p2, TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- GreatCircles.fromPoints(p1, Point2S.of(Double.POSITIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO), TEST_PRECISION);
- }, IllegalArgumentException.class);
-
- GeometryTestUtils.assertThrows(() -> {
- GreatCircles.fromPoints(Point2S.of(Double.POSITIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO), p2, TEST_PRECISION);
- }, IllegalArgumentException.class);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> GreatCircles.fromPoints(p1, Point2S.NaN, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> GreatCircles.fromPoints(Point2S.NaN, p2, TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> GreatCircles.fromPoints(p1, Point2S.of(Double.POSITIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO), TEST_PRECISION));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> GreatCircles.fromPoints(Point2S.of(Double.POSITIVE_INFINITY, PlaneAngleRadians.PI_OVER_TWO), p2, TEST_PRECISION));
}
@Test
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/Point2STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/Point2STest.java
index 4235c91..86bb298 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/Point2STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/Point2STest.java
@@ -28,7 +28,6 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertThrows;
public class Point2STest {
@@ -355,7 +354,7 @@ public class Point2STest {
@Test
public void testParse_failure() {
// act/assert
- assertThrows(IllegalArgumentException.class, () -> Point2S.parse("abc"));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> Point2S.parse("abc"));
}
private static void checkPoint(final Point2S p, final double az, final double polar) {
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
index e7fd918..40f706a 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.apache.commons.geometry.core.GeometryTestUtils;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SplitLocation;
@@ -37,6 +36,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+
public class RegionBSPTree2STest {
private static final double TEST_EPS = 1e-10;
@@ -272,9 +272,7 @@ public class RegionBSPTree2STest {
tree.insert(EQUATOR.span());
// act/assert
- GeometryTestUtils.assertThrows(() -> {
- tree.getBoundaryPaths().add(GreatArcPath.empty());
- }, UnsupportedOperationException.class);
+ Assertions.assertThrows(UnsupportedOperationException.class, () -> tree.getBoundaryPaths().add(GreatArcPath.empty()));
}
@Test