Skip to content

Commit 0ebaf6e

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into merge-osm
# Conflicts: # src/test/java/org/neo4j/gis/spatial/procedures/SpatialProceduresTest.java
2 parents 3f31b94 + 12f6d46 commit 0ebaf6e

8 files changed

+53
-52
lines changed

pom.xml

+1-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<plugin>
3838
<groupId>org.apache.maven.plugins</groupId>
3939
<artifactId>maven-compiler-plugin</artifactId>
40-
<version>3.11.0</version>
40+
<version>3.13.0</version>
4141
<configuration>
4242
<source>${neo4j.java.version}</source>
4343
<target>${neo4j.java.version}</target>
@@ -304,12 +304,6 @@
304304
</dependency>
305305

306306
<!-- The JUnit-Hamcrest-Mockito combo -->
307-
<dependency>
308-
<groupId>org.junit.vintage</groupId>
309-
<artifactId>junit-vintage-engine</artifactId>
310-
<version>${junit.version}</version>
311-
<scope>test</scope>
312-
</dependency>
313307
<dependency>
314308
<groupId>org.junit.jupiter</groupId>
315309
<artifactId>junit-jupiter-engine</artifactId>

src/test/java/org/neo4j/gis/spatial/LayersTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
import static org.hamcrest.MatcherAssert.assertThat;
2323
import static org.junit.jupiter.api.Assertions.assertEquals;
24+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2425
import static org.junit.jupiter.api.Assertions.assertNotNull;
2526
import static org.junit.jupiter.api.Assertions.assertNull;
26-
import static org.junit.jupiter.api.Assertions.assertTrue;
2727
import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME;
2828

