neography 1.3.14 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/neography/rest.rb +29 -472
  3. data/lib/neography/rest/batch.rb +80 -87
  4. data/lib/neography/rest/clean.rb +8 -10
  5. data/lib/neography/rest/constraints.rb +15 -25
  6. data/lib/neography/rest/cypher.rb +2 -6
  7. data/lib/neography/rest/extensions.rb +4 -8
  8. data/lib/neography/rest/gremlin.rb +2 -6
  9. data/lib/neography/rest/helpers.rb +58 -0
  10. data/lib/neography/rest/node_auto_indexes.rb +54 -8
  11. data/lib/neography/rest/node_indexes.rb +92 -17
  12. data/lib/neography/rest/node_labels.rb +15 -26
  13. data/lib/neography/rest/node_paths.rb +8 -16
  14. data/lib/neography/rest/node_properties.rb +45 -4
  15. data/lib/neography/rest/node_relationships.rb +8 -17
  16. data/lib/neography/rest/node_traversal.rb +7 -63
  17. data/lib/neography/rest/nodes.rb +21 -29
  18. data/lib/neography/rest/other_node_relationships.rb +6 -13
  19. data/lib/neography/rest/relationship_auto_indexes.rb +54 -8
  20. data/lib/neography/rest/relationship_indexes.rb +104 -14
  21. data/lib/neography/rest/relationship_properties.rb +45 -4
  22. data/lib/neography/rest/relationship_types.rb +4 -11
  23. data/lib/neography/rest/relationships.rb +6 -13
  24. data/lib/neography/rest/schema_indexes.rb +8 -16
  25. data/lib/neography/rest/spatial.rb +16 -33
  26. data/lib/neography/rest/transactions.rb +25 -26
  27. data/lib/neography/tasks.rb +2 -2
  28. data/lib/neography/version.rb +1 -1
  29. data/spec/unit/rest/batch_spec.rb +49 -50
  30. data/spec/unit/rest/clean_spec.rb +3 -4
  31. data/spec/unit/rest/constraints_spec.rb +12 -13
  32. data/spec/unit/rest/cypher_spec.rb +3 -4
  33. data/spec/unit/rest/extensions_spec.rb +5 -6
  34. data/spec/unit/rest/gremlin_spec.rb +5 -6
  35. data/spec/unit/rest/helpers_spec.rb +124 -0
  36. data/spec/unit/rest/labels_spec.rb +21 -22
  37. data/spec/unit/rest/node_auto_indexes_spec.rb +23 -24
  38. data/spec/unit/rest/node_indexes_spec.rb +42 -43
  39. data/spec/unit/rest/node_paths_spec.rb +10 -13
  40. data/spec/unit/rest/node_properties_spec.rb +22 -23
  41. data/spec/unit/rest/node_relationships_spec.rb +18 -39
  42. data/spec/unit/rest/node_traversal_spec.rb +4 -97
  43. data/spec/unit/rest/nodes_spec.rb +47 -48
  44. data/spec/unit/rest/relationship_auto_indexes_spec.rb +23 -24
  45. data/spec/unit/rest/relationship_indexes_spec.rb +42 -43
  46. data/spec/unit/rest/relationship_properties_spec.rb +22 -23
  47. data/spec/unit/rest/relationship_types_spec.rb +3 -4
  48. data/spec/unit/rest/relationships_spec.rb +5 -6
  49. data/spec/unit/rest/schema_index_spec.rb +7 -8
  50. data/spec/unit/rest/transactions_spec.rb +10 -11
  51. metadata +27 -31
  52. data/lib/neography/rest/auto_indexes.rb +0 -64
  53. data/lib/neography/rest/indexes.rb +0 -102
  54. data/lib/neography/rest/paths.rb +0 -46
  55. data/lib/neography/rest/properties.rb +0 -56
  56. data/spec/unit/rest/paths_spec.rb +0 -69
