@@ -101,14 +101,6 @@ public static void testCall(GraphDatabaseService db, String call, Consumer<Map<S
101101 testCall (db , call , null , consumer );
102102 }
103103
104- public static Map <String , Object > map (Object ... values ) {
105- Map <String , Object > map = new LinkedHashMap <>();
106- for (int i = 0 ; i < values .length ; i += 2 ) {
107- map .put (values [i ].toString (), values [i + 1 ]);
108- }
109- return map ;
110- }
111-
112104 public static void testCall (GraphDatabaseService db , String call , Map <String , Object > params ,
113105 Consumer <Map <String , Object >> consumer ) {
114106 testCall (db , call , params , consumer , true );
@@ -159,7 +151,7 @@ public static void testResult(GraphDatabaseService db, String call, Consumer<Res
159151 public static void testResult (GraphDatabaseService db , String call , Map <String , Object > params ,
160152 Consumer <Result > resultConsumer ) {
161153 try (Transaction tx = db .beginTx ()) {
162- Map <String , Object > p = (params == null ) ? map () : params ;
154+ Map <String , Object > p = (params == null ) ? Map . of () : params ;
163155 resultConsumer .accept (tx .execute (call , p ));
164156 tx .commit ();
165157 }
@@ -231,7 +223,7 @@ public void old_spatial_model_can_be_upgraded() {
231223 public void add_node_to_non_existing_layer () {
232224 execute ("CALL spatial.addPointLayer('some_name')" );
233225 Node node = createNode ("CREATE (n:Point {latitude:60.1,longitude:15.2}) RETURN n" , "n" );
234- testCallFails (db , "CALL spatial.addNode.byId('wrong_name',$nodeId)" , map ("nodeId" , node .getElementId ()),
226+ testCallFails (db , "CALL spatial.addNode.byId('wrong_name',$nodeId)" , Map . of ("nodeId" , node .getElementId ()),
235227 "No such layer 'wrong_name'" );
236228 }
237229
@@ -380,7 +372,7 @@ public void create_node_and_convert_to_geometry() {
380372 "CREATE (n:Node {geom:'POINT(4.0 5.0)'}) RETURN spatial.decodeGeometry('geom',n) AS geometry" ,
381373 "geometry" );
382374 double distance = (Double ) executeObject ("RETURN point.distance($geom, point({y: 6.0, x: 4.0})) as distance" ,
383- map ("geom" , geom ), "distance" );
375+ Map . of ("geom" , geom ), "distance" );
384376 MatcherAssert .assertThat ("Expected the cartesian distance of 1.0" , distance , closeTo (1.0 , 0.00001 ));
385377 }
386378
@@ -391,7 +383,7 @@ public void create_point_and_pass_as_param() {
391383 "geometry" );
392384 double distance = (Double ) executeObject (
393385 "WITH spatial.asGeometry($geom) AS geometry RETURN point.distance(geometry, point({latitude: 5.1, longitude: 4.0})) as distance" ,
394- map ("geom" , geom ), "distance" );
386+ Map . of ("geom" , geom ), "distance" );
395387 MatcherAssert .assertThat ("Expected the geographic distance of 11132km" , distance , closeTo (11132.0 , 1.0 ));
396388 }
397389
@@ -443,7 +435,7 @@ private Object executeObject(String call, String column) {
443435 private Object executeObject (String call , Map <String , Object > params , String column ) {
444436 Object obj ;
445437 try (Transaction tx = db .beginTx ()) {
446- Map <String , Object > p = (params == null ) ? map () : params ;
438+ Map <String , Object > p = (params == null ) ? Map . of () : params ;
447439 ResourceIterator <Object > values = tx .execute (call , p ).columnAs (column );
448440 obj = values .next ();
449441 values .close ();
@@ -630,7 +622,7 @@ public void create_a_wkt_layer_using_know_format() {
630622 public void list_layer_names () {
631623 String wkt = "LINESTRING (15.2 60.1, 15.3 60.1)" ;
632624 execute ("CALL spatial.addWKTLayer('geom','wkt')" );
633- execute ("CALL spatial.addWKT('geom',$wkt)" , map ("wkt" , wkt ));
625+ execute ("CALL spatial.addWKT('geom',$wkt)" , Map . of ("wkt" , wkt ));
634626
635627 testCall (db , "CALL spatial.layers()" , (r ) -> {
636628 assertEquals ("geom" , r .get ("name" ));
@@ -654,14 +646,14 @@ public void add_and_remove_multiple_layers() {
654646 for (int i = 0 ; i < NUM_LAYERS ; i ++) {
655647 String name = "wktLayer_" + i ;
656648 testCallCount (db , "CALL spatial.layers()" , null , i );
657- execute ("CALL spatial.addWKTLayer($layerName,'wkt')" , map ("layerName" , name ));
658- execute ("CALL spatial.addWKT($layerName,$wkt)" , map ("wkt" , wkt , "layerName" , name ));
649+ execute ("CALL spatial.addWKTLayer($layerName,'wkt')" , Map . of ("layerName" , name ));
650+ execute ("CALL spatial.addWKT($layerName,$wkt)" , Map . of ("wkt" , wkt , "layerName" , name ));
659651 testCallCount (db , "CALL spatial.layers()" , null , i + 1 );
660652 }
661653 for (int i = 0 ; i < NUM_LAYERS ; i ++) {
662654 String name = "wktLayer_" + i ;
663655 testCallCount (db , "CALL spatial.layers()" , null , NUM_LAYERS - i );
664- execute ("CALL spatial.removeLayer($layerName)" , map ("layerName" , name ));
656+ execute ("CALL spatial.removeLayer($layerName)" , Map . of ("layerName" , name ));
665657 testCallCount (db , "CALL spatial.layers()" , null , NUM_LAYERS - i - 1 );
666658 }
667659 testCallCount (db , "CALL spatial.layers()" , null , 0 );
@@ -752,7 +744,7 @@ public void list_layer_types() {
752744 public void find_layer () {
753745 String wkt = "LINESTRING (15.2 60.1, 15.3 60.1)" ;
754746 execute ("CALL spatial.addWKTLayer('geom','wkt')" );
755- execute ("CALL spatial.addWKT('geom',$wkt)" , map ("wkt" , wkt ));
747+ execute ("CALL spatial.addWKT('geom',$wkt)" , Map . of ("wkt" , wkt ));
756748
757749 testCall (db , "CALL spatial.layer('geom')" ,
758750 (r ) -> assertEquals ("geom" , (dump ((Node ) r .get ("node" ))).getProperty ("layer" )));
@@ -927,9 +919,9 @@ public void add_two_nodes_to_the_spatial_layer() {
927919 });
928920 try (Transaction tx = db .beginTx ()) {
929921 Node node = (Node ) tx .execute ("MATCH (node) WHERE elementId(node) = $nodeId RETURN node" ,
930- map ("nodeId" , node1 )).next ().get ("node" );
922+ Map . of ("nodeId" , node1 )).next ().get ("node" );
931923 Result removeResult = tx .execute ("CALL spatial.removeNode('geom',$node) YIELD nodeId RETURN nodeId" ,
932- map ("node" , node ));
924+ Map . of ("node" , node ));
933925 assertEquals (node1 , removeResult .next ().get ("nodeId" ));
934926 removeResult .close ();
935927 tx .commit ();
@@ -941,7 +933,7 @@ public void add_two_nodes_to_the_spatial_layer() {
941933 });
942934 try (Transaction tx = db .beginTx ()) {
943935 Result removeResult = tx .execute ("CALL spatial.removeNode.byId('geom',$nodeId) YIELD nodeId RETURN nodeId" ,
944- map ("nodeId" , node2 ));
936+ Map . of ("nodeId" , node2 ));
945937 assertEquals (node2 , removeResult .next ().get ("nodeId" ));
946938 removeResult .close ();
947939 tx .commit ();
@@ -960,7 +952,7 @@ public void add_many_nodes_to_the_simple_point_layer_using_addNodes() {
960952 "WITH collect(n) as points\n " +
961953 "CALL spatial.addNodes('simple_poi',points) YIELD count\n " +
962954 "RETURN count" ;
963- testCountQuery ("addNodes" , query , count , "count" , map ("count" , count ));
955+ testCountQuery ("addNodes" , query , count , "count" , Map . of ("count" , count ));
964956 testRemoveNodes ("simple_poi" , count );
965957 }
966958
@@ -974,7 +966,7 @@ public void add_many_nodes_to_the_simple_point_layer_using_addNode() {
974966 "WITH n\n " +
975967 "CALL spatial.addNode('simple_poi',n) YIELD node\n " +
976968 "RETURN count(node)" ;
977- testCountQuery ("addNode" , query , count , "count(node)" , map ("count" , count ));
969+ testCountQuery ("addNode" , query , count , "count(node)" , Map . of ("count" , count ));
978970 testRemoveNode ("simple_poi" , count );
979971 }
980972
@@ -989,7 +981,7 @@ public void add_many_nodes_to_the_native_point_layer_using_addNodes() {
989981 "WITH collect(n) as points\n " +
990982 "CALL spatial.addNodes('native_poi',points) YIELD count\n " +
991983 "RETURN count" ;
992- testCountQuery ("addNodes" , query , count , "count" , map ("count" , count ));
984+ testCountQuery ("addNodes" , query , count , "count" , Map . of ("count" , count ));
993985 testRemoveNodes ("native_poi" , count );
994986 }
995987
@@ -1004,7 +996,7 @@ public void add_many_nodes_to_the_native_point_layer_using_addNode() {
1004996 "WITH n\n " +
1005997 "CALL spatial.addNode('native_poi',n) YIELD node\n " +
1006998 "RETURN count(node)" ;
1007- testCountQuery ("addNode" , query , count , "count(node)" , map ("count" , count ));
999+ testCountQuery ("addNode" , query , count , "count(node)" , Map . of ("count" , count ));
10081000 testRemoveNode ("native_poi" , count );
10091001 }
10101002
@@ -1019,7 +1011,7 @@ private void testRemoveNode(String layer, int count) {
10191011 "WITH n\n " +
10201012 "CALL spatial.removeNode('" + layer + "',n) YIELD nodeId\n " +
10211013 "RETURN count(nodeId)" ;
1022- testCountQuery ("removeNode" , remove , count / 2 , "count(nodeId)" , map ("count" , count / 2 ));
1014+ testCountQuery ("removeNode" , remove , count / 2 , "count(nodeId)" , Map . of ("count" , count / 2 ));
10231015 // Check that only half remain
10241016 testCountQuery ("withinDistance" ,
10251017 "CALL spatial.withinDistance('" + layer + "',{lon:15.0,lat:60.0},1000) YIELD node RETURN count(node)" ,
@@ -1037,7 +1029,7 @@ private void testRemoveNodes(String layer, int count) {
10371029 "WITH collect(n) as points\n " +
10381030 "CALL spatial.removeNodes('" + layer + "',points) YIELD count\n " +
10391031 "RETURN count" ;
1040- testCountQuery ("removeNodes" , remove , count / 2 , "count" , map ("count" , count / 2 ));
1032+ testCountQuery ("removeNodes" , remove , count / 2 , "count" , Map . of ("count" , count / 2 ));
10411033 // Check that only half remain
10421034 testCountQuery ("withinDistance" ,
10431035 "CALL spatial.withinDistance('" + layer + "',{lon:15.0,lat:60.0},1000) YIELD node RETURN count(node)" ,
@@ -1146,7 +1138,7 @@ public void import_osm_and_add_geometry() {
11461138
11471139 @ Test
11481140 public void import_osm_and_polygons_withinDistance () {
1149- Map <String , Object > params = map ("osmFile" , "withinDistance.osm" , "busShelterID" , 2938842290L );
1141+ Map <String , Object > params = Map . of ("osmFile" , "withinDistance.osm" , "busShelterID" , 2938842290L );
11501142 execute ("CALL spatial.addLayer('geom','OSM','')" );
11511143 testCountQuery ("importOSMAndPolygonsWithinDistance" , "CALL spatial.importOSMToLayer('geom',$osmFile)" , 74 ,
11521144 "count" , params );
@@ -1204,18 +1196,17 @@ public void import_osm_and_polygons_withinDistance() {
12041196 private void testCountQuery (String name , String query , long count , String column , Map <String , Object > params ) {
12051197 // warmup
12061198 try (Transaction tx = db .beginTx ()) {
1207- Result results = tx .execute ("EXPLAIN " + query , params == null ? map () : params );
1199+ Result results = tx .execute ("EXPLAIN " + query , params == null ? Map . of () : params );
12081200 results .close ();
12091201 tx .commit ();
12101202 }
12111203 long start = System .currentTimeMillis ();
12121204 testResult (db , query , params , res -> {
12131205 assertTrue (res .hasNext (), "Expected a single result" );
1214- long c = (Long ) res .next ().get (column );
1206+ long c = (Long ) res .next ().get (column );
12151207 assertFalse (res .hasNext (), "Expected a single result" );
12161208 assertEquals (count , c , "Expected count of " + count + " nodes but got " + c );
1217- }
1218- );
1209+ });
12191210 System .out .println (name + " query took " + (System .currentTimeMillis () - start ) + "ms - " + params );
12201211 }
12211212
@@ -1326,15 +1317,15 @@ public void add_a_WKT_geometry_to_a_layer() {
13261317 String lineString = "LINESTRING (15.2 60.1, 15.3 60.1)" ;
13271318
13281319 execute ("CALL spatial.addWKTLayer('geom','wkt')" );
1329- testCall (db , "CALL spatial.addWKT('geom',$wkt)" , map ("wkt" , lineString ),
1320+ testCall (db , "CALL spatial.addWKT('geom',$wkt)" , Map . of ("wkt" , lineString ),
13301321 r -> assertEquals (lineString , dump (((Node ) r .get ("node" ))).getProperty ("wkt" )));
13311322 }
13321323
13331324 @ Test
13341325 public void find_geometries_close_to_a_point_wkt () {
13351326 String lineString = "LINESTRING (15.2 60.1, 15.3 60.1)" ;
13361327 execute ("CALL spatial.addLayer('geom','WKT','wkt')" );
1337- execute ("CALL spatial.addWKT('geom',$wkt)" , map ("wkt" , lineString ));
1328+ execute ("CALL spatial.addWKT('geom',$wkt)" , Map . of ("wkt" , lineString ));
13381329 testCall (db , "CALL spatial.closest('geom',{lon:15.2, lat:60.1}, 1.0)" ,
13391330 r -> assertEquals (lineString , (dump ((Node ) r .get ("node" ))).getProperty ("wkt" )));
13401331 }
@@ -1343,23 +1334,23 @@ public void find_geometries_close_to_a_point_wkt() {
13431334 public void find_geometries_close_to_a_point_geohash () {
13441335 String lineString = "POINT (15.2 60.1)" ;
13451336 execute ("CALL spatial.addLayer('geom','geohash','lon:lat')" );
1346- execute ("CALL spatial.addWKT('geom',$wkt)" , map ("wkt" , lineString ));
1337+ execute ("CALL spatial.addWKT('geom',$wkt)" , Map . of ("wkt" , lineString ));
13471338 testCallCount (db , "CALL spatial.closest('geom',{lon:15.2, lat:60.1}, 1.0)" , null , 1 );
13481339 }
13491340
13501341 @ Test
13511342 public void find_geometries_close_to_a_point_zorder () {
13521343 String lineString = "POINT (15.2 60.1)" ;
13531344 execute ("CALL spatial.addLayer('geom','zorder','lon:lat')" );
1354- execute ("CALL spatial.addWKT('geom',$wkt)" , map ("wkt" , lineString ));
1345+ execute ("CALL spatial.addWKT('geom',$wkt)" , Map . of ("wkt" , lineString ));
13551346 testCallCount (db , "CALL spatial.closest('geom',{lon:15.2, lat:60.1}, 1.0)" , null , 1 );
13561347 }
13571348
13581349 @ Test
13591350 public void find_geometries_close_to_a_point_hilbert () {
13601351 String lineString = "POINT (15.2 60.1)" ;
13611352 execute ("CALL spatial.addLayer('geom','hilbert','lon:lat')" );
1362- execute ("CALL spatial.addWKT('geom',$wkt)" , map ("wkt" , lineString ));
1353+ execute ("CALL spatial.addWKT('geom',$wkt)" , Map . of ("wkt" , lineString ));
13631354 testCallCount (db , "CALL spatial.closest('geom',{lon:15.2, lat:60.1}, 1.0)" , null , 1 );
13641355 }
13651356
0 commit comments