2929
import java.io.File;
@@ -272,12 +272,12 @@ private String testSpecificEditableLayer(String layerName, Class<? extends Geome
272272
inTx(tx -> {
273273
Layer layer = spatial.createLayer(tx, layerName, geometryEncoderClass, layerClass);
274274
assertNotNull(layer);
275-
assertTrue(layer instanceof EditableLayer, "Should be an editable layer");
275+
assertInstanceOf(EditableLayer.class, layer, "Should be an editable layer");
276276
});
277277
inTx(tx -> {
278278
Layer layer = spatial.getLayer(tx, layerName);
279279
assertNotNull(layer);
280-
assertTrue(layer instanceof EditableLayer, "Should be an editable layer");
280+
assertInstanceOf(EditableLayer.class, layer, "Should be an editable layer");
281281
EditableLayer editableLayer = (EditableLayer) layer;
282282

283283
CoordinateList coordinates = new CoordinateList();
@@ -386,7 +386,7 @@ public void testIndexAccessAfterBulkInsertion() {
386386
Result result = tx.execute(cypher);
387387
// System.out.println(result.columns().toString());
388388
Object obj = result.columnAs("count(p)").next();
389-
assertTrue(obj instanceof Long);
389+
assertInstanceOf(Long.class, obj);
390390
assertEquals(1000L, (long) ((Long) obj));
391391
tx.commit();
392392
}

src/test/java/org/neo4j/gis/spatial/Neo4jTestUtils.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*/
2020
package org.neo4j.gis.spatial;
2121

22-
import static org.junit.Assert.assertEquals;
23-
import static org.junit.Assert.assertTrue;
22+
import static org.junit.jupiter.api.Assertions.assertEquals;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
2424

2525
import java.io.File;
2626
import java.util.ArrayList;
@@ -117,7 +117,7 @@ public static void printTree(Node root, int depth) {
117117

118118
public static <T> void assertCollection(Collection<T> collection, T... expectedItems) {
119119
String collectionString = join(", ", collection.toArray());
120-
assertEquals(collectionString, expectedItems.length, collection.size());
120+
assertEquals(expectedItems.length, collection.size(), collectionString);
121121
for (T item : expectedItems) {
122122
assertTrue(collection.contains(item));
123123
}

src/test/java/org/neo4j/gis/spatial/RTreeBulkInsertTest.java

+16-13
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
import static org.hamcrest.MatcherAssert.assertThat;
2424
import static org.hamcrest.Matchers.lessThan;
2525
import static org.hamcrest.Matchers.lessThanOrEqualTo;
26-
import static org.junit.Assert.assertEquals;
27-
import static org.junit.Assert.assertNotNull;
28-
import static org.junit.Assert.assertTrue;
26+
import static org.junit.jupiter.api.Assertions.assertEquals;
27+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
28+
import static org.junit.jupiter.api.Assertions.assertNotNull;
29+
import static org.junit.jupiter.api.Assertions.assertTrue;
2930
import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME;
3031
import static org.neo4j.gis.spatial.rtree.RTreeIndex.DEFAULT_MAX_NODE_REFERENCES;
3132
import static org.neo4j.internal.helpers.collection.MapUtil.map;
@@ -1137,7 +1138,7 @@ public void shouldAccessIndexAfterBulkInsertion() throws Exception {
11371138
Result result = tx.execute(cypher);
11381139
// System.out.println(result.columns().toString());
11391140
Object obj = result.columnAs("count").next();
1140-
assertTrue(obj instanceof Long);
1141+
assertInstanceOf(Long.class, obj);
11411142
assertEquals((long) ((Long) obj), numNodes);
11421143
tx.commit();
11431144
}
@@ -1152,7 +1153,7 @@ public void shouldAccessIndexAfterBulkInsertion() throws Exception {
11521153
Result result = tx.execute(cypher);
11531154
// System.out.println(result.columns().toString());
11541155
Object obj = result.columnAs("count").next();
1155-
assertTrue(obj instanceof Long);
1156+
assertInstanceOf(Long.class, obj);
11561157
assertEquals((long) ((Long) obj), numNodes);
11571158
tx.commit();
11581159
}
@@ -1492,8 +1493,8 @@ private List<Node> queryIndex(Layer layer, TestStats stats) {
14921493
stats.put("Indexed", geometrySize);
14931494
System.out.println("Index contains " + geometrySize + " geometries");
14941495
}
1495-
assertEquals("Expected " + config.expectedGeometries + " nodes to be returned", config.expectedGeometries,
1496-
countGeometries);
1496+
assertEquals(config.expectedGeometries, countGeometries,
1497+
"Expected " + config.expectedGeometries + " nodes to be returned");
14971498
return nodes;
14981499
}
14991500

@@ -1529,7 +1530,8 @@ private void getRTreeIndexStats(RTreeIndex index, TreeMonitor monitor, TestStats
15291530
// unless the polygon is a rectangle, in which case they are not contained, leading to
15301531
// different numbers for expectedGeometries and expectedCount.
15311532
// See https://github.com/locationtech/jts/blob/master/modules/core/src/main/java/org/locationtech/jts/operation/predicate/RectangleContains.java#L70
1532-
assertEquals("Expected " + config.expectedCount + " nodes to be matched", config.expectedCount, matched);
1533+
assertEquals(config.expectedCount, matched,
1534+
"Expected " + config.expectedCount + " nodes to be matched");
15331535
int maxNodeReferences = stats.maxNodeReferences;
15341536
int maxExpectedGeometriesTouched = matched * maxNodeReferences;
15351537
if (countGeometries > 1 && assertTouches) {
@@ -1555,7 +1557,8 @@ private void getExplicitIndexBackedIndexStats(ExplicitIndexBackedPointIndex inde
15551557
// unless the polygon is a rectangle, in which case they are not contained, leading to
15561558
// different numbers for expectedGeometries and expectedCount.
15571559
// See https://github.com/locationtech/jts/blob/master/modules/core/src/main/java/org/locationtech/jts/operation/predicate/RectangleContains.java#L70
1558-
assertEquals("Expected " + config.expectedCount + " nodes to be matched", config.expectedCount, matched);
1560+
assertEquals(config.expectedCount, matched,
1561+
"Expected " + config.expectedCount + " nodes to be matched");
15591562
}
15601563

15611564
private class TimedLogger {
@@ -1599,17 +1602,17 @@ private void log(String line, long number) {
15991602

16001603
private void verifyGeohashIndex(Layer layer) {
16011604
LayerIndexReader index = layer.getIndex();
1602-
assertTrue("Index should be a geohash index", index instanceof LayerGeohashPointIndex);
1605+
assertInstanceOf(LayerGeohashPointIndex.class, index, "Index should be a geohash index");
16031606
}
16041607

16051608
private void verifyHilbertIndex(Layer layer) {
16061609
LayerIndexReader index = layer.getIndex();
1607-
assertTrue("Index should be a hilbert index", index instanceof LayerHilbertPointIndex);
1610+
assertInstanceOf(LayerHilbertPointIndex.class, index, "Index should be a hilbert index");
16081611
}
16091612

16101613
private void verifyZOrderIndex(Layer layer) {
16111614
LayerIndexReader index = layer.getIndex();
1612-
assertTrue("Index should be a Z-Order index", index instanceof LayerZOrderPointIndex);
1615+
assertInstanceOf(LayerZOrderPointIndex.class, index, "Index should be a Z-Order index");
16131616
}
16141617

16151618
private void verifyTreeStructure(Layer layer, String splitMode, TestStats stats) {
@@ -1650,7 +1653,7 @@ private void verifyTreeStructure(Layer layer, String splitMode, TestStats stats)
16501653
System.out.println("Tree depth to all geometries: " + depthMap);
16511654
}
16521655
}
1653-
assertEquals("All geometries should be at the same depth", 1, balanced);
1656+
assertEquals(1, balanced, "All geometries should be at the same depth");
16541657
Map<String, Object> leafMap;
16551658
try (Transaction tx = db.beginTx()) {
16561659
Result resultNumChildren = tx.execute(queryNumChildren, params);

src/test/java/org/neo4j/gis/spatial/TestSimplePointLayer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.ArrayList;
3030
import java.util.List;
3131
import java.util.function.Consumer;
32-
import junit.framework.AssertionFailedError;
3332
import org.geotools.data.neo4j.StyledImageExporter;
3433
import org.junit.jupiter.api.Test;
3534
import org.locationtech.jts.geom.Coordinate;
@@ -48,6 +47,7 @@
4847
import org.neo4j.graphdb.Transaction;
4948
import org.neo4j.internal.kernel.api.security.SecurityContext;
5049
import org.neo4j.kernel.internal.GraphDatabaseAPI;
50+
import org.opentest4j.AssertionFailedError;
5151

5252
public class TestSimplePointLayer extends Neo4jTestCase {
5353

src/test/java/org/neo4j/gis/spatial/pipes/GeoPipesDocTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ public void extract_points() {
628628

629629
assertEquals(1, flow.getProperties().size());
630630
String wkt = (String) flow.getProperties().get("WellKnownText");
631-
assertTrue(wkt.indexOf("POINT") == 0);
631+
assertEquals(0, wkt.indexOf("POINT"));
632632
}
633633

634634
// every rectangle has 5 points, the last point is in the same position of the first

src/test/java/org/neo4j/gis/spatial/pipes/GeoPipesPerformanceTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
package org.neo4j.gis.spatial.pipes;
2121

22-
import static org.junit.Assert.assertTrue;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
2323

2424
import java.util.ArrayList;
2525
import org.junit.jupiter.api.BeforeEach;
@@ -136,9 +136,9 @@ public void testQueryPerformance() {
136136
count += rec.count;
137137
System.out.println("\t" + rec);
138138
float average = (float) rec.time / (float) rec.count;
139-
assertTrue("Expected record average of " + rec.average()
139+
assertTrue(rec.average() < 2 * average, "Expected record average of " + rec.average()
140140
+ " to not be substantially larger than running average "
141-
+ average, rec.average() < 2 * average);
141+
+ average);
142142
}
143143
tx.commit();
144144
}

src/test/java/org/neo4j/gis/spatial/procedures/SpatialProceduresTest.java

+24-20
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
import static org.hamcrest.Matchers.equalTo;
2828
import static org.hamcrest.Matchers.hasKey;
2929
import static org.hamcrest.Matchers.not;
30+
import static org.junit.jupiter.api.Assertions.assertEquals;
31+
import static org.junit.jupiter.api.Assertions.assertFalse;
32+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
33+
import static org.junit.jupiter.api.Assertions.assertTrue;
3034
import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME;
3135
import static org.neo4j.gis.spatial.Constants.LABEL_LAYER;
3236
import static org.neo4j.gis.spatial.Constants.PROP_GEOMENCODER;
@@ -136,11 +140,11 @@ public static void testCallFails(GraphDatabaseService db, String call, Map<Strin
136140
public static void testCall(GraphDatabaseService db, String call, Map<String, Object> params,
137141
Consumer<Map<String, Object>> consumer, boolean onlyOne) {
138142
testResult(db, call, params, (res) -> {
139-
Assertions.assertTrue(res.hasNext(), "Expect at least one result but got none: " + call);
143+
assertTrue(res.hasNext(), "Expect at least one result but got none: " + call);
140144
Map<String, Object> row = res.next();
141145
consumer.accept(row);
142146
if (onlyOne) {
143-
Assertions.assertFalse(res.hasNext(), "Expected only one result, but there are more");
147+
assertFalse(res.hasNext(), "Expected only one result, but there are more");
144148
}
145149
});
146150
}
@@ -154,7 +158,7 @@ public static void testCallCount(GraphDatabaseService db, String call, Map<Strin
154158
res.next();
155159
numLeft--;
156160
}
157-
Assertions.assertFalse(res.hasNext(), "Expected " + count + " results but there are more");
161+
assertFalse(res.hasNext(), "Expected " + count + " results but there are more");
158162
});
159163
}
160164

@@ -355,22 +359,22 @@ public void create_point_geometry_and_distance() {
355359
@Test
356360
public void create_point_and_return() {
357361
Object geometry = executeObject("RETURN point({latitude: 5.0, longitude: 4.0}) as geometry", "geometry");
358-
Assertions.assertTrue(geometry instanceof Geometry, "Should be Geometry type");
362+
assertInstanceOf(Geometry.class, geometry, "Should be Geometry type");
359363
}
360364

361365
@Test
362366
public void create_point_geometry_return() {
363367
Object geometry = executeObject(
364368
"WITH point({latitude: 5.0, longitude: 4.0}) as geom RETURN spatial.asGeometry(geom) AS geometry",
365369
"geometry");
366-
Assertions.assertTrue(geometry instanceof Geometry, "Should be Geometry type");
370+
assertInstanceOf(Geometry.class, geometry, "Should be Geometry type");
367371
}
368372

369373
@Test
370374
public void literal_geometry_return() {
371375
Object geometry = executeObject(
372376
"WITH spatial.asGeometry({latitude: 5.0, longitude: 4.0}) AS geometry RETURN geometry", "geometry");
373-
Assertions.assertTrue(geometry instanceof Geometry, "Should be Geometry type");
377+
assertInstanceOf(Geometry.class, geometry, "Should be Geometry type");
374378
}
375379

376380
@Test
@@ -379,7 +383,7 @@ public void create_node_decode_to_geometry() {
379383
Object geometry = executeObject(
380384
"CREATE (n:Node {geom:'POINT(4.0 5.0)'}) RETURN spatial.decodeGeometry('geom',n) AS geometry",
381385
"geometry");
382-
Assertions.assertTrue(geometry instanceof Geometry, "Should be Geometry type");
386+
assertInstanceOf(Geometry.class, geometry, "Should be Geometry type");
383387
}
384388

385389
@Test
@@ -781,31 +785,31 @@ public void add_a_node_to_the_spatial_rtree_index_for_simple_points() {
781785
execute("CALL spatial.addPointLayer('geom')");
782786
Node node = createNode("CREATE (n:Node {latitude:60.1,longitude:15.2}) RETURN n", "n");
783787
testCall(db, "MATCH (n:Node) WITH n CALL spatial.addNode('geom',n) YIELD node RETURN node",
784-
r -> Assertions.assertEquals(node, r.get("node")));
788+
r -> assertEquals(node, r.get("node")));
785789
}
786790

787791
@Test
788792
public void add_a_node_to_the_spatial_geohash_index_for_simple_points() {
789793
execute("CALL spatial.addPointLayerGeohash('geom')");
790794
Node node = createNode("CREATE (n:Node {latitude:60.1,longitude:15.2}) RETURN n", "n");
791795
testCall(db, "MATCH (n:Node) WITH n CALL spatial.addNode('geom',n) YIELD node RETURN node",
792-
r -> Assertions.assertEquals(node, r.get("node")));
796+
r -> assertEquals(node, r.get("node")));
793797
}
794798

795799
@Test
796800
public void add_a_node_to_the_spatial_zorder_index_for_simple_points() {
797801
execute("CALL spatial.addPointLayerZOrder('geom')");
798802
Node node = createNode("CREATE (n:Node {latitude:60.1,longitude:15.2}) RETURN n", "n");
799803
testCall(db, "MATCH (n:Node) WITH n CALL spatial.addNode('geom',n) YIELD node RETURN node",
800-
r -> Assertions.assertEquals(node, r.get("node")));
804+
r -> assertEquals(node, r.get("node")));
801805
}
802806

803807
@Test
804808
public void add_a_node_to_the_spatial_hilbert_index_for_simple_points() {
805809
execute("CALL spatial.addPointLayerHilbert('geom')");
806810
Node node = createNode("CREATE (n:Node {latitude:60.1,longitude:15.2}) RETURN n", "n");
807811
testCall(db, "MATCH (n:Node) WITH n CALL spatial.addNode('geom',n) YIELD node RETURN node",
808-
r -> Assertions.assertEquals(node, r.get("node")));
812+
r -> assertEquals(node, r.get("node")));
809813
}
810814

811815
@Test
@@ -836,7 +840,7 @@ public void add_a_node_to_multiple_different_indexes_for_both_simple_and_native_
836840
for (String encoder : encoders) {
837841
for (String indexType : indexes) {
838842
String layerName = (encoder + indexType).toLowerCase();
839-
testCall(db, "MATCH (node:Node) RETURN node", r -> Assertions.assertEquals(node, r.get("node")));
843+
testCall(db, "MATCH (node:Node) RETURN node", r -> assertEquals(node, r.get("node")));
840844
testCall(db, "MATCH (n:Node) WITH n CALL spatial.addNode('" + layerName + "',n) YIELD node RETURN node",
841845
r -> Assertions.assertEquals(node, r.get("node")));
842846
testCall(db, "CALL spatial.withinDistance('" + layerName + "',{lon:15.0,lat:60.0},100)",
@@ -908,15 +912,15 @@ public void add_a_node_to_the_spatial_index_short() {
908912
execute("CALL spatial.addPointLayerXY('geom','lon','lat')");
909913
Node node = createNode("CREATE (n:Node {lat:60.1,lon:15.2}) RETURN n", "n");
910914
testCall(db, "MATCH (n:Node) WITH n CALL spatial.addNode('geom',n) YIELD node RETURN node",
911-
r -> Assertions.assertEquals(node, r.get("node")));
915+
r -> assertEquals(node, r.get("node")));
912916
}
913917

914918
@Test
915919
public void add_a_node_to_the_spatial_index_short_with_geohash() {
916920
execute("CALL spatial.addPointLayerXY('geom','lon','lat','geohash')");
917921
Node node = createNode("CREATE (n:Node {lat:60.1,lon:15.2}) RETURN n", "n");
918922
testCall(db, "MATCH (n:Node) WITH n CALL spatial.addNode('geom',n) YIELD node RETURN node",
919-
r -> Assertions.assertEquals(node, r.get("node")));
923+
r -> assertEquals(node, r.get("node")));
920924
}
921925

922926
@Test
@@ -931,7 +935,7 @@ public void add_two_nodes_to_the_spatial_layer() {
931935
node1 = ((Node) row.get("n1")).getElementId();
932936
node2 = ((Node) row.get("n2")).getElementId();
933937
long count = (Long) row.get("count");
934-
Assertions.assertEquals(2L, count);
938+
assertEquals(2L, count);
935939
result.close();
936940
tx.commit();
937941
}
@@ -947,7 +951,7 @@ public void add_two_nodes_to_the_spatial_layer() {
947951
map("nodeId", node1)).next().get("node");
948952
Result removeResult = tx.execute("CALL spatial.removeNode('geom',$node) YIELD nodeId RETURN nodeId",
949953
map("node", node));
950-
Assertions.assertEquals(node1, removeResult.next().get("nodeId"));
954+
assertEquals(node1, removeResult.next().get("nodeId"));
951955
removeResult.close();
952956
tx.commit();
953957
}
@@ -959,7 +963,7 @@ public void add_two_nodes_to_the_spatial_layer() {
959963
try (Transaction tx = db.beginTx()) {
960964
Result removeResult = tx.execute("CALL spatial.removeNode.byId('geom',$nodeId) YIELD nodeId RETURN nodeId",
961965
map("nodeId", node2));
962-
Assertions.assertEquals(node2, removeResult.next().get("nodeId"));
966+
assertEquals(node2, removeResult.next().get("nodeId"));
963967
removeResult.close();
964968
tx.commit();
965969
}
@@ -1227,10 +1231,10 @@ private void testCountQuery(String name, String query, long count, String column
12271231
}
12281232
long start = System.currentTimeMillis();
12291233
testResult(db, query, params, res -> {
1230-
Assertions.assertTrue(res.hasNext(), "Expected a single result");
1234+
Assertions.assertTrue(res.hasNext(), "Expected a single result");
12311235
long c = (Long) res.next().get(column);
1232-
Assertions.assertFalse(res.hasNext(), "Expected a single result");
1233-
Assertions.assertEquals(count, c, "Expected count of " + count + " nodes but got " + c);
1236+
assertFalse(res.hasNext(), "Expected a single result");
1237+
assertEquals(count, c, "Expected count of " + count + " nodes but got " + c);
12341238
}
12351239
);
12361240
System.out.println(name + " query took " + (System.currentTimeMillis() - start) + "ms - " + params);

0 commit comments

Comments
 (0)