keymaker 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +36 -10
- data/keymaker.gemspec +37 -33
- data/lib/keymaker.rb +3 -2
- data/lib/keymaker/configuration.rb +14 -24
- data/lib/keymaker/node.rb +1 -1
- data/lib/keymaker/request.rb +0 -2
- data/lib/keymaker/requests/add_node_to_index_request.rb +10 -1
- data/lib/keymaker/requests/create_relationship_request.rb +8 -1
- data/lib/keymaker/requests/delete_relationship_request.rb +10 -1
- data/lib/keymaker/requests/execute_cypher_request.rb +8 -3
- data/lib/keymaker/requests/execute_gremlin_request.rb +8 -3
- data/lib/keymaker/requests/remove_node_from_index_request.rb +0 -2
- data/lib/keymaker/requests/service_root_request.rb +1 -1
- data/lib/keymaker/requests/{path_traverse_request.rb → traverse_path_request.rb} +16 -4
- data/lib/keymaker/requests/update_node_properties_request.rb +8 -1
- data/lib/keymaker/response.rb +1 -0
- data/lib/keymaker/service.rb +16 -4
- data/spec/cassettes/Keymaker_AddNodeToIndexRequest/{returns_a_201_status_code.yml → with_valid_options/returns_a_201_status_code.yml} +54 -55
- data/spec/cassettes/Keymaker_AddNodeToIndexRequest/{returns_application → with_valid_options/returns_application}/json.yml +54 -55
- data/spec/cassettes/Keymaker_AddNodeToIndexRequest/{returns_the_Neo4j_REST_API_starting_point_response_request.yml → with_valid_options/returns_the_Neo4j_REST_API_starting_point_response_request.yml} +54 -55
- data/spec/cassettes/Keymaker_CreateNodeRequest/returns_a_201_status_code.yml +112 -0
- data/spec/cassettes/Keymaker_CreateNodeRequest/returns_application/json.yml +112 -0
- data/spec/cassettes/Keymaker_CreateNodeRequest/with_properties/creates_a_node_with_the_given_properties.yml +112 -0
- data/spec/cassettes/Keymaker_CreateNodeRequest/without_properties/creates_an_empty_node.yml +112 -0
- data/spec/cassettes/Keymaker_CreateRelationshipRequest/with_invalid_options/raises_ClientError.yml +201 -0
- data/spec/cassettes/Keymaker_CreateRelationshipRequest/with_properties/creates_a_node_with_the_given_properties.yml +233 -0
- data/spec/cassettes/Keymaker_CreateRelationshipRequest/with_properties/returns_a_201_status_code.yml +196 -0
- data/spec/cassettes/Keymaker_CreateRelationshipRequest/with_properties/returns_application/json.yml +196 -0
- data/spec/cassettes/Keymaker_CreateRelationshipRequest/without_properties/creates_an_empty_relationship_of_type_birthed_.yml +195 -0
- data/spec/cassettes/Keymaker_DeleteRelationshipRequest/with_a_non-existent_relationship/raises_ResourceNotFound.yml +191 -0
- data/spec/cassettes/Keymaker_DeleteRelationshipRequest/with_an_existing_relationship/deletes_the_relationship.yml +219 -0
- data/spec/cassettes/Keymaker_ExecuteCypherRequest/with_a_valid_Cypher_Query/returns_a_200_status_code.yml +111 -0
- data/spec/cassettes/Keymaker_ExecuteCypherRequest/with_an_invalid_Cypher_Query/raises_ClientError.yml +108 -0
- data/spec/cassettes/Keymaker_ExecuteGremlinRequest/with_a_valid_Gremlin_Script/returns_a_200_status_code.yml +98 -0
- data/spec/cassettes/Keymaker_ExecuteGremlinRequest/with_an_invalid_Gremlin_Script/raises_ClientError.yml +107 -0
- data/spec/cassettes/Keymaker_TraversePathRequest/_traverse_path_properties/with_options/builds_the_query_properties_with_defaults.yml +157 -0
- data/spec/cassettes/Keymaker_TraversePathRequest/with_invalid_options/raise_a_ClientError.yml +193 -0
- data/spec/cassettes/Keymaker_TraversePathRequest/with_valid_options/returns_status_code_200.yml +269 -0
- data/spec/cassettes/Keymaker_UpdateNodePropertiesRequest/_node_properties/excludes_the_node_id.yml +157 -0
- data/spec/cassettes/Keymaker_UpdateNodePropertiesRequest/with_invalid_options/raises_a_ClientError.yml +193 -0
- data/spec/cassettes/Keymaker_UpdateNodePropertiesRequest/with_valid_options/returns_a_status_of_204.yml +182 -0
- data/spec/cassettes/Keymaker_UpdateNodePropertiesRequest/with_valid_options/updates_the_properties.yml +214 -0
- data/spec/keymaker/requests/add_node_to_index_request_spec.rb +30 -28
- data/spec/keymaker/requests/batch_get_nodes_request_spec.rb +4 -4
- data/spec/keymaker/requests/batch_request_spec.rb +33 -33
- data/spec/keymaker/requests/create_node_request_spec.rb +34 -0
- data/spec/keymaker/requests/create_relationship_request_spec.rb +58 -0
- data/spec/keymaker/requests/delete_relationship_request_spec.rb +28 -0
- data/spec/keymaker/requests/execute_cypher_request_spec.rb +23 -0
- data/spec/keymaker/requests/execute_gremlin_request_spec.rb +23 -0
- data/spec/keymaker/requests/service_root_request_spec.rb +9 -9
- data/spec/keymaker/requests/traverse_path_request_spec.rb +50 -0
- data/spec/keymaker/requests/update_node_properties_request_spec.rb +50 -0
- data/spec/keymaker/service_spec.rb +31 -0
- data/spec/keymaker_spec.rb +26 -2
- data/spec/support/keymaker.rb +10 -4
- metadata +86 -10
@@ -0,0 +1,214 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:7477/db/data/ext/GremlinPlugin/graphdb/execute_script
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '{"script":"g.clear();g.V()"}'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: !!null
|
16
|
+
headers:
|
17
|
+
content-length:
|
18
|
+
- '3'
|
19
|
+
content-encoding:
|
20
|
+
- UTF-8
|
21
|
+
content-type:
|
22
|
+
- application/json
|
23
|
+
access-control-allow-origin:
|
24
|
+
- ! '*'
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
server:
|
28
|
+
- Jetty(6.1.25)
|
29
|
+
body:
|
30
|
+
encoding: US-ASCII
|
31
|
+
string: ! '[ ]'
|
32
|
+
http_version: !!null
|
33
|
+
recorded_at: Fri, 27 Jul 2012 19:54:42 GMT
|
34
|
+
- request:
|
35
|
+
method: delete
|
36
|
+
uri: http://localhost:7477/db/data/index/node/users
|
37
|
+
body:
|
38
|
+
encoding: US-ASCII
|
39
|
+
string: ''
|
40
|
+
headers: {}
|
41
|
+
response:
|
42
|
+
status:
|
43
|
+
code: 404
|
44
|
+
message: !!null
|
45
|
+
headers:
|
46
|
+
content-length:
|
47
|
+
- '422'
|
48
|
+
content-encoding:
|
49
|
+
- UTF-8
|
50
|
+
content-type:
|
51
|
+
- application/json
|
52
|
+
access-control-allow-origin:
|
53
|
+
- ! '*'
|
54
|
+
connection:
|
55
|
+
- close
|
56
|
+
server:
|
57
|
+
- Jetty(6.1.25)
|
58
|
+
body:
|
59
|
+
encoding: US-ASCII
|
60
|
+
string: ! "{\n \"message\" : \"No node index named 'users'.\",\n \"exception\"
|
61
|
+
: \"NotFoundException\",\n \"stacktrace\" : [ \"org.neo4j.server.rest.web.DatabaseActions.removeNodeIndex(DatabaseActions.java:420)\",
|
62
|
+
\"org.neo4j.server.rest.web.RestfulGraphDatabase.deleteNodeIndex(RestfulGraphDatabase.java:729)\",
|
63
|
+
\"java.lang.reflect.Method.invoke(Method.java:597)\", \"org.neo4j.server.statistic.StatisticFilter.doFilter(StatisticFilter.java:62)\"
|
64
|
+
]\n}"
|
65
|
+
http_version: !!null
|
66
|
+
recorded_at: Fri, 27 Jul 2012 19:54:42 GMT
|
67
|
+
- request:
|
68
|
+
method: post
|
69
|
+
uri: http://localhost:7477/db/data/node
|
70
|
+
body:
|
71
|
+
encoding: UTF-8
|
72
|
+
string: ! '{"email":"john@resistance.net"}'
|
73
|
+
headers:
|
74
|
+
Content-Type:
|
75
|
+
- application/json
|
76
|
+
response:
|
77
|
+
status:
|
78
|
+
code: 201
|
79
|
+
message: !!null
|
80
|
+
headers:
|
81
|
+
content-length:
|
82
|
+
- '1138'
|
83
|
+
location:
|
84
|
+
- http://localhost:7477/db/data/node/829
|
85
|
+
content-encoding:
|
86
|
+
- UTF-8
|
87
|
+
content-type:
|
88
|
+
- application/json
|
89
|
+
access-control-allow-origin:
|
90
|
+
- ! '*'
|
91
|
+
connection:
|
92
|
+
- close
|
93
|
+
server:
|
94
|
+
- Jetty(6.1.25)
|
95
|
+
body:
|
96
|
+
encoding: US-ASCII
|
97
|
+
string: ! "{\n \"extensions\" : {\n },\n \"paged_traverse\" : \"http://localhost:7477/db/data/node/829/paged/traverse/{returnType}{?pageSize,leaseTime}\",\n
|
98
|
+
\ \"outgoing_relationships\" : \"http://localhost:7477/db/data/node/829/relationships/out\",\n
|
99
|
+
\ \"traverse\" : \"http://localhost:7477/db/data/node/829/traverse/{returnType}\",\n
|
100
|
+
\ \"all_typed_relationships\" : \"http://localhost:7477/db/data/node/829/relationships/all/{-list|&|types}\",\n
|
101
|
+
\ \"property\" : \"http://localhost:7477/db/data/node/829/properties/{key}\",\n
|
102
|
+
\ \"all_relationships\" : \"http://localhost:7477/db/data/node/829/relationships/all\",\n
|
103
|
+
\ \"self\" : \"http://localhost:7477/db/data/node/829\",\n \"properties\"
|
104
|
+
: \"http://localhost:7477/db/data/node/829/properties\",\n \"outgoing_typed_relationships\"
|
105
|
+
: \"http://localhost:7477/db/data/node/829/relationships/out/{-list|&|types}\",\n
|
106
|
+
\ \"incoming_relationships\" : \"http://localhost:7477/db/data/node/829/relationships/in\",\n
|
107
|
+
\ \"incoming_typed_relationships\" : \"http://localhost:7477/db/data/node/829/relationships/in/{-list|&|types}\",\n
|
108
|
+
\ \"create_relationship\" : \"http://localhost:7477/db/data/node/829/relationships\",\n
|
109
|
+
\ \"data\" : {\n \"email\" : \"john@resistance.net\"\n }\n}"
|
110
|
+
http_version: !!null
|
111
|
+
recorded_at: Fri, 27 Jul 2012 19:54:42 GMT
|
112
|
+
- request:
|
113
|
+
method: post
|
114
|
+
uri: http://localhost:7477/db/data/node
|
115
|
+
body:
|
116
|
+
encoding: UTF-8
|
117
|
+
string: ! '{"email":"sarah@resistance.net"}'
|
118
|
+
headers:
|
119
|
+
Content-Type:
|
120
|
+
- application/json
|
121
|
+
response:
|
122
|
+
status:
|
123
|
+
code: 201
|
124
|
+
message: !!null
|
125
|
+
headers:
|
126
|
+
content-length:
|
127
|
+
- '1139'
|
128
|
+
location:
|
129
|
+
- http://localhost:7477/db/data/node/830
|
130
|
+
content-encoding:
|
131
|
+
- UTF-8
|
132
|
+
content-type:
|
133
|
+
- application/json
|
134
|
+
access-control-allow-origin:
|
135
|
+
- ! '*'
|
136
|
+
connection:
|
137
|
+
- close
|
138
|
+
server:
|
139
|
+
- Jetty(6.1.25)
|
140
|
+
body:
|
141
|
+
encoding: US-ASCII
|
142
|
+
string: ! "{\n \"extensions\" : {\n },\n \"paged_traverse\" : \"http://localhost:7477/db/data/node/830/paged/traverse/{returnType}{?pageSize,leaseTime}\",\n
|
143
|
+
\ \"outgoing_relationships\" : \"http://localhost:7477/db/data/node/830/relationships/out\",\n
|
144
|
+
\ \"traverse\" : \"http://localhost:7477/db/data/node/830/traverse/{returnType}\",\n
|
145
|
+
\ \"all_typed_relationships\" : \"http://localhost:7477/db/data/node/830/relationships/all/{-list|&|types}\",\n
|
146
|
+
\ \"property\" : \"http://localhost:7477/db/data/node/830/properties/{key}\",\n
|
147
|
+
\ \"all_relationships\" : \"http://localhost:7477/db/data/node/830/relationships/all\",\n
|
148
|
+
\ \"self\" : \"http://localhost:7477/db/data/node/830\",\n \"properties\"
|
149
|
+
: \"http://localhost:7477/db/data/node/830/properties\",\n \"outgoing_typed_relationships\"
|
150
|
+
: \"http://localhost:7477/db/data/node/830/relationships/out/{-list|&|types}\",\n
|
151
|
+
\ \"incoming_relationships\" : \"http://localhost:7477/db/data/node/830/relationships/in\",\n
|
152
|
+
\ \"incoming_typed_relationships\" : \"http://localhost:7477/db/data/node/830/relationships/in/{-list|&|types}\",\n
|
153
|
+
\ \"create_relationship\" : \"http://localhost:7477/db/data/node/830/relationships\",\n
|
154
|
+
\ \"data\" : {\n \"email\" : \"sarah@resistance.net\"\n }\n}"
|
155
|
+
http_version: !!null
|
156
|
+
recorded_at: Fri, 27 Jul 2012 19:54:42 GMT
|
157
|
+
- request:
|
158
|
+
method: put
|
159
|
+
uri: http://localhost:7477/db/data/node/829/properties
|
160
|
+
body:
|
161
|
+
encoding: UTF-8
|
162
|
+
string: ! '{"email":"john.connor@resistance.net"}'
|
163
|
+
headers:
|
164
|
+
Content-Type:
|
165
|
+
- application/json
|
166
|
+
response:
|
167
|
+
status:
|
168
|
+
code: 204
|
169
|
+
message: !!null
|
170
|
+
headers:
|
171
|
+
access-control-allow-origin:
|
172
|
+
- ! '*'
|
173
|
+
connection:
|
174
|
+
- close
|
175
|
+
server:
|
176
|
+
- Jetty(6.1.25)
|
177
|
+
body:
|
178
|
+
encoding: US-ASCII
|
179
|
+
string: ''
|
180
|
+
http_version: !!null
|
181
|
+
recorded_at: Fri, 27 Jul 2012 19:54:42 GMT
|
182
|
+
- request:
|
183
|
+
method: post
|
184
|
+
uri: http://localhost:7477/db/data/cypher
|
185
|
+
body:
|
186
|
+
encoding: UTF-8
|
187
|
+
string: ! '{"query":"START n=node({node_id}) RETURN n.email;","params":{"node_id":829}}'
|
188
|
+
headers:
|
189
|
+
Content-Type:
|
190
|
+
- application/json
|
191
|
+
response:
|
192
|
+
status:
|
193
|
+
code: 200
|
194
|
+
message: !!null
|
195
|
+
headers:
|
196
|
+
content-length:
|
197
|
+
- '80'
|
198
|
+
content-encoding:
|
199
|
+
- UTF-8
|
200
|
+
content-type:
|
201
|
+
- application/json
|
202
|
+
access-control-allow-origin:
|
203
|
+
- ! '*'
|
204
|
+
connection:
|
205
|
+
- close
|
206
|
+
server:
|
207
|
+
- Jetty(6.1.25)
|
208
|
+
body:
|
209
|
+
encoding: US-ASCII
|
210
|
+
string: ! "{\n \"columns\" : [ \"n.email\" ],\n \"data\" : [ [ \"john.connor@resistance.net\"
|
211
|
+
] ]\n}"
|
212
|
+
http_version: !!null
|
213
|
+
recorded_at: Fri, 27 Jul 2012 19:54:42 GMT
|
214
|
+
recorded_with: VCR 2.2.2
|
@@ -5,37 +5,39 @@ describe Keymaker::AddNodeToIndexRequest, vcr: true do
|
|
5
5
|
|
6
6
|
include_context "John and Sarah nodes"
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
context "with valid options" do
|
9
|
+
let(:options) {{index_name: "users", key: "email", node_id: john_node_id, value: john_email}}
|
10
|
+
let(:add_node_to_index_request) { Keymaker::AddNodeToIndexRequest.new(Keymaker.service, options).submit }
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
12
|
+
it "returns the Neo4j REST API starting point response request" do
|
13
|
+
add_node_to_index_request.body.should include(
|
14
|
+
{
|
15
|
+
"indexed" => "#{neo4j_host}/db/data/index/node/users/email/john%40resistance.net/189",
|
16
|
+
"outgoing_relationships" => "#{neo4j_host}/db/data/node/189/relationships/out",
|
17
|
+
"data" => {"email" => "john@resistance.net"},
|
18
|
+
"traverse" => "#{neo4j_host}/db/data/node/189/traverse/{returnType}",
|
19
|
+
"all_typed_relationships" => "#{neo4j_host}/db/data/node/189/relationships/all/{-list|&|types}",
|
20
|
+
"property" => "#{neo4j_host}/db/data/node/189/properties/{key}",
|
21
|
+
"self" => "#{neo4j_host}/db/data/node/189",
|
22
|
+
"properties" => "#{neo4j_host}/db/data/node/189/properties",
|
23
|
+
"outgoing_typed_relationships" => "#{neo4j_host}/db/data/node/189/relationships/out/{-list|&|types}",
|
24
|
+
"incoming_relationships" => "#{neo4j_host}/db/data/node/189/relationships/in",
|
25
|
+
"extensions" => {},
|
26
|
+
"create_relationship" => "#{neo4j_host}/db/data/node/189/relationships",
|
27
|
+
"paged_traverse" => "#{neo4j_host}/db/data/node/189/paged/traverse/{returnType}{?pageSize,leaseTime}",
|
28
|
+
"all_relationships" => "#{neo4j_host}/db/data/node/189/relationships/all",
|
29
|
+
"incoming_typed_relationships" => "#{neo4j_host}/db/data/node/189/relationships/in/{-list|&|types}"
|
30
|
+
}
|
31
|
+
)
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
it "returns a 201 status code" do
|
35
|
+
add_node_to_index_request.status.should == 201
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
it "returns application/json" do
|
39
|
+
add_node_to_index_request.faraday_response.headers["content-type"].should include("application/json")
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
43
|
end
|
@@ -12,10 +12,10 @@ describe Keymaker::BatchGetNodesRequest do
|
|
12
12
|
|
13
13
|
it "builds the job descriptions collection" do
|
14
14
|
batch_get_nodes_request.opts.should == [
|
15
|
-
{id: 0, to: "
|
16
|
-
{id: 1, to: "
|
17
|
-
{id: 2, to: "
|
18
|
-
{id: 3, to: "
|
15
|
+
{id: 0, to: "#{neo4j_host}/db/data/node/1", method: "GET"},
|
16
|
+
{id: 1, to: "#{neo4j_host}/db/data/node/2", method: "GET"},
|
17
|
+
{id: 2, to: "#{neo4j_host}/db/data/node/3", method: "GET"},
|
18
|
+
{id: 3, to: "#{neo4j_host}/db/data/node/4", method: "GET"}
|
19
19
|
]
|
20
20
|
end
|
21
21
|
|
@@ -55,50 +55,50 @@ describe Keymaker::BatchRequest, :vcr => true do
|
|
55
55
|
|
56
56
|
let(:results) do
|
57
57
|
[ {"id"=>0,
|
58
|
-
"location"=>"
|
59
|
-
"body"=>{"outgoing_relationships"=>"
|
58
|
+
"location"=>"#{neo4j_host}/db/data/node/26",
|
59
|
+
"body"=>{"outgoing_relationships"=>"#{neo4j_host}/db/data/node/26/relationships/out",
|
60
60
|
"data"=>{"name"=>"John Connor"},
|
61
|
-
"traverse"=>"
|
62
|
-
"all_typed_relationships"=>"
|
63
|
-
"property"=>"
|
64
|
-
"self"=>"
|
65
|
-
"properties"=>"
|
66
|
-
"outgoing_typed_relationships"=>"
|
67
|
-
"incoming_relationships"=>"
|
61
|
+
"traverse"=>"#{neo4j_host}/db/data/node/26/traverse/{returnType}",
|
62
|
+
"all_typed_relationships"=>"#{neo4j_host}/db/data/node/26/relationships/all/{-list|&|types}",
|
63
|
+
"property"=>"#{neo4j_host}/db/data/node/26/properties/{key}",
|
64
|
+
"self"=>"#{neo4j_host}/db/data/node/26",
|
65
|
+
"properties"=>"#{neo4j_host}/db/data/node/26/properties",
|
66
|
+
"outgoing_typed_relationships"=>"#{neo4j_host}/db/data/node/26/relationships/out/{-list|&|types}",
|
67
|
+
"incoming_relationships"=>"#{neo4j_host}/db/data/node/26/relationships/in",
|
68
68
|
"extensions"=>{},
|
69
|
-
"create_relationship"=>"
|
70
|
-
"paged_traverse"=>"
|
71
|
-
"all_relationships"=>"
|
72
|
-
"incoming_typed_relationships"=>"
|
69
|
+
"create_relationship"=>"#{neo4j_host}/db/data/node/26/relationships",
|
70
|
+
"paged_traverse"=>"#{neo4j_host}/db/data/node/26/paged/traverse/{returnType}{?pageSize,leaseTime}",
|
71
|
+
"all_relationships"=>"#{neo4j_host}/db/data/node/26/relationships/all",
|
72
|
+
"incoming_typed_relationships"=>"#{neo4j_host}/db/data/node/26/relationships/in/{-list|&|types}"},
|
73
73
|
"from"=>"/node"},
|
74
74
|
{"id"=>1,
|
75
|
-
"location"=>"
|
76
|
-
"body"=>{"outgoing_relationships"=>"
|
75
|
+
"location"=>"#{neo4j_host}/db/data/node/27",
|
76
|
+
"body"=>{"outgoing_relationships"=>"#{neo4j_host}/db/data/node/27/relationships/out",
|
77
77
|
"data"=>{"name"=>"Sarah Connor"},
|
78
|
-
"traverse"=>"
|
79
|
-
"all_typed_relationships"=>"
|
80
|
-
"property"=>"
|
81
|
-
"self"=>"
|
82
|
-
"properties"=>"
|
83
|
-
"outgoing_typed_relationships"=>"
|
84
|
-
"incoming_relationships"=>"
|
78
|
+
"traverse"=>"#{neo4j_host}/db/data/node/27/traverse/{returnType}",
|
79
|
+
"all_typed_relationships"=>"#{neo4j_host}/db/data/node/27/relationships/all/{-list|&|types}",
|
80
|
+
"property"=>"#{neo4j_host}/db/data/node/27/properties/{key}",
|
81
|
+
"self"=>"#{neo4j_host}/db/data/node/27",
|
82
|
+
"properties"=>"#{neo4j_host}/db/data/node/27/properties",
|
83
|
+
"outgoing_typed_relationships"=>"#{neo4j_host}/db/data/node/27/relationships/out/{-list|&|types}",
|
84
|
+
"incoming_relationships"=>"#{neo4j_host}/db/data/node/27/relationships/in",
|
85
85
|
"extensions"=>{},
|
86
|
-
"create_relationship"=>"
|
87
|
-
"paged_traverse"=>"
|
88
|
-
"all_relationships"=>"
|
89
|
-
"incoming_typed_relationships"=>"
|
86
|
+
"create_relationship"=>"#{neo4j_host}/db/data/node/27/relationships",
|
87
|
+
"paged_traverse"=>"#{neo4j_host}/db/data/node/27/paged/traverse/{returnType}{?pageSize,leaseTime}",
|
88
|
+
"all_relationships"=>"#{neo4j_host}/db/data/node/27/relationships/all",
|
89
|
+
"incoming_typed_relationships"=>"#{neo4j_host}/db/data/node/27/relationships/in/{-list|&|types}"},
|
90
90
|
"from"=>"/node"},
|
91
91
|
{"id"=>3,
|
92
|
-
"location"=>"
|
93
|
-
"body"=>{"start"=>"
|
92
|
+
"location"=>"#{neo4j_host}/db/data/relationship/2",
|
93
|
+
"body"=>{"start"=>"#{neo4j_host}/db/data/node/26",
|
94
94
|
"data"=>{"since"=>"1985"},
|
95
|
-
"self"=>"
|
96
|
-
"property"=>"
|
97
|
-
"properties"=>"
|
95
|
+
"self"=>"#{neo4j_host}/db/data/relationship/2",
|
96
|
+
"property"=>"#{neo4j_host}/db/data/relationship/2/properties/{key}",
|
97
|
+
"properties"=>"#{neo4j_host}/db/data/relationship/2/properties",
|
98
98
|
"type"=>"knows",
|
99
99
|
"extensions"=>{},
|
100
|
-
"end"=>"
|
101
|
-
"from"=>"
|
100
|
+
"end"=>"#{neo4j_host}/db/data/node/27"},
|
101
|
+
"from"=>"#{neo4j_host}/db/data/node/26/relationships"}
|
102
102
|
]
|
103
103
|
end
|
104
104
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'keymaker'
|
3
|
+
|
4
|
+
describe Keymaker::CreateNodeRequest, vcr: true do
|
5
|
+
|
6
|
+
let(:create_node_request) { Keymaker::CreateNodeRequest.new(Keymaker.service, options).submit }
|
7
|
+
let(:options) {{}}
|
8
|
+
|
9
|
+
context "with properties" do
|
10
|
+
let(:options) {{name: "John Connor"}}
|
11
|
+
it "creates a node with the given properties" do
|
12
|
+
create_node_request.body.should include(
|
13
|
+
{"self"=>"#{neo4j_host}/db/data/node/40", "data"=>{"name"=>"John Connor"}}
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "without properties" do
|
19
|
+
it "creates an empty node" do
|
20
|
+
create_node_request.body.should include(
|
21
|
+
{"self"=>"#{neo4j_host}/db/data/node/41", "data"=>{}}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns a 201 status code" do
|
27
|
+
create_node_request.status.should == 201
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns application/json" do
|
31
|
+
create_node_request.faraday_response.headers["content-type"].should include("application/json")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'keymaker'
|
3
|
+
|
4
|
+
describe Keymaker::CreateRelationshipRequest, vcr: true do
|
5
|
+
|
6
|
+
include_context "John and Sarah nodes"
|
7
|
+
|
8
|
+
let(:create_relationship_request) { Keymaker::CreateRelationshipRequest.new(Keymaker.service, options).submit }
|
9
|
+
|
10
|
+
context "with properties" do
|
11
|
+
let(:options) do
|
12
|
+
{
|
13
|
+
node_id: sarah_node_id,
|
14
|
+
end_node_id: john_node_id,
|
15
|
+
rel_type: "birthed",
|
16
|
+
data: {location: "unknown", date: "1985-02-28"}
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
it "creates a node with the given properties" do
|
21
|
+
create_relationship_request.body.should include(
|
22
|
+
{"self"=>"#{neo4j_host}/db/data/relationship/18", "data"=>{"location"=>"unknown", "date"=>"1985-02-28"}, "type"=>"birthed"}
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns a 201 status code" do
|
27
|
+
create_relationship_request.status.should == 201
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns application/json" do
|
31
|
+
create_relationship_request.faraday_response.headers["content-type"].should include("application/json")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
context "without properties" do
|
37
|
+
let(:options) do
|
38
|
+
{
|
39
|
+
node_id: sarah_node_id,
|
40
|
+
end_node_id: john_node_id,
|
41
|
+
rel_type: "birthed"
|
42
|
+
}
|
43
|
+
end
|
44
|
+
it "creates an empty relationship of type: 'birthed'" do
|
45
|
+
create_relationship_request.body.should include(
|
46
|
+
{"self"=>"#{neo4j_host}/db/data/relationship/21", "data"=>{}, "type"=>"birthed"}
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "with invalid options" do
|
52
|
+
let(:options) {{}}
|
53
|
+
it "raises ClientError" do
|
54
|
+
expect { create_relationship_request }.to raise_error(Keymaker::ClientError)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|