neography-down 1.6.4
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.project +12 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +939 -0
- data/CONTRIBUTORS +18 -0
- data/Gemfile +4 -0
- data/Guardfile +14 -0
- data/LICENSE +19 -0
- data/README.md +281 -0
- data/Rakefile +14 -0
- data/examples/facebook.rb +40 -0
- data/examples/facebook_v2.rb +25 -0
- data/examples/greatest.rb +43 -0
- data/examples/linkedin.rb +39 -0
- data/examples/linkedin_v2.rb +22 -0
- data/examples/traversal_example1.rb +65 -0
- data/examples/traversal_example2.rb +54 -0
- data/lib/neography.rb +45 -0
- data/lib/neography/config.rb +64 -0
- data/lib/neography/connection.rb +263 -0
- data/lib/neography/equal.rb +21 -0
- data/lib/neography/errors.rb +60 -0
- data/lib/neography/index.rb +52 -0
- data/lib/neography/multi_json_parser.rb +28 -0
- data/lib/neography/neography.rb +10 -0
- data/lib/neography/node.rb +63 -0
- data/lib/neography/node_path.rb +29 -0
- data/lib/neography/node_relationship.rb +37 -0
- data/lib/neography/node_traverser.rb +146 -0
- data/lib/neography/path_traverser.rb +100 -0
- data/lib/neography/property.rb +110 -0
- data/lib/neography/property_container.rb +28 -0
- data/lib/neography/railtie.rb +19 -0
- data/lib/neography/relationship.rb +78 -0
- data/lib/neography/relationship_traverser.rb +80 -0
- data/lib/neography/rest.rb +99 -0
- data/lib/neography/rest/batch.rb +414 -0
- data/lib/neography/rest/clean.rb +17 -0
- data/lib/neography/rest/constraints.rb +38 -0
- data/lib/neography/rest/cypher.rb +29 -0
- data/lib/neography/rest/extensions.rb +21 -0
- data/lib/neography/rest/gremlin.rb +20 -0
- data/lib/neography/rest/helpers.rb +96 -0
- data/lib/neography/rest/node_auto_indexes.rb +60 -0
- data/lib/neography/rest/node_indexes.rb +139 -0
- data/lib/neography/rest/node_labels.rb +49 -0
- data/lib/neography/rest/node_paths.rb +49 -0
- data/lib/neography/rest/node_properties.rb +52 -0
- data/lib/neography/rest/node_relationships.rb +33 -0
- data/lib/neography/rest/node_traversal.rb +25 -0
- data/lib/neography/rest/nodes.rb +94 -0
- data/lib/neography/rest/other_node_relationships.rb +38 -0
- data/lib/neography/rest/relationship_auto_indexes.rb +60 -0
- data/lib/neography/rest/relationship_indexes.rb +142 -0
- data/lib/neography/rest/relationship_properties.rb +52 -0
- data/lib/neography/rest/relationship_types.rb +11 -0
- data/lib/neography/rest/relationships.rb +16 -0
- data/lib/neography/rest/schema_indexes.rb +26 -0
- data/lib/neography/rest/spatial.rb +137 -0
- data/lib/neography/rest/transactions.rb +101 -0
- data/lib/neography/tasks.rb +207 -0
- data/lib/neography/version.rb +3 -0
- data/neography.gemspec +39 -0
- data/spec/integration/authorization_spec.rb +40 -0
- data/spec/integration/broken_spatial_spec.rb +28 -0
- data/spec/integration/index_spec.rb +71 -0
- data/spec/integration/neography_spec.rb +10 -0
- data/spec/integration/node_encoding_spec.rb +71 -0
- data/spec/integration/node_path_spec.rb +222 -0
- data/spec/integration/node_relationship_spec.rb +381 -0
- data/spec/integration/node_spec.rb +260 -0
- data/spec/integration/parsing_spec.rb +13 -0
- data/spec/integration/performance_spec.rb +17 -0
- data/spec/integration/relationship_spec.rb +37 -0
- data/spec/integration/rest_batch_no_streaming_spec.rb +41 -0
- data/spec/integration/rest_batch_spec.rb +604 -0
- data/spec/integration/rest_batch_streaming_spec.rb +51 -0
- data/spec/integration/rest_bulk_spec.rb +106 -0
- data/spec/integration/rest_constraints_spec.rb +72 -0
- data/spec/integration/rest_experimental_spec.rb +22 -0
- data/spec/integration/rest_gremlin_fail_spec.rb +46 -0
- data/spec/integration/rest_header_spec.rb +15 -0
- data/spec/integration/rest_index_spec.rb +481 -0
- data/spec/integration/rest_labels_spec.rb +128 -0
- data/spec/integration/rest_node_spec.rb +274 -0
- data/spec/integration/rest_other_node_relationship_spec.rb +137 -0
- data/spec/integration/rest_path_spec.rb +231 -0
- data/spec/integration/rest_plugin_spec.rb +177 -0
- data/spec/integration/rest_relationship_spec.rb +354 -0
- data/spec/integration/rest_relationship_types_spec.rb +18 -0
- data/spec/integration/rest_schema_index_spec.rb +32 -0
- data/spec/integration/rest_spatial_spec.rb +166 -0
- data/spec/integration/rest_transaction_spec.rb +166 -0
- data/spec/integration/rest_traverse_spec.rb +149 -0
- data/spec/integration/unmanaged_spec.rb +27 -0
- data/spec/matchers.rb +33 -0
- data/spec/neography_spec.rb +23 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/unit/config_spec.rb +135 -0
- data/spec/unit/connection_spec.rb +284 -0
- data/spec/unit/node_spec.rb +100 -0
- data/spec/unit/properties_spec.rb +285 -0
- data/spec/unit/relationship_spec.rb +118 -0
- data/spec/unit/rest/batch_spec.rb +262 -0
- data/spec/unit/rest/clean_spec.rb +16 -0
- data/spec/unit/rest/constraints_spec.rb +45 -0
- data/spec/unit/rest/cypher_spec.rb +20 -0
- data/spec/unit/rest/extensions_spec.rb +28 -0
- data/spec/unit/rest/gremlin_spec.rb +25 -0
- data/spec/unit/rest/helpers_spec.rb +124 -0
- data/spec/unit/rest/labels_spec.rb +77 -0
- data/spec/unit/rest/node_auto_indexes_spec.rb +70 -0
- data/spec/unit/rest/node_indexes_spec.rb +140 -0
- data/spec/unit/rest/node_paths_spec.rb +77 -0
- data/spec/unit/rest/node_properties_spec.rb +79 -0
- data/spec/unit/rest/node_relationships_spec.rb +57 -0
- data/spec/unit/rest/node_traversal_spec.rb +35 -0
- data/spec/unit/rest/nodes_spec.rb +187 -0
- data/spec/unit/rest/relationship_auto_indexes_spec.rb +66 -0
- data/spec/unit/rest/relationship_indexes_spec.rb +132 -0
- data/spec/unit/rest/relationship_properties_spec.rb +79 -0
- data/spec/unit/rest/relationship_types_spec.rb +15 -0
- data/spec/unit/rest/relationships_spec.rb +21 -0
- data/spec/unit/rest/schema_index_spec.rb +30 -0
- data/spec/unit/rest/transactions_spec.rb +43 -0
- metadata +372 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
class Rest
|
|
5
|
+
describe NodeRelationships do
|
|
6
|
+
|
|
7
|
+
subject { Neography::Rest.new }
|
|
8
|
+
|
|
9
|
+
it "creates a relationship" do
|
|
10
|
+
body_hash = { "type" => "some_type",
|
|
11
|
+
"to" => "http://localhost:7474/node/43",
|
|
12
|
+
"data" => {"foo"=>"bar","baz"=>"qux"}
|
|
13
|
+
}
|
|
14
|
+
expect(subject.connection).to receive(:post).with("/node/42/relationships", json_match(:body, body_hash))
|
|
15
|
+
|
|
16
|
+
subject.create_relationship("some_type", "42", "43", {:foo => "bar", :baz => "qux"})
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "returns the post results" do
|
|
20
|
+
allow(subject.connection).to receive(:post).and_return("foo")
|
|
21
|
+
|
|
22
|
+
expect(subject.create_relationship("some_type", "42", "43", {})).to eq("foo")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "gets relationships" do
|
|
26
|
+
expect(subject.connection).to receive(:get).with("/node/42/relationships/all")
|
|
27
|
+
subject.get_node_relationships("42")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "gets relationships with direction" do
|
|
31
|
+
expect(subject.connection).to receive(:get).with("/node/42/relationships/in")
|
|
32
|
+
subject.get_node_relationships("42", :in)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "gets relationships with direction and type" do
|
|
36
|
+
expect(subject.connection).to receive(:get).with("/node/42/relationships/in/foo")
|
|
37
|
+
subject.get_node_relationships("42", :in, "foo")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "gets relationships with direction and types" do
|
|
41
|
+
expect(subject.connection).to receive(:get).with("/node/42/relationships/in/foo%26bar")
|
|
42
|
+
subject.get_node_relationships("42", :in, ["foo", "bar"])
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "returns empty array if no relationships were found" do
|
|
46
|
+
allow(subject.connection).to receive(:get).and_return([])
|
|
47
|
+
expect(subject.get_node_relationships("42", :in)).to be_empty
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "returns empty array if no relationships were found by type" do
|
|
51
|
+
allow(subject.connection).to receive(:get).and_return([])
|
|
52
|
+
subject.get_node_relationships("42", :in, "foo")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
class Rest
|
|
5
|
+
describe NodeTraversal do
|
|
6
|
+
|
|
7
|
+
subject { Neography::Rest.new }
|
|
8
|
+
|
|
9
|
+
it "traverses" do
|
|
10
|
+
description = {
|
|
11
|
+
"order" => :breadth,
|
|
12
|
+
"uniqueness" => :nodeglobal,
|
|
13
|
+
"relationships" => "relationships",
|
|
14
|
+
"prune evaluator" => "prune_evaluator",
|
|
15
|
+
"return filter" => "return_filter",
|
|
16
|
+
"depth" => 4
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
expected_body = {
|
|
20
|
+
"order" => "breadth first",
|
|
21
|
+
"uniqueness" => "node global",
|
|
22
|
+
"relationships" => "relationships",
|
|
23
|
+
"prune_evaluator" => "prune_evaluator",
|
|
24
|
+
"return_filter" => "return_filter",
|
|
25
|
+
"max_depth" => 4
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
expect(subject.connection).to receive(:post).with("/node/42/traverse/relationship", json_match(:body, expected_body))
|
|
29
|
+
|
|
30
|
+
subject.traverse("42", :relationship, description)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
class Rest
|
|
5
|
+
describe Nodes do
|
|
6
|
+
|
|
7
|
+
subject { Neography::Rest.new }
|
|
8
|
+
|
|
9
|
+
context "get nodes" do
|
|
10
|
+
it "gets single nodes" do
|
|
11
|
+
expect(subject.connection).to receive(:get).with("/node/42")
|
|
12
|
+
subject.get_node("42")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "gets multiple nodes" do
|
|
16
|
+
expect(subject.connection).to receive(:get).with("/node/42")
|
|
17
|
+
expect(subject.connection).to receive(:get).with("/node/43")
|
|
18
|
+
subject.get_nodes("42", "43")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "returns multiple nodes in an array" do
|
|
22
|
+
allow(subject.connection).to receive(:get).and_return("foo", "bar")
|
|
23
|
+
expect(subject.get_nodes("42", "43")).to eq([ "foo", "bar" ])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "gets the root node" do
|
|
27
|
+
allow(subject.connection).to receive(:get).with("/").and_return({ "reference_node" => "42" })
|
|
28
|
+
expect(subject.connection).to receive(:get).with("/node/42")
|
|
29
|
+
subject.get_root
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "returns the root node" do
|
|
33
|
+
allow(subject.connection).to receive(:get).and_return({ "reference_node" => "42" }, "foo")
|
|
34
|
+
expect(subject.get_root).to eq("foo")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "create nodes" do
|
|
39
|
+
|
|
40
|
+
it "creates with attributes" do
|
|
41
|
+
options = {
|
|
42
|
+
:body => '{"foo":"bar","baz":"qux"}',
|
|
43
|
+
:headers => json_content_type
|
|
44
|
+
}
|
|
45
|
+
expect(subject.connection).to receive(:post).with("/node", options)
|
|
46
|
+
subject.create_node_with_attributes({:foo => "bar", :baz => "qux"})
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "returns the created node" do
|
|
50
|
+
allow(subject.connection).to receive(:post).and_return("foo")
|
|
51
|
+
expect(subject.create_node_with_attributes({})).to eq("foo")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "creates with attributes using #create method" do
|
|
55
|
+
options = {
|
|
56
|
+
:body => '{"foo":"bar","baz":"qux"}',
|
|
57
|
+
:headers => json_content_type
|
|
58
|
+
}
|
|
59
|
+
expect(subject.connection).to receive(:post).with("/node", options)
|
|
60
|
+
subject.create_node({:foo => "bar", :baz => "qux"})
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "creates empty nodes" do
|
|
64
|
+
expect(subject.connection).to receive(:post).with("/node")
|
|
65
|
+
subject.create_empty_node
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "returns an empty node" do
|
|
69
|
+
allow(subject.connection).to receive(:post).and_return("foo")
|
|
70
|
+
expect(subject.create_empty_node).to eq("foo")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "creates empty nodes using #create method" do
|
|
74
|
+
expect(subject.connection).to receive(:post).with("/node")
|
|
75
|
+
subject.create_node
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
context "delete nodes" do
|
|
81
|
+
|
|
82
|
+
it "deletes a node" do
|
|
83
|
+
expect(subject.connection).to receive(:delete).with("/node/42")
|
|
84
|
+
subject.delete_node("42")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
context "#create_multiple" do
|
|
90
|
+
|
|
91
|
+
it "creates multiple with attributes" do
|
|
92
|
+
options1 = {
|
|
93
|
+
:body => '{"foo1":"bar1","baz1":"qux1"}',
|
|
94
|
+
:headers => json_content_type
|
|
95
|
+
}
|
|
96
|
+
options2 = {
|
|
97
|
+
:body => '{"foo2":"bar2","baz2":"qux2"}',
|
|
98
|
+
:headers => json_content_type
|
|
99
|
+
}
|
|
100
|
+
expect(subject.connection).to receive(:post).with("/node", options1)
|
|
101
|
+
expect(subject.connection).to receive(:post).with("/node", options2)
|
|
102
|
+
|
|
103
|
+
subject.create_nodes([
|
|
104
|
+
{:foo1 => "bar1", :baz1 => "qux1"},
|
|
105
|
+
{:foo2 => "bar2", :baz2 => "qux2"}
|
|
106
|
+
])
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "returns multiple nodes with attributes in an array" do
|
|
110
|
+
allow(subject.connection).to receive(:post).and_return("foo", "bar")
|
|
111
|
+
expect(subject.create_nodes([{},{}])).to eq(["foo", "bar"])
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# exotic?
|
|
115
|
+
it "creates multiple with and without attributes" do
|
|
116
|
+
options1 = {
|
|
117
|
+
:body => '{"foo1":"bar1","baz1":"qux1"}',
|
|
118
|
+
:headers => json_content_type
|
|
119
|
+
}
|
|
120
|
+
expect(subject.connection).to receive(:post).with("/node", options1)
|
|
121
|
+
expect(subject.connection).to receive(:post).with("/node")
|
|
122
|
+
|
|
123
|
+
subject.create_nodes([
|
|
124
|
+
{:foo1 => "bar1", :baz1 => "qux1"},
|
|
125
|
+
"not a hash" # ?
|
|
126
|
+
])
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "creates multiple empty nodes" do
|
|
130
|
+
expect(subject.connection).to receive(:post).with("/node").twice
|
|
131
|
+
subject.create_nodes(2)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "returns multiple empty nodes in an array" do
|
|
135
|
+
allow(subject.connection).to receive(:post).and_return("foo", "bar")
|
|
136
|
+
expect(subject.create_nodes(2)).to eq(["foo", "bar"])
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
context "#create_multiple_threaded" do
|
|
142
|
+
|
|
143
|
+
let(:connection) { double(:max_threads => 2) }
|
|
144
|
+
|
|
145
|
+
it "creates multiple with attributes" do
|
|
146
|
+
options1 = {
|
|
147
|
+
:body => '{"foo1":"bar1","baz1":"qux1"}',
|
|
148
|
+
:headers => json_content_type
|
|
149
|
+
}
|
|
150
|
+
options2 = {
|
|
151
|
+
:body => '{"foo2":"bar2","baz2":"qux2"}',
|
|
152
|
+
:headers => json_content_type
|
|
153
|
+
}
|
|
154
|
+
expect(subject.connection).to receive(:post).with("/node", options1)
|
|
155
|
+
expect(subject.connection).to receive(:post).with("/node", options2)
|
|
156
|
+
|
|
157
|
+
subject.create_nodes_threaded([
|
|
158
|
+
{:foo1 => "bar1", :baz1 => "qux1"},
|
|
159
|
+
{:foo2 => "bar2", :baz2 => "qux2"}
|
|
160
|
+
])
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# exotic?
|
|
164
|
+
it "creates multiple with and without attributes" do
|
|
165
|
+
options1 = {
|
|
166
|
+
:body => '{"foo1":"bar1","baz1":"qux1"}',
|
|
167
|
+
:headers => json_content_type
|
|
168
|
+
}
|
|
169
|
+
expect(subject.connection).to receive(:post).with("/node", options1)
|
|
170
|
+
expect(subject.connection).to receive(:post).with("/node")
|
|
171
|
+
|
|
172
|
+
subject.create_nodes_threaded([
|
|
173
|
+
{:foo1 => "bar1", :baz1 => "qux1"},
|
|
174
|
+
"not a hash" # ?
|
|
175
|
+
])
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it "creates multiple empty nodes" do
|
|
179
|
+
expect(subject.connection).to receive(:post).with("/node").twice
|
|
180
|
+
subject.create_nodes_threaded(2)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
class Rest
|
|
5
|
+
describe RelationshipAutoIndexes do
|
|
6
|
+
|
|
7
|
+
subject { Neography::Rest.new }
|
|
8
|
+
|
|
9
|
+
it "gets a relationship from an auto index" do
|
|
10
|
+
expect(subject.connection).to receive(:get).with("/index/auto/relationship/some_key/some_value")
|
|
11
|
+
subject.get_relationship_auto_index("some_key", "some_value")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "returns nil if nothing was found in the auto index" do
|
|
15
|
+
allow(subject.connection).to receive(:get).and_return(nil)
|
|
16
|
+
expect(subject.get_relationship_auto_index("some_key", "some_value")).to be_nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "finds by key and value if value passed to #find_or_query" do
|
|
20
|
+
expect(subject.connection).to receive(:get).with("/index/auto/relationship/some_key/some_value")
|
|
21
|
+
subject.find_relationship_auto_index("some_key", "some_value")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "finds by query if no value passed to #find_or_query" do
|
|
25
|
+
expect(subject.connection).to receive(:get).with("/index/auto/relationship/?query=some_query")
|
|
26
|
+
subject.find_relationship_auto_index("some_query")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "finds by key and value" do
|
|
30
|
+
expect(subject.connection).to receive(:get).with("/index/auto/relationship/some_key/some_value")
|
|
31
|
+
subject.find_relationship_auto_index("some_key", "some_value")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "finds by query" do
|
|
35
|
+
expect(subject.connection).to receive(:get).with("/index/auto/relationship/?query=some_query")
|
|
36
|
+
subject.find_relationship_auto_index("some_query")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "gets the status" do
|
|
40
|
+
expect(subject.connection).to receive(:get).with("/index/auto/relationship/status")
|
|
41
|
+
subject.get_relationship_auto_index_status
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "sets the status" do
|
|
45
|
+
expect(subject.connection).to receive(:put).with("/index/auto/relationship/status", hash_match(:body, '"foo"'))
|
|
46
|
+
subject.set_relationship_auto_index_status("foo")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "gets auto index properties" do
|
|
50
|
+
expect(subject.connection).to receive(:get).with("/index/auto/relationship/properties")
|
|
51
|
+
subject.get_relationship_auto_index_properties
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "adds a property to an auto index" do
|
|
55
|
+
expect(subject.connection).to receive(:post).with("/index/auto/relationship/properties", hash_match(:body, "foo"))
|
|
56
|
+
subject.add_relationship_auto_index_property("foo")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "removes a property from an auto index" do
|
|
60
|
+
expect(subject.connection).to receive(:delete).with("/index/auto/relationship/properties/foo")
|
|
61
|
+
subject.remove_relationship_auto_index_property("foo")
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
class Rest
|
|
5
|
+
describe RelationshipIndexes do
|
|
6
|
+
|
|
7
|
+
subject { Neography::Rest.new }
|
|
8
|
+
|
|
9
|
+
it "lists all indexes" do
|
|
10
|
+
expect(subject.connection).to receive(:get).with("/index/relationship")
|
|
11
|
+
subject.list_relationship_indexes
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "creates a relationship index" do
|
|
15
|
+
expected_body = {
|
|
16
|
+
"config" => {
|
|
17
|
+
"type" => "some_type",
|
|
18
|
+
"provider" => "some_provider"
|
|
19
|
+
},
|
|
20
|
+
"name" => "some_index"
|
|
21
|
+
}
|
|
22
|
+
expect(subject.connection).to receive(:post).with("/index/relationship", json_match(:body, expected_body))
|
|
23
|
+
subject.create_relationship_index("some_index", "some_type", "some_provider")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "returns the post result after creation" do
|
|
27
|
+
allow(subject.connection).to receive(:post).and_return("foo")
|
|
28
|
+
expect(subject.create_relationship_index("some_index", "some_type", "some_provider")).to eq("foo")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "creates an auto-index" do
|
|
32
|
+
expected_body = {
|
|
33
|
+
"config" => {
|
|
34
|
+
"type" => "some_type",
|
|
35
|
+
"provider" => "some_provider"
|
|
36
|
+
},
|
|
37
|
+
"name" => "relationship_auto_index"
|
|
38
|
+
}
|
|
39
|
+
expect(subject.connection).to receive(:post).with("/index/relationship", json_match(:body, expected_body))
|
|
40
|
+
subject.create_relationship_auto_index("some_type", "some_provider")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "creates a unique relationship in an index" do
|
|
44
|
+
expected_body = {
|
|
45
|
+
"key" => "key",
|
|
46
|
+
"value" => "value",
|
|
47
|
+
"type" => "type",
|
|
48
|
+
"start" => "http://localhost:7474/node/42",
|
|
49
|
+
"end" => "http://localhost:7474/node/43",
|
|
50
|
+
"properties" => "properties"
|
|
51
|
+
}
|
|
52
|
+
expect(subject.connection).to receive(:post).with("/index/relationship/some_index?unique", json_match(:body, expected_body))
|
|
53
|
+
subject.create_unique_relationship("some_index", "key", "value", "type", "42", "43", "properties")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "adds a relationship to an index" do
|
|
57
|
+
expected_body = {
|
|
58
|
+
"uri" => "http://localhost:7474/relationship/42",
|
|
59
|
+
"key" => "key",
|
|
60
|
+
"value" => "value"
|
|
61
|
+
}
|
|
62
|
+
expect(subject.connection).to receive(:post).with("/index/relationship/some_index", json_match(:body, expected_body))
|
|
63
|
+
subject.add_relationship_to_index("some_index", "key", "value", "42")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "gets a relationship from an index" do
|
|
67
|
+
expect(subject.connection).to receive(:get).with("/index/relationship/some_index/some_key/some_value")
|
|
68
|
+
subject.get_relationship_index("some_index", "some_key", "some_value")
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "returns nil if nothing was found in the index" do
|
|
72
|
+
allow(subject.connection).to receive(:get).and_return(nil)
|
|
73
|
+
expect(subject.get_relationship_index("some_index", "some_key", "some_value")).to be_nil
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "finds by key and value if both passed to #find" do
|
|
77
|
+
expect(subject.connection).to receive(:get).with("/index/relationship/some_index/some_key/some_value")
|
|
78
|
+
subject.find_relationship_index("some_index", "some_key", "some_value")
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "finds by query if no value passed to #find" do
|
|
82
|
+
expect(subject.connection).to receive(:get).with("/index/relationship/some_index?query=some_query")
|
|
83
|
+
subject.find_relationship_index("some_index", "some_query")
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "finds by key query" do
|
|
87
|
+
expect(subject.connection).to receive(:get).with("/index/relationship/some_index/some_key/some_value")
|
|
88
|
+
subject.find_relationship_index_by_key_value("some_index", "some_key", "some_value")
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "finds by query" do
|
|
92
|
+
expect(subject.connection).to receive(:get).with("/index/relationship/some_index?query=some_query")
|
|
93
|
+
subject.find_relationship_index_by_query("some_index", "some_query")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "removes a relationship from an index for #remove with two arguments" do
|
|
97
|
+
expect(subject.connection).to receive(:delete).with("/index/relationship/some_index/42")
|
|
98
|
+
subject.remove_relationship_from_index("some_index", "42")
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "removes a relationship from an index by key for #remove with three arguments" do
|
|
102
|
+
expect(subject.connection).to receive(:delete).with("/index/relationship/some_index/some_key/42")
|
|
103
|
+
subject.remove_relationship_from_index("some_index", "some_key", "42")
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "removes a relationship from an index by key and value for #remove with four arguments" do
|
|
107
|
+
expect(subject.connection).to receive(:delete).with("/index/relationship/some_index/some_key/some_value/42")
|
|
108
|
+
subject.remove_relationship_from_index("some_index", "some_key", "some_value", "42")
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it "removes a relationship from an index" do
|
|
112
|
+
expect(subject.connection).to receive(:delete).with("/index/relationship/some_index/42")
|
|
113
|
+
subject.remove_relationship_index_by_id("some_index", "42")
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it "removes a relationship from an index by key" do
|
|
117
|
+
expect(subject.connection).to receive(:delete).with("/index/relationship/some_index/some_key/42")
|
|
118
|
+
subject.remove_relationship_index_by_key("some_index", "42", "some_key")
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it "removes a relationship from an index by key and value" do
|
|
122
|
+
expect(subject.connection).to receive(:delete).with("/index/relationship/some_index/some_key/some_value/42")
|
|
123
|
+
subject.remove_relationship_index_by_value("some_index", "42", "some_key", "some_value")
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it "drops an index" do
|
|
127
|
+
expect(subject.connection).to receive(:delete).with("/index/relationship/some_index")
|
|
128
|
+
subject.drop_relationship_index("some_index")
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|