@@ -1,10 +1,51 @@
1
1
  module Neography
2
2
  class Rest
3
- class RelationshipProperties < Properties
4
- extend Neography::Rest::Paths
3
+ module RelationshipProperties
4
+
5
+ def set_relationship_properties(id, properties)
6
+ properties.each do |property, value|
7
+ options = { :body => value.to_json, :headers => json_content_type }
8
+ @connection.put("/relationship/%{id}/properties/%{property}" % {:id => get_id(id), :property => property}, options)
9
+ end
10
+ end
11
+
12
+ def reset_relationship_properties(id, properties)
13
+ options = { :body => properties.to_json, :headers => json_content_type }
14
+ @connection.put("/relationship/%{id}/properties" % {:id => get_id(id)}, options)
15
+ end
16
+
17
+ def get_relationship_properties(id, *properties)
18
+ if properties.none?
19
+ @connection.get("/relationship/%{id}/properties" % {:id => get_id(id)})
20
+ else
21
+ get_each_relationship_properties(id, *properties)
22
+ end
23
+ end
24
+
25
+ def get_each_relationship_properties(id, *properties)
26
+ retrieved_properties = properties.flatten.inject({}) do |memo, property|
27
+ value = @connection.get("/relationship/%{id}/properties/%{property}" % {:id => get_id(id), :property => property})
28
+ memo[property] = value unless value.nil?
29
+ memo
30
+ end
31
+ return nil if retrieved_properties.empty?
32
+ retrieved_properties
33
+ end
34
+
35
+ def remove_relationship_properties(id, *properties)
36
+ if properties.none?
37
+ @connection.delete("/relationship/%{id}/properties" % {:id => get_id(id)})
38
+ else
39
+ remove_each_relationship_properties(id, *properties)
40
+ end
41
+ end
42
+
43
+ def remove_each_relationship_properties(id, *properties)
44
+ properties.flatten.each do |property|
45
+ @connection.delete("/relationship/%{id}/properties/%{property}" % {:id => get_id(id), :property => property})
46
+ end
47
+ end
5
48
 
6
- add_path :all, "/relationship/:id/properties"
7
- add_path :single, "/relationship/:id/properties/:property"
8
49
 
9
50
  end
10
51
  end
@@ -1,16 +1,9 @@
1
1
  module Neography
2
2
  class Rest
3
- class RelationshipTypes
4
- extend Neography::Rest::Paths
5
-
6
- add_path :all, "/relationship/types"
7
-
8
- def initialize(connection)
9
- @connection ||= connection
10
- end
11
-
12
- def list
13
- @connection.get(all_path)
3
+ module RelationshipTypes
4
+
5
+ def list_relationship_types
6
+ @connection.get("/relationship/types")
14
7
  end
15
8
 
16
9
  end
@@ -1,21 +1,14 @@
1
1
  module Neography
2
2
  class Rest
3
- class Relationships
4
- extend Neography::Rest::Paths
3
+ module Relationships
5
4
  include Neography::Rest::Helpers
6
-
7
- add_path :base, "/relationship/:id"
8
-
9
- def initialize(connection)
10
- @connection ||= connection
11
- end
12
-
13
- def get(id)
14
- @connection.get(base_path(:id => get_id(id)))
5
+
6
+ def get_relationship(id)
7
+ @connection.get("/relationship/%{id}" % {:id => get_id(id)})
15
8
  end
16
9
 
17
- def delete(id)
18
- @connection.delete(base_path(:id => get_id(id)))
10
+ def delete_relationship(id)
11
+ @connection.delete("/relationship/%{id}" % {:id => get_id(id)})
19
12
  end
20
13
 
21
14
  end
@@ -1,25 +1,17 @@
1
1
  module Neography
2
2
  class Rest
3
- class SchemaIndexes
4
- extend Neography::Rest::Paths
3
+ module SchemaIndexes
5
4
  include Neography::Rest::Helpers
