results) {
GeoPipeFlow second = results.get(i + 1);
double d1 = (Double) first.getProperties().get(OrthodromicDistance.DISTANCE);
double d2 = (Double) second.getProperties().get(OrthodromicDistance.DISTANCE);
- assertTrue("Point at position " + i + " (d=" + d1 + ") must be closer than point at position " + (i + 1) + " (d=" + d2 + ")", d1 <= d2);
+ assertTrue(d1 <= d2, "Point at position " + i + " (d=" + d1 + ") must be closer than point at position " + (i + 1) + " (d=" + d2 + ")");
}
}
@@ -386,7 +386,7 @@ private void saveResultsAsImage(List extends SpatialRecord> results, String la
}
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"SameParameterValue"})
private static Coordinate[] makeCoordinateDataFromTextFile(String textFile, Coordinate origin) {
CoordinateList data = new CoordinateList();
try {
@@ -410,7 +410,6 @@ private static Coordinate[] makeCoordinateDataFromTextFile(String textFile, Coor
return data.toCoordinateArray();
}
- @SuppressWarnings("unchecked")
private static Coordinate[] makeDensePointData() {
CoordinateList data = new CoordinateList();
Coordinate origin = new Coordinate(13.0, 55.6);
diff --git a/src/test/java/org/neo4j/gis/spatial/TestSpatial.java b/src/test/java/org/neo4j/gis/spatial/TestSpatial.java
index 9bb88fc64..43c4b1243 100644
--- a/src/test/java/org/neo4j/gis/spatial/TestSpatial.java
+++ b/src/test/java/org/neo4j/gis/spatial/TestSpatial.java
@@ -19,29 +19,30 @@
*/
package org.neo4j.gis.spatial;
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.neo4j.gis.spatial.filter.SearchIntersect;
+import org.neo4j.gis.spatial.filter.SearchRecords;
import org.neo4j.gis.spatial.index.IndexManager;
import org.neo4j.gis.spatial.index.LayerIndexReader;
import org.neo4j.gis.spatial.osm.OSMDataset;
+import org.neo4j.gis.spatial.osm.OSMImporter;
import org.neo4j.gis.spatial.osm.OSMLayer;
import org.neo4j.gis.spatial.rtree.Envelope;
import org.neo4j.gis.spatial.rtree.NullListener;
-import org.neo4j.gis.spatial.filter.SearchIntersect;
-import org.neo4j.gis.spatial.filter.SearchRecords;
-import org.neo4j.gis.spatial.osm.OSMImporter;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.internal.kernel.api.security.SecurityContext;
import org.neo4j.kernel.internal.GraphDatabaseAPI;
-import static org.junit.Assert.*;
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import static org.junit.jupiter.api.Assertions.fail;
/**
*
@@ -87,7 +88,7 @@ public class TestSpatial extends Neo4jTestCase {
private final HashMap geomStats = new HashMap<>();
private final String spatialTestMode = System.getProperty("spatial.test.mode");
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
@@ -254,10 +255,10 @@ private void testSpatialIndex(String layerName) {
SpatialDatabaseService spatial = new SpatialDatabaseService(new IndexManager((GraphDatabaseAPI) graphDb(), SecurityContext.AUTH_DISABLED));
try (Transaction tx = graphDb().beginTx()) {
Layer layer = spatial.getLayer(tx, layerName);
- OSMDataset.fromLayer(tx, (OSMLayer) layer); // force lookup
if (layer == null || layer.getIndex() == null || layer.getIndex().count(tx) < 1) {
fail("Layer not loaded: " + layerName);
}
+ OSMDataset.fromLayer(tx, (OSMLayer) layer); // force lookup
LayerIndexReader fakeIndex = new SpatialIndexPerformanceProxy(new FakeIndex(layer, spatial.indexManager));
LayerIndexReader rtreeIndex = new SpatialIndexPerformanceProxy(layer.getIndex());
@@ -267,7 +268,7 @@ private void testSpatialIndex(String layerName) {
assertEnvelopeEquals(fakeIndex.getBoundingBox(tx), rtreeIndex.getBoundingBox(tx));
System.out.println("RTreeIndex count: " + rtreeIndex.count(tx));
- assertEquals(fakeIndex.count(tx), rtreeIndex.count(tx));
+ Assertions.assertEquals(fakeIndex.count(tx), rtreeIndex.count(tx));
Envelope bbox = layerTestEnvelope.get(layerName);
@@ -293,7 +294,7 @@ private void testSpatialIndex(String layerName) {
props.append(prop).append(": ").append(r.getProperty(tx, prop));
}
- System.out.println("\tRTreeIndex result[" + ri + "]: " + r.getNodeId() + ":" + r.getType() + " - " + r.toString() + ": PROPS[" + props + "]");
+ System.out.println("\tRTreeIndex result[" + ri + "]: " + r.getNodeId() + ":" + r.getType() + " - " + r + ": PROPS[" + props + "]");
} else if (ri == 10) {
System.out.println("\t.. and " + (count - ri) + " more ..");
}
@@ -313,8 +314,7 @@ private void testSpatialIndex(String layerName) {
System.out.println("\tOnly first character matched: test[" + testData + "] == result[" + r + "]");
} */
} else {
- System.err.println("\tNo name or id in RTreeIndex result: " + r.getNodeId() + ":" + r.getType() + " - "
- + r.toString());
+ System.err.println("\tNo name or id in RTreeIndex result: " + r.getNodeId() + ":" + r.getType() + " - " + r);
}
}
@@ -345,13 +345,13 @@ private void testSpatialIndex(String layerName) {
}
private void assertEnvelopeEquals(Envelope a, Envelope b) {
- assertNotNull(a);
- assertNotNull(b);
- assertEquals(a.getDimension(), b.getDimension());
+ Assertions.assertNotNull(a);
+ Assertions.assertNotNull(b);
+ Assertions.assertEquals(a.getDimension(), b.getDimension());
for (int i = 0; i < a.getDimension(); i++) {
- assertEquals(a.getMin(i), b.getMin(i), 0);
- assertEquals(a.getMax(i), b.getMax(i), 0);
+ Assertions.assertEquals(a.getMin(i), b.getMin(i), 0);
+ Assertions.assertEquals(a.getMax(i), b.getMax(i), 0);
}
}
diff --git a/src/test/java/org/neo4j/gis/spatial/TestSpatialQueries.java b/src/test/java/org/neo4j/gis/spatial/TestSpatialQueries.java
index 89e39469d..d3c4c3c03 100644
--- a/src/test/java/org/neo4j/gis/spatial/TestSpatialQueries.java
+++ b/src/test/java/org/neo4j/gis/spatial/TestSpatialQueries.java
@@ -19,11 +19,12 @@
*/
package org.neo4j.gis.spatial;
+import org.hamcrest.MatcherAssert;
+import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;
-import org.junit.Test;
import org.neo4j.gis.spatial.index.IndexManager;
import org.neo4j.gis.spatial.pipes.GeoPipeline;
import org.neo4j.graphdb.Transaction;
@@ -31,7 +32,8 @@
import org.neo4j.kernel.internal.GraphDatabaseAPI;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class TestSpatialQueries extends Neo4jTestCase {
@@ -72,7 +74,7 @@ public void testSearchClosestWithShortLongLineStrings() throws ParseException {
closestGeom = geom;
}
}
- assertNotNull("Expected to find a clistestGeom", closestGeom);
+ assertNotNull(closestGeom, "Expected to find a clistestGeom");
System.out.println("Found closest: " + closestGeom);
System.out.println();
@@ -86,7 +88,7 @@ public void testSearchClosestWithShortLongLineStrings() throws ParseException {
.getMin("Distance");
for (SpatialRecord result : pipeline) {
System.out.println("\tGot search result: " + result);
- assertEquals("Did not find the closest", closestGeom.toString(), result.getGeometry().toString());
+ assertEquals(closestGeom.toString(), result.getGeometry().toString(), "Did not find the closest");
}
tx.commit();
}
@@ -103,7 +105,7 @@ public void testSearchClosestWithShortLongLineStrings() throws ParseException {
System.out.println("Searching for geometries close to " + point + " within " + env);
for (SpatialRecord result : pipeline) {
System.out.println("\tGot search result: " + result);
- assertEquals("Did not find the closest", closestGeom.toString(), result.getGeometry().toString());
+ assertEquals(closestGeom.toString(), result.getGeometry().toString(), "Did not find the closest");
}
tx.commit();
}
@@ -118,7 +120,7 @@ public void testSearchClosestWithShortLongLineStrings() throws ParseException {
System.out.println("Searching for geometries close to " + point + " within buffer " + buffer);
for (SpatialRecord result : pipeline) {
System.out.println("\tGot search result: " + result);
- assertEquals("Did not find the closest", closestGeom.toString(), result.getGeometry().toString());
+ assertEquals(closestGeom.toString(), result.getGeometry().toString(), "Did not find the closest");
}
tx.commit();
}
@@ -145,7 +147,7 @@ public void testSearchClosestWithShortLongLineStrings() throws ParseException {
System.out.println("Searching for geometries close to " + point + " within automatic window designed to get about " + limit + " geometries");
for (SpatialRecord result : pipeline) {
System.out.println("\tGot search result: " + result);
- assertThat("Did not find the closest", result.getGeometry().toString(), is(closestGeom.toString()));
+ MatcherAssert.assertThat("Did not find the closest", result.getGeometry().toString(), is(closestGeom.toString()));
}
tx.commit();
}
diff --git a/src/test/java/org/neo4j/gis/spatial/TestSpatialUtils.java b/src/test/java/org/neo4j/gis/spatial/TestSpatialUtils.java
index 0bd725bba..48f4f6c61 100644
--- a/src/test/java/org/neo4j/gis/spatial/TestSpatialUtils.java
+++ b/src/test/java/org/neo4j/gis/spatial/TestSpatialUtils.java
@@ -19,13 +19,13 @@
*/
package org.neo4j.gis.spatial;
+import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Point;
import org.locationtech.jts.linearref.LengthIndexedLine;
import org.locationtech.jts.linearref.LocationIndexedLine;
-import org.junit.Test;
import org.neo4j.gis.spatial.SpatialTopologyUtils.PointResult;
import org.neo4j.gis.spatial.index.IndexManager;
import org.neo4j.gis.spatial.osm.OSMDataset;
@@ -36,11 +36,10 @@
import org.neo4j.kernel.internal.GraphDatabaseAPI;
import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class TestSpatialUtils extends Neo4jTestCase {
@@ -62,17 +61,17 @@ public void testJTSLinearRef() {
Layer layer = spatial.getLayer(tx, "jts");
// Now test the new API in the topology utils
Point point = SpatialTopologyUtils.locatePoint(layer, geometry, 1.5, 0.5);
- assertEquals("X location incorrect", 0.5, point.getX(), delta);
- assertEquals("Y location incorrect", 1.5, point.getY(), delta);
+ assertEquals(0.5, point.getX(), delta, "X location incorrect");
+ assertEquals(1.5, point.getY(), delta, "Y location incorrect");
point = SpatialTopologyUtils.locatePoint(layer, geometry, 1.5, -0.5);
- assertEquals("X location incorrect", 0.5, point.getX(), delta);
- assertEquals("Y location incorrect", 0.5, point.getY(), delta);
+ assertEquals(0.5, point.getX(), delta, "X location incorrect");
+ assertEquals(0.5, point.getY(), delta, "Y location incorrect");
point = SpatialTopologyUtils.locatePoint(layer, geometry, 0.5, 0.5);
- assertEquals("X location incorrect", -0.5, point.getX(), delta);
- assertEquals("Y location incorrect", 0.5, point.getY(), delta);
+ assertEquals(-0.5, point.getX(), delta, "X location incorrect");
+ assertEquals(0.5, point.getY(), delta, "Y location incorrect");
point = SpatialTopologyUtils.locatePoint(layer, geometry, 0.5, -0.5);
- assertEquals("X location incorrect", 0.5, point.getX(), delta);
- assertEquals("Y location incorrect", 0.5, point.getY(), delta);
+ assertEquals(0.5, point.getX(), delta, "X location incorrect");
+ assertEquals(0.5, point.getY(), delta, "Y location incorrect");
tx.commit();
}
}
@@ -121,20 +120,19 @@ public void testSnapping() throws Exception {
printDatabaseStats();
// Define dynamic layers
- List layers = new ArrayList<>();
SpatialDatabaseService spatial = new SpatialDatabaseService(new IndexManager((GraphDatabaseAPI) graphDb(), SecurityContext.AUTH_DISABLED));
try(Transaction tx = graphDb().beginTx()) {
OSMLayer osmLayer = (OSMLayer) spatial.getLayer(tx, osm);
- layers.add(osmLayer.addSimpleDynamicLayer(tx, "highway", "primary"));
- layers.add(osmLayer.addSimpleDynamicLayer(tx, "highway", "secondary"));
- layers.add(osmLayer.addSimpleDynamicLayer(tx, "highway", "tertiary"));
- layers.add(osmLayer.addSimpleDynamicLayer(tx, "highway", "residential"));
- layers.add(osmLayer.addSimpleDynamicLayer(tx, "highway", "footway"));
- layers.add(osmLayer.addSimpleDynamicLayer(tx, "highway", "cycleway"));
- layers.add(osmLayer.addSimpleDynamicLayer(tx, "highway", "track"));
- layers.add(osmLayer.addSimpleDynamicLayer(tx, "highway", "path"));
- layers.add(osmLayer.addSimpleDynamicLayer(tx, "railway", null));
- layers.add(osmLayer.addSimpleDynamicLayer(tx, "highway", null));
+ osmLayer.addSimpleDynamicLayer(tx, "highway", "primary");
+ osmLayer.addSimpleDynamicLayer(tx, "highway", "secondary");
+ osmLayer.addSimpleDynamicLayer(tx, "highway", "tertiary");
+ osmLayer.addSimpleDynamicLayer(tx, "highway", "residential");
+ osmLayer.addSimpleDynamicLayer(tx, "highway", "footway");
+ osmLayer.addSimpleDynamicLayer(tx, "highway", "cycleway");
+ osmLayer.addSimpleDynamicLayer(tx, "highway", "track");
+ osmLayer.addSimpleDynamicLayer(tx, "highway", "path");
+ osmLayer.addSimpleDynamicLayer(tx, "railway", null);
+ osmLayer.addSimpleDynamicLayer(tx, "highway", null);
tx.commit();
}
@@ -150,7 +148,7 @@ public void testSnapping() throws Exception {
resultsLayer.add(tx, point, fieldsNames, new Object[]{0L, "Point to snap", 0L});
for (String layerName : new String[]{"railway", "highway-residential"}) {
Layer layer = osmLayer.getLayer(tx, layerName);
- assertNotNull("Missing layer: " + layerName, layer);
+ assertNotNull(layer, "Missing layer: " + layerName);
System.out.println("Closest features in " + layerName + " to point " + point + ":");
List edgeResults = SpatialTopologyUtils.findClosestEdges(tx, point, layer);
for (PointResult result : edgeResults) {
@@ -166,6 +164,7 @@ public void testSnapping() throws Exception {
SpatialDatabaseRecord wayRecord = closest.getValue();
OSMDataset.Way way = ((OSMDataset) osmLayer.getDataset()).getWayFrom(wayRecord.getGeomNode());
OSMDataset.WayPoint wayPoint = way.getPointAt(closestPoint.getCoordinate());
+ // TODO: presumably we meant to assert something here?
}
}
tx.commit();
@@ -173,6 +172,7 @@ public void testSnapping() throws Exception {
}
+ @SuppressWarnings("SameParameterValue")
private void loadTestOsmData(String layerName, int commitInterval) throws Exception {
System.out.println("\n=== Loading layer " + layerName + " from " + layerName + " ===");
OSMImporter importer = new OSMImporter(layerName);
@@ -180,5 +180,4 @@ private void loadTestOsmData(String layerName, int commitInterval) throws Except
importer.importFile(graphDb(), layerName, commitInterval);
importer.reIndex(graphDb(), commitInterval);
}
-
}
diff --git a/src/test/java/org/neo4j/gis/spatial/TestsForDocs.java b/src/test/java/org/neo4j/gis/spatial/TestsForDocs.java
index 4859da47a..37380f9fe 100644
--- a/src/test/java/org/neo4j/gis/spatial/TestsForDocs.java
+++ b/src/test/java/org/neo4j/gis/spatial/TestsForDocs.java
@@ -22,9 +22,9 @@
import org.geotools.data.DataStore;
import org.geotools.data.neo4j.Neo4jSpatialDataStore;
import org.geotools.data.simple.SimpleFeatureCollection;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.Geometry;
import org.neo4j.dbms.api.DatabaseManagementService;
@@ -50,8 +50,8 @@
import java.util.HashMap;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME;
/**
@@ -65,7 +65,7 @@ public class TestsForDocs {
private DatabaseManagementService databases;
private GraphDatabaseService graphDb;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.databases = new DatabaseManagementServiceBuilder(Path.of("target", "docs-db")).build();
this.graphDb = databases.database(DEFAULT_DATABASE_NAME);
@@ -79,7 +79,7 @@ public void setUp() throws Exception {
}
}
- @After
+ @AfterEach
public void tearDown() {
this.databases.shutdown();
this.databases = null;
@@ -101,7 +101,7 @@ private void checkIndexAndFeatureCount(String layerName) throws IOException {
System.out.println("Layer '" + layerName + "' has " + features.size() + " features");
try (Transaction tx = graphDb.beginTx()) {
Layer layer = spatial.getLayer(tx, layerName);
- assertEquals("FeatureCollection.size for layer '" + layer.getName() + "' not the same as index count", layer.getIndex().count(tx), features.size());
+ assertEquals(layer.getIndex().count(tx), features.size(), "FeatureCollection.size for layer '" + layer.getName() + "' not the same as index count");
if (layer instanceof OSMLayer)
checkOSMAPI(tx, (OSMLayer) layer);
tx.commit();
@@ -132,7 +132,7 @@ private void checkOSMAPI(Transaction tx, OSMLayer layer) {
for (long wayId : waysFound.keySet()) {
System.out.println("\t" + wayId + ":\t" + waysFound.get(wayId) + ((wayId == way.getNode().getId()) ? "\t(original way)" : ""));
}
- assertTrue("Start way should be most found way", way.equals(osm.getWayFromId(tx, mostCommon)));
+ assertTrue(way.equals(osm.getWayFromId(tx, mostCommon)), "Start way should be most found way");
}
private void importMapOSM(GraphDatabaseService db) throws Exception {
diff --git a/src/test/java/org/neo4j/gis/spatial/TryWithResourceTest.java b/src/test/java/org/neo4j/gis/spatial/TryWithResourceTest.java
index 61c26b41f..14cec27ea 100644
--- a/src/test/java/org/neo4j/gis/spatial/TryWithResourceTest.java
+++ b/src/test/java/org/neo4j/gis/spatial/TryWithResourceTest.java
@@ -1,6 +1,6 @@
package org.neo4j.gis.spatial;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.neo4j.dbms.api.DatabaseManagementService;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
@@ -9,9 +9,10 @@
import java.io.File;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME;
+@SuppressWarnings("ConstantConditions")
public class TryWithResourceTest {
public static final String MESSAGE = "I want to see this";
diff --git a/src/test/java/org/neo4j/gis/spatial/index/LayerIndexTestBase.java b/src/test/java/org/neo4j/gis/spatial/index/LayerIndexTestBase.java
index 0b0a736f8..9d34272e6 100644
--- a/src/test/java/org/neo4j/gis/spatial/index/LayerIndexTestBase.java
+++ b/src/test/java/org/neo4j/gis/spatial/index/LayerIndexTestBase.java
@@ -19,11 +19,11 @@
*/
package org.neo4j.gis.spatial.index;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.*;
import org.geotools.referencing.crs.DefaultGeographicCRS;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
import org.mockito.Matchers;
import org.neo4j.dbms.api.DatabaseManagementService;
import org.neo4j.gis.spatial.*;
@@ -108,7 +108,7 @@ protected void addSimplePoint(SpatialIndexWriter index, double x, double y) {
}
}
- @Before
+ @BeforeEach
public void setup() throws IOException {
File baseDir = new File("target/layers");
FileUtils.deleteDirectory(baseDir.toPath());
@@ -117,7 +117,7 @@ public void setup() throws IOException {
spatial = new SpatialDatabaseService(new IndexManager((GraphDatabaseAPI) graph, SecurityContext.AUTH_DISABLED));
}
- @After
+ @AfterEach
public void tearDown() {
if (graph != null) {
databases.shutdown();
diff --git a/src/test/java/org/neo4j/gis/spatial/pipes/GeoPipesDocTest.java b/src/test/java/org/neo4j/gis/spatial/pipes/GeoPipesDocTest.java
index f12e0cfcd..6dac86edb 100644
--- a/src/test/java/org/neo4j/gis/spatial/pipes/GeoPipesDocTest.java
+++ b/src/test/java/org/neo4j/gis/spatial/pipes/GeoPipesDocTest.java
@@ -19,12 +19,6 @@
*/
package org.neo4j.gis.spatial.pipes;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.Envelope;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.util.AffineTransformation;
-import org.locationtech.jts.io.ParseException;
-import org.locationtech.jts.io.WKTReader;
import org.geotools.data.neo4j.Neo4jFeatureBuilder;
import org.geotools.data.neo4j.StyledImageExporter;
import org.geotools.feature.FeatureCollection;
@@ -32,10 +26,16 @@
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.referencing.crs.DefaultEngineeringCRS;
import org.geotools.styling.Style;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Envelope;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.util.AffineTransformation;
+import org.locationtech.jts.io.ParseException;
+import org.locationtech.jts.io.WKTReader;
import org.neo4j.annotations.documented.Documented;
import org.neo4j.gis.spatial.*;
import org.neo4j.gis.spatial.filter.SearchIntersectWindow;
@@ -54,10 +54,10 @@
import java.awt.*;
import java.io.File;
import java.io.IOException;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.NoSuchElementException;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME;
public class GeoPipesDocTest extends AbstractJavaDocTestBase {
@@ -109,10 +109,7 @@ public void filter_by_property() {
@Test
public void filter_by_window_intersection() {
- assertEquals(
- 1,
- GeoPipeline.start(tx, osmLayer).windowIntersectionFilter(10, 40, 20,
- 56.0583531).count());
+ assertEquals(1, GeoPipeline.start(tx, osmLayer).windowIntersectionFilter(10, 40, 20, 56.0583531).count());
}
/**
@@ -147,9 +144,7 @@ public void search_within_geometry() throws CQLException {
GeoPipeline pipeline = GeoPipeline
.startWithinSearch(tx, osmLayer, osmLayer.getGeometryFactory().toGeometry(new Envelope(10, 20, 50, 60)));
// end::search_within_geometry[]
- assertEquals(
- 2,
- pipeline.count());
+ assertEquals(2, pipeline.count());
}
@Test
@@ -228,10 +223,9 @@ public void translate_geometries() {
public void calculate_area() {
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).calculateArea().sort("Area");
- assertEquals((Double) pipeline.next().getProperties().get("Area"),
- 1.0, 0);
- assertEquals((Double) pipeline.next().getProperties().get("Area"),
- 8.0, 0);
+ assertEquals((Double) pipeline.next().getProperties().get("Area"), 1.0, 0);
+ assertEquals((Double) pipeline.next().getProperties().get("Area"), 8.0, 0);
+ pipeline.reset();
}
@Test
@@ -240,6 +234,7 @@ public void calculate_length() {
assertEquals((Double) pipeline.next().getProperties().get("Length"), 4.0, 0);
assertEquals((Double) pipeline.next().getProperties().get("Length"), 12.0, 0);
+ pipeline.reset();
}
@Test
@@ -252,6 +247,7 @@ public void get_boundary_length() {
assertEquals("LINEARRING (2 3, 2 5, 6 5, 6 3, 2 3)", second.getProperties().get("WellKnownText"));
assertEquals((Double) first.getProperties().get("Length"), 4.0, 0);
assertEquals((Double) second.getProperties().get("Length"), 12.0, 0);
+ pipeline.reset();
}
/**
@@ -276,6 +272,7 @@ public void get_buffer() {
assertTrue(((Double) pipeline.next().getProperties().get("Area")) > 1);
assertTrue(((Double) pipeline.next().getProperties().get("Area")) > 8);
+ pipeline.reset();
}
/**
@@ -298,10 +295,9 @@ public void get_centroid() {
pipeline = GeoPipeline.start(tx, boxesLayer).toCentroid().createWellKnownText().copyDatabaseRecordProperties(tx).sort("name");
- assertEquals("POINT (12.5 26.5)",
- pipeline.next().getProperties().get("WellKnownText"));
- assertEquals("POINT (4 4)",
- pipeline.next().getProperties().get("WellKnownText"));
+ assertEquals("POINT (12.5 26.5)", pipeline.next().getProperties().get("WellKnownText"));
+ assertEquals("POINT (4 4)", pipeline.next().getProperties().get("WellKnownText"));
+ pipeline.reset();
}
/**
@@ -349,8 +345,7 @@ public void get_convex_hull() {
pipeline = GeoPipeline.start(tx, concaveLayer).toConvexHull().createWellKnownText();
- assertEquals("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))",
- pipeline.next().getProperties().get("WellKnownText"));
+ assertEquals("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))", pipeline.next().getProperties().get("WellKnownText"));
pipeline.reset();
}
@@ -373,25 +368,20 @@ public void densify() {
// end::densify[]
addImageSnippet(concaveLayer, pipeline, getTitle(), Constants.GTYPE_POINT);
+ pipeline = GeoPipeline.start(tx, concaveLayer).toConvexHull().densify(5).createWellKnownText();
- pipeline = GeoPipeline.start(tx, concaveLayer).toConvexHull().densify(10).createWellKnownText();
-
- assertEquals(
- "POLYGON ((0 0, 0 5, 0 10, 5 10, 10 10, 10 5, 10 0, 5 0, 0 0))",
- pipeline.next().getProperties().get("WellKnownText"));
+ String wkt = (String) pipeline.next().getProperties().get("WellKnownText");
pipeline.reset();
+ assertEquals("POLYGON ((0 0, 0 5, 0 10, 5 10, 10 10, 10 5, 10 0, 5 0, 0 0))", wkt);
}
@Test
public void json() {
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).createJson().copyDatabaseRecordProperties(tx).sort("name");
- assertEquals(
- "{\"type\":\"Polygon\",\"coordinates\":[[[12,26],[12,27],[13,27],[13,26],[12,26]]]}",
- pipeline.next().getProperties().get("GeoJSON"));
- assertEquals(
- "{\"type\":\"Polygon\",\"coordinates\":[[[2,3],[2,5],[6,5],[6,3],[2,3]]]}",
- pipeline.next().getProperties().get("GeoJSON"));
+ assertEquals("{\"type\":\"Polygon\",\"coordinates\":[[[12,26],[12,27],[13,27],[13,26],[12,26]]]}", pipeline.next().getProperties().get("GeoJSON"));
+ assertEquals("{\"type\":\"Polygon\",\"coordinates\":[[[2,3],[2,5],[6,5],[6,3],[2,3]]]}", pipeline.next().getProperties().get("GeoJSON"));
+ pipeline.reset();
}
/**
@@ -417,6 +407,7 @@ public void get_max_area() {
pipeline = GeoPipeline.start(tx, boxesLayer).calculateArea().getMax("Area");
assertEquals((Double) pipeline.next().getProperties().get("Area"), 8.0, 0);
+ pipeline.reset();
}
/**
@@ -533,6 +524,7 @@ public void get_min_area() {
pipeline = GeoPipeline.start(tx, boxesLayer).calculateArea().getMin("Area");
assertEquals((Double) pipeline.next().getProperties().get("Area"), 1.0, 0);
+ pipeline.reset();
}
@Test
@@ -544,7 +536,7 @@ public void extract_osm_points() {
assertEquals(1, flow.getProperties().size());
String wkt = (String) flow.getProperties().get("WellKnownText");
- assertTrue(wkt.indexOf("POINT") == 0);
+ assertEquals(0, wkt.indexOf("POINT"));
}
assertEquals(24, count);
@@ -624,22 +616,14 @@ public void extract_points() {
@Test
public void filter_by_null_property() {
- assertEquals(
- 2,
- GeoPipeline.start(tx, boxesLayer).copyDatabaseRecordProperties(tx).propertyNullFilter("address").count());
- assertEquals(
- 0,
- GeoPipeline.start(tx, boxesLayer).copyDatabaseRecordProperties(tx).propertyNullFilter("name").count());
+ assertEquals(2, GeoPipeline.start(tx, boxesLayer).copyDatabaseRecordProperties(tx).propertyNullFilter("address").count());
+ assertEquals(0, GeoPipeline.start(tx, boxesLayer).copyDatabaseRecordProperties(tx).propertyNullFilter("name").count());
}
@Test
public void filter_by_not_null_property() {
- assertEquals(
- 0,
- GeoPipeline.start(tx, boxesLayer).copyDatabaseRecordProperties(tx).propertyNotNullFilter("address").count());
- assertEquals(
- 2,
- GeoPipeline.start(tx, boxesLayer).copyDatabaseRecordProperties(tx).propertyNotNullFilter("name").count());
+ assertEquals(0, GeoPipeline.start(tx, boxesLayer).copyDatabaseRecordProperties(tx).propertyNotNullFilter("address").count());
+ assertEquals(2, GeoPipeline.start(tx, boxesLayer).copyDatabaseRecordProperties(tx).propertyNotNullFilter("name").count());
}
@Test
@@ -649,10 +633,9 @@ public void compute_distance() throws ParseException {
GeoPipeline pipeline = GeoPipeline.start(tx, boxesLayer).calculateDistance(
reader.read("POINT (0 0)")).sort("Distance");
- assertEquals(
- 4, Math.round((Double) pipeline.next().getProperty(tx, "Distance")));
- assertEquals(
- 29, Math.round((Double) pipeline.next().getProperty(tx, "Distance")));
+ assertEquals(4, Math.round((Double) pipeline.next().getProperty(tx, "Distance")));
+ assertEquals(29, Math.round((Double) pipeline.next().getProperty(tx, "Distance")));
+ pipeline.reset();
}
/**
@@ -679,9 +662,7 @@ public void unite_all() {
.unionAll()
.createWellKnownText();
- assertEquals(
- "POLYGON ((0 0, 0 5, 2 5, 2 6, 4 6, 4 10, 10 10, 10 4, 6 4, 6 2, 5 2, 5 0, 0 0))",
- pipeline.next().getProperty(tx, "WellKnownText"));
+ assertEquals("POLYGON ((0 0, 0 5, 2 5, 2 6, 4 6, 4 10, 10 10, 10 4, 6 4, 6 2, 5 2, 5 0, 0 0))", pipeline.next().getProperty(tx, "WellKnownText"));
try {
pipeline.next();
@@ -714,8 +695,7 @@ public void intersect_all() {
.intersectAll()
.createWellKnownText();
- assertEquals("POLYGON ((4 5, 5 5, 5 4, 4 4, 4 5))",
- pipeline.next().getProperty(tx, "WellKnownText"));
+ assertEquals("POLYGON ((4 5, 5 5, 5 4, 4 4, 4 5))", pipeline.next().getProperty(tx, "WellKnownText"));
try {
pipeline.next();
@@ -854,6 +834,7 @@ public void test_equality() throws Exception {
assertEquals("different order", pipeline.next().getProperty(tx, "name"));
assertEquals("topo equal", pipeline.next().getProperty(tx, "name"));
assertFalse(pipeline.hasNext());
+ pipeline.reset();
}
private String getTitle() {
@@ -979,18 +960,19 @@ private static void load() throws Exception {
}
}
+ @SuppressWarnings("SameParameterValue")
private static void loadTestOsmData(String layerName, int commitInterval)
throws Exception {
String osmPath = "./" + layerName;
System.out.println("\n=== Loading layer " + layerName + " from "
+ osmPath + " ===");
OSMImporter importer = new OSMImporter(layerName);
- importer.setCharset(Charset.forName("UTF-8"));
+ importer.setCharset(StandardCharsets.UTF_8);
importer.importFile(db, osmPath);
importer.reIndex(db, commitInterval);
}
- @Before
+ @BeforeEach
public void setUp() {
gen.get().setGraph(db);
try (Transaction tx = db.beginTx()) {
@@ -1024,7 +1006,7 @@ public void setUp() {
tx = db.beginTx();
}
- @After
+ @AfterEach
public void doc() {
// gen.get().addSnippet( "graph", AsciidocHelper.createGraphViz( imgName , graphdb(), "graph"+getTitle() ) );
gen.get().addTestSourceSnippets(GeoPipesDocTest.class, "s_" + getTitle().toLowerCase());
@@ -1035,7 +1017,7 @@ public void doc() {
}
}
- @BeforeClass
+ @BeforeAll
public static void init() {
databases = new TestDatabaseManagementServiceBuilder(new File("target/docs").toPath()).impermanent().build();
db = databases.database(DEFAULT_DATABASE_NAME);
diff --git a/src/test/java/org/neo4j/gis/spatial/pipes/GeoPipesPerformanceTest.java b/src/test/java/org/neo4j/gis/spatial/pipes/GeoPipesPerformanceTest.java
index d4e05e023..f855cb826 100644
--- a/src/test/java/org/neo4j/gis/spatial/pipes/GeoPipesPerformanceTest.java
+++ b/src/test/java/org/neo4j/gis/spatial/pipes/GeoPipesPerformanceTest.java
@@ -19,8 +19,9 @@
*/
package org.neo4j.gis.spatial.pipes;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.Coordinate;
-import org.junit.Test;
import org.neo4j.gis.spatial.*;
import org.neo4j.gis.spatial.index.IndexManager;
import org.neo4j.graphdb.Transaction;
@@ -35,6 +36,7 @@ public class GeoPipesPerformanceTest extends Neo4jTestCase {
private int records = 10000;
private int chunkSize = records / 10;
+ @BeforeEach
public void setUp() throws Exception {
super.setUp(true);
loadSamplePointData();
diff --git a/src/test/java/org/neo4j/gis/spatial/pipes/OrthodromicDistanceTest.java b/src/test/java/org/neo4j/gis/spatial/pipes/OrthodromicDistanceTest.java
index 1a860dadf..3c32c252e 100644
--- a/src/test/java/org/neo4j/gis/spatial/pipes/OrthodromicDistanceTest.java
+++ b/src/test/java/org/neo4j/gis/spatial/pipes/OrthodromicDistanceTest.java
@@ -19,11 +19,11 @@
*/
package org.neo4j.gis.spatial.pipes;
+import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Point;
import org.locationtech.jts.geom.Polygon;
-import org.junit.Test;
import org.neo4j.gis.spatial.pipes.processing.OrthodromicDistance;
import static org.hamcrest.CoreMatchers.equalTo;
diff --git a/src/test/java/org/neo4j/gis/spatial/rtree/EnvelopeTests.java b/src/test/java/org/neo4j/gis/spatial/rtree/EnvelopeTests.java
index ddb78df94..293ff8a89 100644
--- a/src/test/java/org/neo4j/gis/spatial/rtree/EnvelopeTests.java
+++ b/src/test/java/org/neo4j/gis/spatial/rtree/EnvelopeTests.java
@@ -19,12 +19,12 @@
*/
package org.neo4j.gis.spatial.rtree;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class EnvelopeTests {
@@ -74,6 +74,7 @@ private void testOverlaps(Envelope left, Envelope right, boolean intersects, dou
assertThat(overlapMessage, right.overlap(left), closeTo(overlap, 0.000001));
}
+ @SuppressWarnings("SameParameterValue")
private void testOverlaps(Envelope left, Envelope right, boolean intersects, double overlap, double overlapArea, double bboxArea) {
testOverlaps(left, right, intersects, overlap);
assertThat("Expected overlap area", left.intersection(right).getArea(), closeTo(overlapArea, 0.000001));
@@ -119,7 +120,7 @@ private void makeAndTestEnvelope(double[] min, double[] max, double[] width) {
assertThat("Expected area to be correct", env.getArea(), equalTo(area));
assertThat("Expected copied area to be correct", env.getArea(), equalTo(copy.getArea()));
assertThat("Expected intersected area to be correct", env.getArea(), equalTo(intersection.getArea()));
- assertTrue("Expected copied envelope to intersect", env.intersects(copy));
+ assertTrue(env.intersects(copy), "Expected copied envelope to intersect");
assertThat("Expected copied envelope to intersect completely", env.overlap(copy), equalTo(1.0));
}
diff --git a/src/test/java/org/neo4j/gis/spatial/rtree/RTreeTests.java b/src/test/java/org/neo4j/gis/spatial/rtree/RTreeTests.java
index 49ddac7f5..7898f1c65 100644
--- a/src/test/java/org/neo4j/gis/spatial/rtree/RTreeTests.java
+++ b/src/test/java/org/neo4j/gis/spatial/rtree/RTreeTests.java
@@ -20,9 +20,9 @@
package org.neo4j.gis.spatial.rtree;
import org.geotools.data.neo4j.Neo4jFeatureBuilder;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.neo4j.dbms.api.DatabaseManagementService;
@@ -47,7 +47,7 @@ public class RTreeTests {
private TestRTreeIndex rtree;
private RTreeImageExporter imageExporter;
- @Before
+ @BeforeEach
public void setup() {
databases = new TestDatabaseManagementServiceBuilder(Path.of("target", "rtree")).impermanent().build();
db = databases.database(DEFAULT_DATABASE_NAME);
@@ -65,7 +65,7 @@ public void setup() {
}
}
- @After
+ @AfterEach
public void teardown() {
databases.shutdown();
}
@@ -103,6 +103,7 @@ public void shouldMergeTwoPartiallyOverlappingTrees() throws IOException {
}
}
+ @SuppressWarnings("SameParameterValue")
private RTreeIndex.NodeWithEnvelope createSimpleRTree(double minx, double maxx, int depth) {
double[] min = new double[]{minx, minx};
double[] max = new double[]{maxx, maxx};
@@ -134,9 +135,10 @@ private RTreeIndex.NodeWithEnvelope createSimpleRTree(double minx, double maxx,
}
}
+ @SuppressWarnings("SameParameterValue")
Envelope makeEnvelope(Envelope parent, double scaleFactor, double offsetX, double offsetY) {
Envelope env = new Envelope(parent);
- env.scaleBy(0.5);
+ env.scaleBy(scaleFactor);
env.shiftBy(offsetX * env.getWidth(0), 0);
env.shiftBy(offsetY * env.getWidth(1), 1);
return env;