From 508c34db1b3230461b9d57dbc094ff272fa78e7c Mon Sep 17 00:00:00 2001 From: Danylo Kravchenko Date: Mon, 18 Dec 2023 17:04:19 +0100 Subject: [PATCH] GIS #462: upgraded Junit to v5 in geo tests --- .../db/type/entity/PolyTimestamp.java | 137 +++++++++++ .../java/org/polypheny/db/PolyphenyDb.java | 2 +- .../db/sql/fun/GeoFunctionsTest.java | 15 +- .../db/type/spatial/GeometryTest.java | 225 +++++++++--------- 4 files changed, 252 insertions(+), 127 deletions(-) create mode 100644 core/src/main/java/org/polypheny/db/type/entity/PolyTimestamp.java diff --git a/core/src/main/java/org/polypheny/db/type/entity/PolyTimestamp.java b/core/src/main/java/org/polypheny/db/type/entity/PolyTimestamp.java new file mode 100644 index 0000000000..7664eafd13 --- /dev/null +++ b/core/src/main/java/org/polypheny/db/type/entity/PolyTimestamp.java @@ -0,0 +1,137 @@ +/* + * Copyright 2019-2023 The Polypheny Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.polypheny.db.type.entity; + +import com.fasterxml.jackson.core.JsonToken; +import java.sql.Time; +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Value; +import org.apache.calcite.linq4j.tree.Expression; +import org.apache.calcite.linq4j.tree.Expressions; +import org.apache.commons.lang3.NotImplementedException; +import org.jetbrains.annotations.NotNull; +import org.polypheny.db.functions.Functions; +import org.polypheny.db.type.PolySerializable; +import org.polypheny.db.type.PolyType; +import org.polypheny.db.type.entity.category.PolyTemporal; +import org.polypheny.db.util.TimestampString; + +@Getter +@Value +@EqualsAndHashCode(callSuper = true) +public class PolyTimestamp extends PolyTemporal { + + public static final DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); + + public Long milliSinceEpoch; // normalized to UTC + + + public PolyTimestamp( Long milliSinceEpoch ) { + super( PolyType.TIMESTAMP ); + this.milliSinceEpoch = milliSinceEpoch; + } + + + public static PolyTimestamp of( Number number ) { + return new PolyTimestamp( number.longValue() ); + } + + + public static PolyTimestamp ofNullable( Number number ) { + return number == null ? null : of( number ); + } + + + public static PolyTimestamp ofNullable( Time value ) { + return value == null ? null : PolyTimestamp.of( value ); + } + + + public static PolyTimestamp of( long value ) { + return new PolyTimestamp( value ); + } + + + public static PolyTimestamp of( Long value ) { + return new PolyTimestamp( value ); + } + + + public static PolyTimestamp of( Timestamp value ) { + return new PolyTimestamp( Functions.toLongOptional( value ) ); + } + + + public static PolyTimestamp of( Date date ) { + return new PolyTimestamp( date.getTime() ); + } + + + public Timestamp asSqlTimestamp() { + return new Timestamp( milliSinceEpoch ); + } + + + @Override + public String toJson() { + return milliSinceEpoch == null ? JsonToken.VALUE_NULL.asString() : TimestampString.fromMillisSinceEpoch( milliSinceEpoch ).toString(); + } + + + @Override + public int compareTo( @NotNull PolyValue o ) { + if ( !isSameType( o ) ) { + return -1; + } + + return Long.compare( milliSinceEpoch, o.asTimestamp().milliSinceEpoch ); + } + + + @Override + public Expression asExpression() { + return Expressions.new_( PolyTimestamp.class, Expressions.constant( milliSinceEpoch ) ); + } + + + @Override + public PolySerializable copy() { + return PolySerializable.deserialize( serialize(), PolyTimestamp.class ); + } + + + public static PolyTimestamp convert( PolyValue value ) { + if ( value.isNumber() ) { + return PolyTimestamp.of( value.asNumber().longValue() ); + } else if ( value.isTemporal() ) { + return PolyTimestamp.of( value.asTemporal().getMilliSinceEpoch() ); + } + throw new NotImplementedException( "convert " + PolyTimestamp.class.getSimpleName() ); + } + + + @Override + public @NotNull Long deriveByteSize() { + return 16L; + } + +} \ No newline at end of file diff --git a/dbms/src/main/java/org/polypheny/db/PolyphenyDb.java b/dbms/src/main/java/org/polypheny/db/PolyphenyDb.java index 6fb9ba6f1c..5172423392 100644 --- a/dbms/src/main/java/org/polypheny/db/PolyphenyDb.java +++ b/dbms/src/main/java/org/polypheny/db/PolyphenyDb.java @@ -127,7 +127,7 @@ public class PolyphenyDb { public boolean daemonMode = false; @Option(name = { "-defaultStore" }, description = "Type of default storeId") - public String defaultStoreName = "mongodb"; + public String defaultStoreName = "hsqldb"; @Option(name = { "-defaultSource" }, description = "Type of default source") public String defaultSourceName = "csv"; diff --git a/dbms/src/test/java/org/polypheny/db/sql/fun/GeoFunctionsTest.java b/dbms/src/test/java/org/polypheny/db/sql/fun/GeoFunctionsTest.java index 751a26a36d..377212f0f0 100644 --- a/dbms/src/test/java/org/polypheny/db/sql/fun/GeoFunctionsTest.java +++ b/dbms/src/test/java/org/polypheny/db/sql/fun/GeoFunctionsTest.java @@ -21,20 +21,19 @@ import java.sql.SQLException; import java.sql.Statement; import lombok.extern.slf4j.Slf4j; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.polypheny.db.AdapterTestSuite; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.polypheny.db.TestHelper; import org.polypheny.db.TestHelper.JdbcConnection; @SuppressWarnings({ "SqlDialectInspection", "SqlNoDataSourceInspection" }) @Slf4j -@Category({ AdapterTestSuite.class }) +@Tag("adapter") public class GeoFunctionsTest { - @BeforeClass + @BeforeAll public static void start() throws SQLException { // Ensures that Polypheny-DB is running //noinspection ResultOfMethodCallIgnored @@ -55,7 +54,7 @@ private static void addTestData() throws SQLException { } - @AfterClass + @AfterAll public static void stop() throws SQLException { try ( JdbcConnection jdbcConnection = new JdbcConnection( true ) ) { Connection connection = jdbcConnection.getConnection(); diff --git a/dbms/src/test/java/org/polypheny/db/type/spatial/GeometryTest.java b/dbms/src/test/java/org/polypheny/db/type/spatial/GeometryTest.java index b2d6a5e681..e0852a39be 100644 --- a/dbms/src/test/java/org/polypheny/db/type/spatial/GeometryTest.java +++ b/dbms/src/test/java/org/polypheny/db/type/spatial/GeometryTest.java @@ -16,17 +16,17 @@ package org.polypheny.db.type.spatial; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThrows; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeAll; import org.polypheny.db.TestHelper; import org.polypheny.db.type.entity.PolyValue; import org.polypheny.db.type.entity.spatial.InvalidGeometryException; @@ -43,24 +43,25 @@ public class GeometryTest { - private PolyGeometry point2d; - private PolyGeometry point3d; - private PolyGeometry lineString; - private PolyGeometry linearRing; - private PolyGeometry polygon; - private PolyGeometry geometryCollection; - private PolyGeometry multiPoint; - private PolyGeometry multiLineString; - private PolyGeometry multiPolygon; + private static PolyGeometry point2d; + private static PolyGeometry point3d; + private static PolyGeometry lineString; + private static PolyGeometry linearRing; + private static PolyGeometry polygon; + private static PolyGeometry geometryCollection; + private static PolyGeometry multiPoint; + private static PolyGeometry multiLineString; + private static PolyGeometry multiPolygon; - @BeforeClass - public static void start() { + @BeforeAll + public static void start() throws InvalidGeometryException { TestHelper.getInstance(); + prepareGeometries(); } - @Before - public void prepareGeometries() throws InvalidGeometryException { + + private static void prepareGeometries() throws InvalidGeometryException { point2d = PolyGeometry.of( GeometryConstants.POINT_EWKT ); point3d = PolyGeometry.of( GeometryConstants.POINT_WKT ); lineString = PolyGeometry.of( GeometryConstants.LINESTRING_WKT ); @@ -72,6 +73,7 @@ public void prepareGeometries() throws InvalidGeometryException { multiPolygon = PolyGeometry.of( GeometryConstants.MULTIPOLYGON_WKT ); } + @Test public void testGeometryFormats() throws InvalidGeometryException { // from TWKB @@ -83,28 +85,24 @@ public void testGeometryFormats() throws InvalidGeometryException { @Test public void testPointValidity() { - assertAll( "Group assertions of valid Point in EWKT", - () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.POINT_EWKT ) ), - () -> { - assertEquals( PolyGeometryType.POINT, point2d.getGeometryType() ); - assertEquals( 4326, (long) point2d.getSRID() ); - PolyPoint point = point2d.asPoint(); - assertEquals( 13.4050, point.getX(), GeometryConstants.DELTA ); - assertEquals( 52.5200, point.getY(), GeometryConstants.DELTA ); - assertFalse( point.hasZ() ); - } ); - - assertAll( "Group assertions of valid Point in WKT", - () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.POINT_WKT ) ), - () -> { - assertEquals( PolyGeometryType.POINT, point3d.getGeometryType() ); - assertEquals( GeometryConstants.NO_SRID, (long) point3d.getSRID() ); - PolyPoint point = point3d.asPoint(); - assertEquals( 13.4050, point.getX(), GeometryConstants.DELTA ); - assertEquals( 52.5200, point.getY(), GeometryConstants.DELTA ); - assertTrue( point.hasZ() ); - assertEquals( 36.754, point.getZ(), GeometryConstants.DELTA ); - } ); + assertAll( "Group assertions of valid Point in EWKT", () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.POINT_EWKT ) ), () -> { + assertEquals( PolyGeometryType.POINT, point2d.getGeometryType() ); + assertEquals( 4326, (long) point2d.getSRID() ); + PolyPoint point = point2d.asPoint(); + assertEquals( 13.4050, point.getX(), GeometryConstants.DELTA ); + assertEquals( 52.5200, point.getY(), GeometryConstants.DELTA ); + assertFalse( point.hasZ() ); + } ); + + assertAll( "Group assertions of valid Point in WKT", () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.POINT_WKT ) ), () -> { + assertEquals( PolyGeometryType.POINT, point3d.getGeometryType() ); + assertEquals( GeometryConstants.NO_SRID, (long) point3d.getSRID() ); + PolyPoint point = point3d.asPoint(); + assertEquals( 13.4050, point.getX(), GeometryConstants.DELTA ); + assertEquals( 52.5200, point.getY(), GeometryConstants.DELTA ); + assertTrue( point.hasZ() ); + assertEquals( 36.754, point.getZ(), GeometryConstants.DELTA ); + } ); assertThrows( InvalidGeometryException.class, () -> PolyGeometry.of( "POINT (13.4050)" ) ); assertThrows( InvalidGeometryException.class, () -> PolyGeometry.of( "POINT (13.4050 13.4050 13.4050 13.4050 13.4050)" ) ); @@ -113,123 +111,112 @@ public void testPointValidity() { @Test public void testLineStringValidity() { - assertAll( "Group assertions of valid LineString", - () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.LINESTRING_WKT ) ), - () -> { - assertEquals( PolyGeometryType.LINESTRING, lineString.getGeometryType() ); - assertEquals( GeometryConstants.NO_SRID, (long) lineString.getSRID() ); - PolyLineString line = lineString.asLineString(); - assertEquals( 10.6766191, line.getLength(), GeometryConstants.DELTA ); - assertEquals( 4, line.getNumPoints() ); - assertEquals( PolyPoint.of( "POINT(6 7)" ), line.getEndPoint() ); - assertFalse( line.isEmpty() ); - assertTrue( line.isSimple() ); - assertFalse( line.isClosed() ); - } ); + assertAll( "Group assertions of valid LineString", () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.LINESTRING_WKT ) ), () -> { + assertEquals( PolyGeometryType.LINESTRING, lineString.getGeometryType() ); + assertEquals( GeometryConstants.NO_SRID, (long) lineString.getSRID() ); + PolyLineString line = lineString.asLineString(); + assertEquals( 10.6766191, line.getLength(), GeometryConstants.DELTA ); + assertEquals( 4, line.getNumPoints() ); + assertEquals( PolyPoint.of( "POINT(6 7)" ), line.getEndPoint() ); + assertFalse( line.isEmpty() ); + assertTrue( line.isSimple() ); + assertFalse( line.isClosed() ); + } ); assertThrows( InvalidGeometryException.class, () -> PolyGeometry.of( "LINESTRING (0 0)" ) ); } + @Test public void testLinearRingValidity() { - assertAll( "Group assertions of valid LinearRing", - () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.LINEAR_RING_WKT ) ), - () -> { - assertEquals( PolyGeometryType.LINEARRING, linearRing.getGeometryType() ); - assertEquals( GeometryConstants.NO_SRID, (long) linearRing.getSRID() ); - PolyLinearRing ring = linearRing.asLinearRing(); - assertTrue( ring.isRing() ); - assertEquals( 40, ring.getLength(), GeometryConstants.DELTA ); - assertEquals( 5, ring.getNumPoints() ); - } ); + assertAll( "Group assertions of valid LinearRing", () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.LINEAR_RING_WKT ) ), () -> { + assertEquals( PolyGeometryType.LINEARRING, linearRing.getGeometryType() ); + assertEquals( GeometryConstants.NO_SRID, (long) linearRing.getSRID() ); + PolyLinearRing ring = linearRing.asLinearRing(); + assertTrue( ring.isRing() ); + assertEquals( 40, ring.getLength(), GeometryConstants.DELTA ); + assertEquals( 5, ring.getNumPoints() ); + } ); assertThrows( InvalidGeometryException.class, () -> PolyGeometry.of( "LINEARRING (0 0, 0 10, 10 10, 10 5, 5 5)" ) ); } + @Test public void testPolygonValidity() { - assertAll( "Group assertions of valid Polygon", - () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.POLYGON_WKT ) ), - () -> { - assertEquals( PolyGeometryType.POLYGON, polygon.getGeometryType() ); - assertEquals( GeometryConstants.NO_SRID, (long) polygon.getSRID() ); - PolyPolygon poly = polygon.asPolygon(); - assertEquals( PolyPoint.of( "POINT (-0 1)" ), poly.getCentroid() ); - assertEquals( PolyLinearRing.of( "LINEARRING (-1 -1, 2 2, -1 2, -1 -1)" ), poly.getBoundary() ); - assertEquals( poly.getExteriorRing(), poly.getBoundary() ); - assertEquals( 10.2426406, poly.getLength(), GeometryConstants.DELTA ); - assertEquals( 4.5, poly.getArea(), GeometryConstants.DELTA ); - assertEquals( 4, poly.getNumPoints() ); - } ); + assertAll( "Group assertions of valid Polygon", () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.POLYGON_WKT ) ), () -> { + assertEquals( PolyGeometryType.POLYGON, polygon.getGeometryType() ); + assertEquals( GeometryConstants.NO_SRID, (long) polygon.getSRID() ); + PolyPolygon poly = polygon.asPolygon(); + assertEquals( PolyPoint.of( "POINT (-0 1)" ), poly.getCentroid() ); + assertEquals( PolyLinearRing.of( "LINEARRING (-1 -1, 2 2, -1 2, -1 -1)" ), poly.getBoundary() ); + assertEquals( poly.getExteriorRing(), poly.getBoundary() ); + assertEquals( 10.2426406, poly.getLength(), GeometryConstants.DELTA ); + assertEquals( 4.5, poly.getArea(), GeometryConstants.DELTA ); + assertEquals( 4, poly.getNumPoints() ); + } ); assertThrows( InvalidGeometryException.class, () -> PolyGeometry.of( "POLYGON ((-1 -1, 2 2, -1 1, -1 2, 2 2, -1 -1))" ) ); } + @Test public void testGeometryCollectionValidity() { - assertAll( "Group assertions of valid GeometryCollection", - () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.GEOMETRYCOLLECTION_WKT ) ), - () -> { - assertEquals( PolyGeometryType.GEOMETRYCOLLECTION, geometryCollection.getGeometryType() ); - assertEquals( GeometryConstants.NO_SRID, (long) geometryCollection.getSRID() ); - PolyGeometryCollection collection = geometryCollection.asGeometryCollection(); - assertEquals( 2, collection.getNumGeometries() ); - assertEquals( PolyLinearRing.of( "POINT(2 3)" ), collection.getGeometryN( 0 ) ); - assertEquals( 3, collection.getNumPoints() ); - } ); + assertAll( "Group assertions of valid GeometryCollection", () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.GEOMETRYCOLLECTION_WKT ) ), () -> { + assertEquals( PolyGeometryType.GEOMETRYCOLLECTION, geometryCollection.getGeometryType() ); + assertEquals( GeometryConstants.NO_SRID, (long) geometryCollection.getSRID() ); + PolyGeometryCollection collection = geometryCollection.asGeometryCollection(); + assertEquals( 2, collection.getNumGeometries() ); + assertEquals( PolyLinearRing.of( "POINT(2 3)" ), collection.getGeometryN( 0 ) ); + assertEquals( 3, collection.getNumPoints() ); + } ); // GEOMETRYCOLLECTION do not have any extra validity rules, geometries may overlap assertDoesNotThrow( () -> PolyGeometry.of( "GEOMETRYCOLLECTION ( POINT (2 3), POINT (2 3) )" ) ); assertDoesNotThrow( () -> PolyGeometry.of( "GEOMETRYCOLLECTION ( POLYGON ((-1 -1, 2 2, -1 2, -1 -1 )), POLYGON ((-1 -1, 2 2, -1 2, -1 -1 )) )" ) ); } + @Test public void testMultiPointValidity() { - assertAll( "Group assertions of valid MultiPoint", - () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.MULTIPOINT_WKT ) ), - () -> { - assertEquals( PolyGeometryType.MULTIPOINT, multiPoint.getGeometryType() ); - assertEquals( GeometryConstants.NO_SRID, (long) multiPoint.getSRID() ); - PolyMultiPoint multi = multiPoint.asGeometryCollection().asMultiPoint(); - assertEquals( 2, multi.getNumGeometries() ); - assertEquals( 2, multi.getNumPoints() ); - } ); + assertAll( "Group assertions of valid MultiPoint", () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.MULTIPOINT_WKT ) ), () -> { + assertEquals( PolyGeometryType.MULTIPOINT, multiPoint.getGeometryType() ); + assertEquals( GeometryConstants.NO_SRID, (long) multiPoint.getSRID() ); + PolyMultiPoint multi = multiPoint.asGeometryCollection().asMultiPoint(); + assertEquals( 2, multi.getNumGeometries() ); + assertEquals( 2, multi.getNumPoints() ); + } ); // points may overlap assertDoesNotThrow( () -> PolyGeometry.of( "MULTIPOINT ( (2 3), (2 3) )" ) ); assertThrows( InvalidGeometryException.class, () -> PolyGeometry.of( "MULTIPOINT( (2 3), LINEARRING (-1 -1, 2 2, -1 2, -1 -1) )" ) ); } + @Test public void testMultiLineStringValidity() { - assertAll( "Group assertions of valid MultiLineString", - () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.MULTILINESTRING_WKT ) ), - () -> { - assertEquals( PolyGeometryType.MULTILINESTRING, multiLineString.getGeometryType() ); - assertEquals( GeometryConstants.NO_SRID, (long) multiLineString.getSRID() ); - PolyMultiLineString multi = multiLineString.asGeometryCollection().asMultiLineString(); - assertEquals( 2, multi.getNumGeometries() ); - assertEquals( 6, multi.getNumPoints() ); - } ); + assertAll( "Group assertions of valid MultiLineString", () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.MULTILINESTRING_WKT ) ), () -> { + assertEquals( PolyGeometryType.MULTILINESTRING, multiLineString.getGeometryType() ); + assertEquals( GeometryConstants.NO_SRID, (long) multiLineString.getSRID() ); + PolyMultiLineString multi = multiLineString.asGeometryCollection().asMultiLineString(); + assertEquals( 2, multi.getNumGeometries() ); + assertEquals( 6, multi.getNumPoints() ); + } ); // line strings may overlap assertDoesNotThrow( () -> PolyGeometry.of( "MULTILINESTRING ( (0 0, 1 1, 1 2), (0 0, 1 1, 1 2) )" ) ); assertThrows( InvalidGeometryException.class, () -> PolyGeometry.of( "MULTILINESTRING ( (2 3), (2 3) )" ) ); } + @Test public void testMultiPolygonValidity() { - assertAll( "Group assertions of valid MultiPolygon", - () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.MULTIPOLYGON_WKT ) ), - () -> { - assertEquals( PolyGeometryType.MULTIPOLYGON, multiPolygon.getGeometryType() ); - assertEquals( GeometryConstants.NO_SRID, (long) multiPolygon.getSRID() ); - PolyMultiPolygon multi = multiPolygon.asGeometryCollection().asMultiPolygon(); - assertEquals( 2, multi.getNumGeometries() ); - assertEquals( 9, multi.getNumPoints() ); - } ); + assertAll( "Group assertions of valid MultiPolygon", () -> assertDoesNotThrow( () -> PolyGeometry.of( GeometryConstants.MULTIPOLYGON_WKT ) ), () -> { + assertEquals( PolyGeometryType.MULTIPOLYGON, multiPolygon.getGeometryType() ); + assertEquals( GeometryConstants.NO_SRID, (long) multiPolygon.getSRID() ); + PolyMultiPolygon multi = multiPolygon.asGeometryCollection().asMultiPolygon(); + assertEquals( 2, multi.getNumGeometries() ); + assertEquals( 9, multi.getNumPoints() ); + } ); // Polygons are not allowed to overlap - assertThrows( InvalidGeometryException.class, - () -> PolyGeometry.of( - "MULTIPOLYGON (( (1 5, 5 5, 5 1, 1 1, 1 5) ), (-1 -1, 2 2, -1 2, -1 -1 ))" ) - ); + assertThrows( InvalidGeometryException.class, () -> PolyGeometry.of( "MULTIPOLYGON (( (1 5, 5 5, 5 1, 1 1, 1 5) ), (-1 -1, 2 2, -1 2, -1 -1 ))" ) ); } @@ -240,6 +227,7 @@ public void testPointsEquality() throws InvalidGeometryException { assertNotEquals( point2d, point3d ); } + @Test public void testLineStringEquality() throws InvalidGeometryException { PolyGeometry line = PolyGeometry.of( GeometryConstants.LINESTRING_WKT ); @@ -247,6 +235,7 @@ public void testLineStringEquality() throws InvalidGeometryException { assertNotEquals( lineString, linearRing ); } + @Test public void testLinearRingEquality() throws InvalidGeometryException { PolyGeometry ring = PolyGeometry.of( GeometryConstants.LINEAR_RING_WKT );