6
-
7
- add_path :base, "/schema/index/:label"
8
- add_path :drop, "/schema/index/:label/:index"
9
-
10
- def initialize(connection)
11
- @connection ||= connection
12
- end
13
-
14
- def list(label)
15
- @connection.get(base_path(:label => label))
5
+
6
+ def get_schema_index(label)
7
+ @connection.get("/schema/index/%{label}" % {:label => label})
16
8
  end
17
9
 
18
- def drop(label, index)
19
- @connection.delete(drop_path(:label => label, :index => index))
10
+ def delete_schema_index(label, index)
11
+ @connection.delete("/schema/index/%{label}/%{index}" % {:label => label, :index => index})
20
12
  end
21
13
 
22
- def create(label, keys = [])
14
+ def create_schema_index(label, keys = [])
23
15
  options = {
24
16
  :body => (
25
17
  { :property_keys => keys
@@ -27,7 +19,7 @@ module Neography
27
19
  ).to_json,
28
20
  :headers => json_content_type
29
21
  }
30
- @connection.post(base_path(:label => label), options)
22
+ @connection.post("/schema/index/%{label}" % {:label => label}, options)
31
23
  end
32
24
  end
33
25
  end
@@ -1,30 +1,13 @@
1
1
  module Neography
2
2
  class Rest
3
- class Spatial
4
- extend Neography::Rest::Paths
3
+ module Spatial
5
4
  include Neography::Rest::Helpers
6
-
7
- add_path :index, "/ext/SpatialPlugin"
8
- add_path :add_simple_point_layer, "/ext/SpatialPlugin/graphdb/addSimplePointLayer"
9
- add_path :add_editable_layer, "/ext/SpatialPlugin/graphdb/addEditableLayer"
10
- add_path :get_layer, "/ext/SpatialPlugin/graphdb/getLayer"
11
- add_path :add_geometry_to_layer, "/ext/SpatialPlugin/graphdb/addGeometryWKTToLayer"
12
- add_path :edit_geometry_from_layer, "/ext/SpatialPlugin/graphdb/updateGeometryFromWKT"
13
- add_path :add_node_to_layer, "/ext/SpatialPlugin/graphdb/addNodeToLayer"
14
- add_path :find_geometries_in_bbox, "/ext/SpatialPlugin/graphdb/findGeometriesInBBox"
15
- add_path :find_geometries_within_distance,"/ext/SpatialPlugin/graphdb/findGeometriesWithinDistance"
16
- add_path :create_index, "/index/node"
17
- add_path :add_to_index, "/index/node/:index"
18
-
19
- def initialize(connection)
20
- @connection ||= connection
21
- end
22
-
23
- def index
24
- @connection.get(index_path)
5
+
6
+ def get_spatial
7
+ @connection.get("/ext/SpatialPlugin")
25
8
  end
26
9
 
27
- def add_point_layer(layer, lat, lon)
10
+ def add_point_layer(layer, lat = nil, lon = nil)
28
11
  options = {
29
12
  :body => {
30
13
  :layer => layer,
@@ -34,7 +17,7 @@ module Neography
34
17
  :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
35
18
  }
36
19
 
37
- @connection.post(add_simple_point_layer_path, options)
20
+ @connection.post("/ext/SpatialPlugin/graphdb/addSimplePointLayer", options)
38
21
  end
39
22
 
40
23
  def add_editable_layer(layer, format = "WKT", node_property_name = "wkt")
@@ -47,7 +30,7 @@ module Neography
47
30
  :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
48
31
  }
49
32
 
50
- @connection.post(add_editable_layer_path, options)
33
+ @connection.post("/ext/SpatialPlugin/graphdb/addEditableLayer", options)
51
34
  end
52
35
 
53
36
  def get_layer(layer)
@@ -57,7 +40,7 @@ module Neography
57
40
  }.to_json,
