27
27
import static org .hamcrest .Matchers .equalTo ;
28
28
import static org .hamcrest .Matchers .hasKey ;
29
29
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 ;
30
34
import static org .neo4j .configuration .GraphDatabaseSettings .DEFAULT_DATABASE_NAME ;
31
35
import static org .neo4j .gis .spatial .Constants .LABEL_LAYER ;
32
36
import static org .neo4j .gis .spatial .Constants .PROP_GEOMENCODER ;
@@ -136,11 +140,11 @@ public static void testCallFails(GraphDatabaseService db, String call, Map<Strin
136
140
public static void testCall (GraphDatabaseService db , String call , Map <String , Object > params ,
137
141
Consumer <Map <String , Object >> consumer , boolean onlyOne ) {
138
142
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 );
140
144
Map <String , Object > row = res .next ();
141
145
consumer .accept (row );
142
146
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" );
144
148
}
145
149
});
146
150
}
@@ -154,7 +158,7 @@ public static void testCallCount(GraphDatabaseService db, String call, Map<Strin
154
158
res .next ();
155
159
numLeft --;
156
160
}
157
- Assertions . assertFalse (res .hasNext (), "Expected " + count + " results but there are more" );
161
+ assertFalse (res .hasNext (), "Expected " + count + " results but there are more" );
158
162
});
159
163
}
160
164
@@ -355,22 +359,22 @@ public void create_point_geometry_and_distance() {
355
359
@ Test
356
360
public void create_point_and_return () {
357
361
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" );
359
363
}
360
364
361
365
@ Test
362
366
public void create_point_geometry_return () {
363
367
Object geometry = executeObject (
364
368
"WITH point({latitude: 5.0, longitude: 4.0}) as geom RETURN spatial.asGeometry(geom) AS geometry" ,
365
369
"geometry" );
366
- Assertions . assertTrue ( geometry instanceof Geometry , "Should be Geometry type" );
370
+ assertInstanceOf ( Geometry . class , geometry , "Should be Geometry type" );
367
371
}
368
372
369
373
@ Test
370
374
public void literal_geometry_return () {
371
375
Object geometry = executeObject (
372
376
"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" );
374
378
}
375
379
376
380
@ Test
@@ -379,7 +383,7 @@ public void create_node_decode_to_geometry() {
379
383
Object geometry = executeObject (
380
384
"CREATE (n:Node {geom:'POINT(4.0 5.0)'}) RETURN spatial.decodeGeometry('geom',n) AS geometry" ,
381
385
"geometry" );
382
- Assertions . assertTrue ( geometry instanceof Geometry , "Should be Geometry type" );
386
+ assertInstanceOf ( Geometry . class , geometry , "Should be Geometry type" );
383
387
}
384
388
385
389
@ Test
@@ -781,31 +785,31 @@ public void add_a_node_to_the_spatial_rtree_index_for_simple_points() {
781
785
execute ("CALL spatial.addPointLayer('geom')" );
782
786
Node node = createNode ("CREATE (n:Node {latitude:60.1,longitude:15.2}) RETURN n" , "n" );
783
787
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" )));
785
789
}
786
790
787
791
@ Test
788
792
public void add_a_node_to_the_spatial_geohash_index_for_simple_points () {
789
793
execute ("CALL spatial.addPointLayerGeohash('geom')" );
790
794
Node node = createNode ("CREATE (n:Node {latitude:60.1,longitude:15.2}) RETURN n" , "n" );
791
795
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" )));
793
797
}
794
798
795
799
@ Test
796
800
public void add_a_node_to_the_spatial_zorder_index_for_simple_points () {
797
801
execute ("CALL spatial.addPointLayerZOrder('geom')" );
798
802
Node node = createNode ("CREATE (n:Node {latitude:60.1,longitude:15.2}) RETURN n" , "n" );
799
803
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" )));
801
805
}
802
806
803
807
@ Test
804
808
public void add_a_node_to_the_spatial_hilbert_index_for_simple_points () {
805
809
execute ("CALL spatial.addPointLayerHilbert('geom')" );
806
810
Node node = createNode ("CREATE (n:Node {latitude:60.1,longitude:15.2}) RETURN n" , "n" );
807
811
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" )));
809
813
}
810
814
811
815
@ Test
@@ -836,7 +840,7 @@ public void add_a_node_to_multiple_different_indexes_for_both_simple_and_native_
836
840
for (String encoder : encoders ) {
837
841
for (String indexType : indexes ) {
838
842
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" )));
840
844
testCall (db , "MATCH (n:Node) WITH n CALL spatial.addNode('" + layerName + "',n) YIELD node RETURN node" ,
841
845
r -> Assertions .assertEquals (node , r .get ("node" )));
842
846
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() {
908
912
execute ("CALL spatial.addPointLayerXY('geom','lon','lat')" );
909
913
Node node = createNode ("CREATE (n:Node {lat:60.1,lon:15.2}) RETURN n" , "n" );
910
914
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" )));
912
916
}
913
917
914
918
@ Test
915
919
public void add_a_node_to_the_spatial_index_short_with_geohash () {
916
920
execute ("CALL spatial.addPointLayerXY('geom','lon','lat','geohash')" );
917
921
Node node = createNode ("CREATE (n:Node {lat:60.1,lon:15.2}) RETURN n" , "n" );
918
922
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" )));
920
924
}
921
925
922
926
@ Test
@@ -931,7 +935,7 @@ public void add_two_nodes_to_the_spatial_layer() {
931
935
node1 = ((Node ) row .get ("n1" )).getElementId ();
932
936
node2 = ((Node ) row .get ("n2" )).getElementId ();
933
937
long count = (Long ) row .get ("count" );
934
- Assertions . assertEquals (2L , count );
938
+ assertEquals (2L , count );
935
939
result .close ();
936
940
tx .commit ();
937
941
}
@@ -947,7 +951,7 @@ public void add_two_nodes_to_the_spatial_layer() {
947
951
map ("nodeId" , node1 )).next ().get ("node" );
948
952
Result removeResult = tx .execute ("CALL spatial.removeNode('geom',$node) YIELD nodeId RETURN nodeId" ,
949
953
map ("node" , node ));
950
- Assertions . assertEquals (node1 , removeResult .next ().get ("nodeId" ));
954
+ assertEquals (node1 , removeResult .next ().get ("nodeId" ));
951
955
removeResult .close ();
952
956
tx .commit ();
953
957
}
@@ -959,7 +963,7 @@ public void add_two_nodes_to_the_spatial_layer() {
959
963
try (Transaction tx = db .beginTx ()) {
960
964
Result removeResult = tx .execute ("CALL spatial.removeNode.byId('geom',$nodeId) YIELD nodeId RETURN nodeId" ,
961
965
map ("nodeId" , node2 ));
962
- Assertions . assertEquals (node2 , removeResult .next ().get ("nodeId" ));
966
+ assertEquals (node2 , removeResult .next ().get ("nodeId" ));
963
967
removeResult .close ();
964
968
tx .commit ();
965
969
}
@@ -1227,10 +1231,10 @@ private void testCountQuery(String name, String query, long count, String column
1227
1231
}
1228
1232
long start = System .currentTimeMillis ();
1229
1233
testResult (db , query , params , res -> {
1230
- Assertions .assertTrue (res .hasNext (), "Expected a single result" );
1234
+ Assertions .assertTrue (res .hasNext (), "Expected a single result" );
1231
1235
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 );
1234
1238
}
1235
1239
);
1236
1240
System .out .println (name + " query took " + (System .currentTimeMillis () - start ) + "ms - " + params );
0 commit comments