58
41
  :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
59
42
  }
60
- @connection.post(get_layer_path, options)
43
+ @connection.post("/ext/SpatialPlugin/graphdb/getLayer", options)
61
44
  end
62
45
 
63
46
  def add_geometry_to_layer(layer, geometry)
@@ -68,7 +51,7 @@ module Neography
68
51
  }.to_json,
69
52
  :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
70
53
  }
71
- @connection.post(add_geometry_to_layer_path, options)
54
+ @connection.post("/ext/SpatialPlugin/graphdb/addGeometryWKTToLayer", options)
72
55
  end
73
56
 
74
57
  def edit_geometry_from_layer(layer, geometry, node)
@@ -80,7 +63,7 @@ module Neography
80
63
  }.to_json,
81
64
  :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
82
65
  }
83
- @connection.post(edit_geometry_from_layer_path, options)
66
+ @connection.post("/ext/SpatialPlugin/graphdb/updateGeometryFromWKT", options)
84
67
  end
85
68
 
86
69
  def add_node_to_layer(layer, node)
@@ -91,7 +74,7 @@ module Neography
91
74
  }.to_json,
92
75
  :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
93
76
  }
94
- @connection.post(add_node_to_layer_path, options)
77
+ @connection.post("/ext/SpatialPlugin/graphdb/addNodeToLayer", options)
95
78
  end
96
79
 
97
80
  def find_geometries_in_bbox(layer, minx, maxx, miny, maxy)
@@ -105,7 +88,7 @@ module Neography
105
88
  }.to_json,
106
89
  :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
107
90
  }
108
- @connection.post(find_geometries_in_bbox_path, options)
91
+ @connection.post("/ext/SpatialPlugin/graphdb/findGeometriesInBBox", options)
109
92
  end
110
93
 
111
94
  def find_geometries_within_distance(layer, pointx, pointy, distance)
@@ -118,10 +101,10 @@ module Neography
118
101
  }.to_json,
119
102
  :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
120
103
  }
121
- @connection.post(find_geometries_within_distance_path, options)
104
+ @connection.post("/ext/SpatialPlugin/graphdb/findGeometriesWithinDistance", options)
122
105
  end
123
106
 
124
- def create_spatial_index(name, type, lat, lon)
107
+ def create_spatial_index(name, type = nil, lat = nil, lon = nil)
125
108
  options = {
126
109
  :body => {
127
110
  :name => name,
@@ -134,7 +117,7 @@ module Neography
134
117
  }.to_json,
135
118
  :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
136
119
  }
137
- @connection.post(create_index_path, options)
120
+ @connection.post("/index/node", options)
138
121
  end
139
122
 
140
123
  def add_node_to_spatial_index(index, id)
@@ -146,7 +129,7 @@ module Neography
146
129
  }.to_json,
147
130
  :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
148
131
  }
149
- @connection.post(add_to_index_path(:index => index), options)
132
+ @connection.post("/index/node/%{index}" % {:index => index}, options)
150
133
  end
151
134
 
152
135
  end
@@ -1,54 +1,53 @@
1
1
  module Neography
2
2
  class Rest
3
- class Transactions
4
- extend Neography::Rest::Paths
3
+ module Transactions
5
4
  include Neography::Rest::Helpers
6
-
7
- add_path :base, "/transaction"
8
- add_path :tx, "/transaction/:id"
9
- add_path :commit, "/transaction/:id/commit"
10
-
11
- def initialize(connection)
12
- @connection ||= connection
13
- end
14
-
15
- def begin(statements = [], commit = "")
5
+
6
+ def begin_transaction(statements = [], commit = "")
16
7
  options = {
17
8
  :body => (
18
9
  convert_cypher(statements)
19
10
  ).to_json,
20
11
  :headers => json_content_type
21
12
  }
22
- @connection.post(base_path + commit, options)
13
+ @connection.post("/transaction" + commit, options)
23
14
  end
24
15
 
25
- def add(tx, statements = [])
16
+ def in_transaction(tx, statements = [])
26
17
  options = {
27
18
  :body => (
28
19
  convert_cypher(statements)
29
20
  ).to_json,
30
21
  :headers => json_content_type
31
22
  }
32
- @connection.post(tx_path(:id => get_id(tx)), options)
23
+ @connection.post("/transaction/%{id}" % {:id => get_tx_id(tx)}, options)
24
+ end
25
+
26
+ def keep_transaction(tx)
27
+ in_transaction(tx)
33
28
  end
34
29
 
35
- def commit(tx, statements = [])
36
- options = {
37
- :body => (
38
- convert_cypher(statements)
39
- ).to_json,
40
- :headers => json_content_type
41
- }
42
- @connection.post(commit_path(:id => get_id(tx)), options)
30
+ def commit_transaction(tx, statements = [])
31
+ if (tx.is_a?(Hash) || tx.is_a?(Integer))
32
+ options = {
33
+ :body => (
34
+ convert_cypher(statements)
35
+ ).to_json,
36
+ :headers => json_content_type
37
+ }
38
+ @connection.post("/transaction/%{id}/commit" % {:id => get_tx_id(tx)}, options)
39
+ else
40
+ begin_transaction(tx, "/commit")
41
+ end
43
42
  end
44
43
 
45
- def rollback(tx)
46
- @connection.delete(tx_path(:id => get_id(tx)))
44
+ def rollback_transaction(tx)
45
+ @connection.delete("/transaction/%{id}" % {:id => get_tx_id(tx)})
47
46
  end
48
47
 
49
48
  private
50
49
 
51
- def get_id(tx)
50
+ def get_tx_id(tx)
52
51
  return tx if tx.is_a?(Integer)
53
52
  return tx.split("/")[-2] if tx.is_a?(String)
54
53
  return tx["commit"].split("/")[-2] if tx["commit"]
@@ -163,8 +163,8 @@ namespace :neo4j do
163
163
  df = File.open('neo4j-spatial.zip', 'wb')
164
164
  case args[:version]
165
165
  when "2.0.1"
166
- dist = "dist.neo4j.org"
167
- request = "/spatial/neo4j-spatial-0.12-neo4j-2.0.1-server-plugin.zip"
166
+ dist = "m2.neo4j.org"
167
+ request = "/content/repositories/releases/org/neo4j/neo4j-spatial/0.13-neo4j-2.0.1/neo4j-spatial-0.13-neo4j-2.0.1-server-plugin.zip"
168
168
  when "2.0.0"
169
169
  dist = "dist.neo4j.org"
170
170
  request = "/spatial/neo4j-spatial-0.12-neo4j-2.0.0-server-plugin.zip"
@@ -1,3 +1,3 @@
1
1
  module Neography
2
- VERSION = "1.3.14"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -4,8 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe Batch do
6
6
 
7
- let(:connection) { double(:gremlin_path => "/gremlin", :cypher_path => "/cypher") }
8
- subject { Batch.new(connection) }
7
+ subject { Neography::Rest.new }
9
8
 
10
9
  it "gets nodes" do
11
10
  expected_body = [
@@ -13,8 +12,8 @@ module Neography
13
12
  { "id" => 1, "method" => "GET", "to" => "/node/bar" }
14
13
  ]
15
14
 
16
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
17
- subject.execute [:get_node, "foo"], [:get_node, "bar"]
15
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
16
+ subject.batch [:get_node, "foo"], [:get_node, "bar"]
18
17
  end
19
18
 
20
19
  it "creates nodes" do
@@ -23,8 +22,8 @@ module Neography
23
22
  { "id" => 1, "method" => "POST", "to" => "/node", "body" => { "baz" => "qux" } }
24
23
  ]
25
24
 
26
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
27
- subject.execute [:create_node, { "foo" => "bar" }], [:create_node, { "baz" => "qux" }]
25
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
26
+ subject.batch [:create_node, { "foo" => "bar" }], [:create_node, { "baz" => "qux" }]
28
27
  end
29
28
 
30
29
  it "deletes nodes" do
@@ -33,8 +32,8 @@ module Neography
33
32
  { "id" => 1, "method" => "DELETE", "to" => "/node/bar" }
34
33
  ]
35
34
 
36
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
37
- subject.execute [:delete_node, "foo"], [:delete_node, "bar"]
35
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
36
+ subject.batch [:delete_node, "foo"], [:delete_node, "bar"]
38
37
  end
39
38
 
40
39
  it "creates unique nodes" do
@@ -43,8 +42,8 @@ module Neography
43
42
  { "id" => 1, "method" => "POST", "to" => "/index/node/quux?unique", "body" => { "key" => "corge", "value" => "grault", "properties" => "garply" } }
44
43
  ]
45
44
 
46
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
47
- subject.execute [:create_unique_node, "foo", "bar", "baz", "qux" ],
45
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
46
+ subject.batch [:create_unique_node, "foo", "bar", "baz", "qux" ],
48
47
  [:create_unique_node, "quux", "corge", "grault", "garply"]
49
48
  end
50
49
 
@@ -54,8 +53,8 @@ module Neography
54
53
  { "id" => 1, "method" => "POST", "to" => "/index/node/quux", "body" => { "uri" => "{0}", "key" => "corge", "value" => "grault" } }
55
54
  ]
56
55
 
57
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
58
- subject.execute [:add_node_to_index, "foo", "bar", "baz", "qux" ],
56
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
57
+ subject.batch [:add_node_to_index, "foo", "bar", "baz", "qux" ],
59
58
  [:add_node_to_index, "quux", "corge", "grault", "{0}"]
60
59
  end
61
60
 
@@ -65,8 +64,8 @@ module Neography
65
64
  { "id" => 1, "method" => "GET", "to" => "/index/node/qux/quux/corge" }
66
65
  ]
67
66
 
68
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
69
- subject.execute [:get_node_index, "foo", "bar", "baz" ],
67
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
68
+ subject.batch [:get_node_index, "foo", "bar", "baz" ],
70
69
  [:get_node_index, "qux", "quux", "corge" ]
71
70
  end
72
71
 
@@ -77,8 +76,8 @@ module Neography
77
76
  { "id" => 2, "method" => "DELETE", "to" => "/index/node/index3/key3/value3/id3" }
78
77
  ]
79
78
 
80
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
81
- subject.execute [:remove_node_from_index, "index1", "id1", ],
79
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
80
+ subject.batch [:remove_node_from_index, "index1", "id1", ],
82
81
  [:remove_node_from_index, "index2", "key2", "id2" ],
83
82
  [:remove_node_from_index, "index3", "key3", "value3", "id3" ]
84
83
  end
@@ -89,8 +88,8 @@ module Neography
89
88
  { "id" => 1, "method" => "PUT", "to" => "/node/index2/properties/key2", "body" => "value2" }
90
89
  ]
91
90
 
92
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
93
- subject.execute [:set_node_property, "index1", { "key1" => "value1" } ],
91
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
92
+ subject.batch [:set_node_property, "index1", { "key1" => "value1" } ],
94
93
  [:set_node_property, "index2", { "key2" => "value2" } ]
95
94
  end
96
95
 
@@ -100,8 +99,8 @@ module Neography
100
99
  { "id" => 1, "method" => "PUT", "to" => "/node/index2/properties", "body" => { "key2" => "value2" } }
101
100
  ]
102
101
 
103
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
104
- subject.execute [:reset_node_properties, "index1", { "key1" => "value1" } ],
102
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
103
+ subject.batch [:reset_node_properties, "index1", { "key1" => "value1" } ],
105
104
  [:reset_node_properties, "index2", { "key2" => "value2" } ]
106
105
  end
107
106
 
@@ -110,8 +109,8 @@ module Neography
110
109
  { "id" => 0, "method" => "POST", "to" => "{0}/labels", "body" => "foo" },
111
110
  { "id" => 1, "method" => "POST", "to" => "{0}/labels", "body" => "bar" },
112
111
  ]
113
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
114
- subject.execute [:add_label, "{0}", "foo"],
112
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
113
+ subject.batch [:add_label, "{0}", "foo"],
115
114
  [:add_label, "{0}", "bar"]
116
115
  end
117
116
 
@@ -121,8 +120,8 @@ module Neography
121
120
  { "id" => 1, "method" => "GET", "to" => "/node/id2/relationships/all" }
122
121
  ]
123
122
 
124
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
125
- subject.execute [:get_node_relationships, "id1", "direction1" ],
123
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
124
+ subject.batch [:get_node_relationships, "id1", "direction1" ],
126
125
  [:get_node_relationships, "id2" ]
127
126
  end
128
127
 
@@ -132,8 +131,8 @@ module Neography
132
131
  { "id" => 1, "method" => "GET", "to" => "/relationship/bar" }
133
132
  ]
134
133
 
135
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
136
- subject.execute [:get_relationship, "foo"], [:get_relationship, "bar"]
134
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
135
+ subject.batch [:get_relationship, "foo"], [:get_relationship, "bar"]
137
136
  end
138
137
 
139
138
  it "creates relationships" do
@@ -142,8 +141,8 @@ module Neography
142
141
  { "id" => 1, "method" => "POST", "to" => "{0}/relationships", "body" => { "to" => "{1}", "type" => "type2", "data" => "data2" } }
143
142
  ]
144
143
 
145
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
146
- subject.execute [:create_relationship, "type1", "from1", "to1", "data1" ],
144
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
145
+ subject.batch [:create_relationship, "type1", "from1", "to1", "data1" ],
147
146
  [:create_relationship, "type2", "{0}", "{1}", "data2" ]
148
147
  end
149
148
 
@@ -153,8 +152,8 @@ module Neography
153
152
  { "id" => 1, "method" => "DELETE", "to" => "/relationship/bar" }
154
153
  ]
155
154
 
156
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
157
- subject.execute [:delete_relationship, "foo"], [:delete_relationship, "bar"]
155
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
156
+ subject.batch [:delete_relationship, "foo"], [:delete_relationship, "bar"]
158
157
  end
159
158
 
160
159
  it "creates unique nodes" do
@@ -163,8 +162,8 @@ module Neography
163
162
  { "id" => 1, "method" => "POST", "to" => "/index/relationship/index2?unique", "body" => { "key" => "key2", "value" => "value2", "type" => "type2", "start" => "{0}", "end" => "{1}", "properties" => "properties" } }
164
163
  ]
165
164
 
166
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
167
- subject.execute [:create_unique_relationship, "index1", "key1", "value1", "type1", "node1", "node2","properties" ],
165
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
166
+ subject.batch [:create_unique_relationship, "index1", "key1", "value1", "type1", "node1", "node2","properties" ],
168
167
  [:create_unique_relationship, "index2", "key2", "value2", "type2", "{0}", "{1}", "properties" ]
169
168
  end
170
169
 
@@ -174,8 +173,8 @@ module Neography
174
173
  { "id" => 1, "method" => "POST", "to" => "/index/relationship/index2", "body" => { "uri" => "{0}", "key" => "key2", "value" => "value2" } }
175
174
  ]
176
175
 
177
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
178
- subject.execute [:add_relationship_to_index, "index1", "key1", "value1", "rel1" ],
176
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
177
+ subject.batch [:add_relationship_to_index, "index1", "key1", "value1", "rel1" ],
179
178
  [:add_relationship_to_index, "index2", "key2", "value2", "{0}"]
180
179
  end
181
180
 
@@ -185,8 +184,8 @@ module Neography
185
184
  { "id" => 1, "method" => "GET", "to" => "/index/relationship/qux/quux/corge" }
186
185
  ]
187
186
 
188
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
189
- subject.execute [:get_relationship_index, "foo", "bar", "baz" ],
187
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
188
+ subject.batch [:get_relationship_index, "foo", "bar", "baz" ],
190
189
  [:get_relationship_index, "qux", "quux", "corge" ]
191
190
  end
192
191
 
@@ -197,8 +196,8 @@ module Neography
197
196
  { "id" => 2, "method" => "DELETE", "to" => "/index/relationship/index3/key3/value3/id3" }
198
197
  ]
199
198
 
200
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
201
- subject.execute [:remove_relationship_from_index, "index1", "id1", ],
199
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
200
+ subject.batch [:remove_relationship_from_index, "index1", "id1", ],
202
201
  [:remove_relationship_from_index, "index2", "key2", "id2" ],
203
202
  [:remove_relationship_from_index, "index3", "key3", "value3", "id3" ]
204
203
  end
@@ -209,8 +208,8 @@ module Neography
209
208
  { "id" => 1, "method" => "PUT", "to" => "/relationship/index2/properties/key2", "body" => "value2" }
210
209
  ]
211
210
 
212
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
213
- subject.execute [:set_relationship_property, "index1", { "key1" => "value1" } ],
211
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
212
+ subject.batch [:set_relationship_property, "index1", { "key1" => "value1" } ],
214
213
  [:set_relationship_property, "index2", { "key2" => "value2" } ]
215
214
  end
216
215
 
@@ -220,30 +219,30 @@ module Neography
220
219
  { "id" => 1, "method" => "PUT", "to" => "{0}/properties", "body" => { "key2" => "value2" } }
221
220
  ]
222
221
 
223
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
224
- subject.execute [:reset_relationship_properties, "index1", { "key1" => "value1" } ],
222
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
223
+ subject.batch [:reset_relationship_properties, "index1", { "key1" => "value1" } ],
225
224
  [:reset_relationship_properties, "{0}", { "key2" => "value2" } ]
226
225
  end
227
226
 
228
- it "executes scripts" do
227
+ it "batchs scripts" do
229
228
  expected_body = [
230
- { "id" => 0, "method" => "POST", "to" => "/gremlin", "body" => { "script" => "script1", "params" => "params1" } },
231
- { "id" => 1, "method" => "POST", "to" => "/gremlin", "body" => { "script" => "script2", "params" => "params2" } }
229
+ { "id" => 0, "method" => "POST", "to" => "/ext/GremlinPlugin/graphdb/execute_script", "body" => { "script" => "script1", "params" => "params1" } },
230
+ { "id" => 1, "method" => "POST", "to" => "/ext/GremlinPlugin/graphdb/execute_script", "body" => { "script" => "script2", "params" => "params2" } }
232
231
  ]
233
232
 
234
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
235
- subject.execute [:execute_script, "script1", "params1"],
233
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
234
+ subject.batch [:execute_script, "script1", "params1"],
236
235
  [:execute_script, "script2", "params2"]
237
236
  end
238
237
 
239
- it "executes queries" do
238
+ it "batchs queries" do
240
239
  expected_body = [
241
240
  { "id" => 0, "method" => "POST", "to" => "/cypher", "body" => { "query" => "query1", "params" => "params1" } },
242
241
  { "id" => 1, "method" => "POST", "to" => "/cypher", "body" => { "query" => "query2" } }
243
242
  ]
244
243
 
245
- connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
246
- subject.execute [:execute_query, "query1", "params1"],
244
+ subject.connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
245
+ subject.batch [:execute_query, "query1", "params1"],
247
246
  [:execute_query, "query2" ]
248
247
  end
249
248