mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel
This commit is contained in:
commit
682d22bfb0
|
@ -0,0 +1,744 @@
|
|||
# coding: utf-8
|
||||
|
||||
require 'rspec'
|
||||
require './arangodb.rb'
|
||||
|
||||
|
||||
describe ArangoDB do
|
||||
prefix = "api-graph"
|
||||
|
||||
vertex_collection = "v"
|
||||
edge_collection = "e"
|
||||
graph_name = "graph1"
|
||||
|
||||
context "testing graph methods:" do
|
||||
|
||||
def truncate_collection (prefix, name)
|
||||
cmd = "/_api/collection/#{name}/truncate"
|
||||
ArangoDB.put(cmd)
|
||||
end
|
||||
|
||||
def create_graph (prefix, name, vertices, edges)
|
||||
cmd = "/_api/graph"
|
||||
body = "{\"_key\" : \"#{name}\", \"vertices\" : \"#{vertices}\", \"edges\" : \"#{edges}\"}"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
return doc
|
||||
end
|
||||
|
||||
def create_vertex (prefix, graphName, body)
|
||||
cmd = "/_api/graph/#{graphName}/vertex"
|
||||
doc = ArangoDB.post(cmd, :body => body)
|
||||
return doc
|
||||
end
|
||||
|
||||
def create_simple_vertex (prefix, graphName, name)
|
||||
cmd = "/_api/graph/#{graphName}/vertex"
|
||||
body = "{\"_key\" : \"#{name}\"}"
|
||||
doc = ArangoDB.post(cmd, :body => body)
|
||||
return doc
|
||||
end
|
||||
|
||||
def create_edge (prefix, graphName, body)
|
||||
cmd = "/_api/graph/#{graphName}/edge"
|
||||
doc = ArangoDB.post(cmd, :body => body)
|
||||
return doc
|
||||
end
|
||||
|
||||
def get_vertex (prefix, graphName, name)
|
||||
cmd = "/_api/graph/#{graphName}/vertex/#{name}"
|
||||
doc = ArangoDB.get(cmd)
|
||||
return doc
|
||||
end
|
||||
|
||||
def get_edge (prefix, graphName, name)
|
||||
cmd = "/_api/graph/#{graphName}/edge/#{name}"
|
||||
doc = ArangoDB.get(cmd)
|
||||
return doc
|
||||
end
|
||||
|
||||
################################################################################
|
||||
## checking graph responses
|
||||
################################################################################
|
||||
|
||||
context "checks graph requests" do
|
||||
before do
|
||||
truncate_collection(prefix, "_graphs")
|
||||
end
|
||||
|
||||
after do
|
||||
truncate_collection(prefix, "_graphs")
|
||||
ArangoDB.drop_collection( vertex_collection )
|
||||
ArangoDB.drop_collection( edge_collection )
|
||||
end
|
||||
|
||||
it "checks create graph" do
|
||||
doc = create_graph( prefix, graph_name, vertex_collection, edge_collection )
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['graph']['_key'].should eq("#{graph_name}")
|
||||
end
|
||||
|
||||
it "checks create graph with wrong characters" do
|
||||
doc = create_graph( prefix, "hjü/$", vertex_collection, edge_collection )
|
||||
|
||||
doc.code.should eq(400)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['code'].should eq(400)
|
||||
end
|
||||
|
||||
it "checks create graph with wrong edges collection" do
|
||||
ArangoDB.create_collection( edge_collection , 0, 2)
|
||||
doc = create_graph( prefix, "wrong_edge_collection", vertex_collection, edge_collection )
|
||||
|
||||
doc.code.should eq(400)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['code'].should eq(400)
|
||||
end
|
||||
|
||||
it "checks create graph with same edges collection" do
|
||||
doc = create_graph( prefix, "with_same_edge_colection1", vertex_collection, edge_collection )
|
||||
doc.code.should eq(201)
|
||||
|
||||
doc = create_graph( prefix, "with_same_edge_colection2", "vertex33", edge_collection )
|
||||
|
||||
doc.code.should eq(400)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['code'].should eq(400)
|
||||
end
|
||||
|
||||
it "checks (re)create graph same name" do
|
||||
doc1 = create_graph( prefix, "recreate", vertex_collection, edge_collection )
|
||||
doc1.code.should eq(201)
|
||||
|
||||
doc2 = create_graph( prefix, "recreate", vertex_collection, edge_collection )
|
||||
doc2.code.should eq(201)
|
||||
end
|
||||
|
||||
it "checks (re)create graph different name" do
|
||||
doc1 = create_graph( prefix, "recreate_1", vertex_collection, edge_collection )
|
||||
doc1.code.should eq(201)
|
||||
|
||||
doc2 = create_graph( prefix, "recreate_2", vertex_collection, edge_collection )
|
||||
doc2.code.should eq(400)
|
||||
doc2.parsed_response['error'].should eq(true)
|
||||
end
|
||||
|
||||
it "checks create and get graph" do
|
||||
doc1 = create_graph( prefix, graph_name, vertex_collection, edge_collection )
|
||||
doc1.code.should eq(201)
|
||||
|
||||
doc1.parsed_response['graph']['_key'].should eq(graph_name)
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}"
|
||||
doc2 = ArangoDB.log_get("#{prefix}", cmd)
|
||||
|
||||
doc2.code.should eq(200)
|
||||
doc2.parsed_response['graph']['_key'].should eq(graph_name)
|
||||
end
|
||||
|
||||
it "checks create and delete graph" do
|
||||
# create
|
||||
doc1 = create_graph( prefix, graph_name, vertex_collection, edge_collection )
|
||||
doc1.code.should eq(201)
|
||||
|
||||
# delete
|
||||
cmd = "/_api/graph/#{graph_name}"
|
||||
doc2 = ArangoDB.log_delete("#{prefix}", cmd)
|
||||
doc2.code.should eq(200)
|
||||
doc2.parsed_response['deleted'].should eq(true)
|
||||
|
||||
# check
|
||||
doc3 = ArangoDB.log_get("#{prefix}", cmd)
|
||||
doc3.code.should eq(400)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
################################################################################
|
||||
## checking vertex responses
|
||||
################################################################################
|
||||
|
||||
context "checks graph vertex requests" do
|
||||
before do
|
||||
truncate_collection(prefix, "_graphs")
|
||||
doc = create_graph( prefix, graph_name, vertex_collection, edge_collection )
|
||||
end
|
||||
|
||||
after do
|
||||
truncate_collection(prefix, "_graphs")
|
||||
ArangoDB.drop_collection( vertex_collection )
|
||||
ArangoDB.drop_collection( edge_collection )
|
||||
end
|
||||
|
||||
it "checks create vertex with _key" do
|
||||
|
||||
body = "{\"\_key\" : \"vertexTest1\", \"optional1\" : \"val1\", \"optional2\" : \"val2\"}"
|
||||
doc = create_vertex( prefix, graph_name, body )
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
doc.parsed_response['vertex']['_key'].should eq("vertexTest1")
|
||||
doc.parsed_response['vertex']['optional1'].should eq("val1")
|
||||
end
|
||||
|
||||
it "checks create second vertex with same _key" do
|
||||
body = "{\"\_key\" : \"vertexTest2\", \"optional1\" : \"val1\", \"optional2\" : \"val2\"}"
|
||||
doc = create_vertex( prefix, graph_name, body )
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
|
||||
doc2 = create_vertex( prefix, graph_name, body )
|
||||
doc2.code.should eq(400)
|
||||
doc2.parsed_response['error'].should eq(true)
|
||||
doc2.parsed_response['code'].should eq(400)
|
||||
end
|
||||
|
||||
it "checks get vertex by _key" do
|
||||
body = "{\"\_key\" : \"vertexTest3\", \"optional1\" : \"val1\", \"optional2\" : \"val2\"}"
|
||||
doc = create_vertex( prefix, graph_name, body )
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
doc.parsed_response['vertex']['_key'].should eq("vertexTest3")
|
||||
doc.parsed_response['vertex']['optional1'].should eq("val1")
|
||||
|
||||
doc2 = get_vertex( prefix, graph_name, "vertexTest3")
|
||||
doc2.code.should eq(200)
|
||||
doc2.parsed_response['error'].should eq(false)
|
||||
doc2.parsed_response['code'].should eq(200)
|
||||
doc2.parsed_response['vertex']['optional1'].should eq(doc.parsed_response['vertex']['optional1'])
|
||||
end
|
||||
|
||||
it "checks get vertex by _id" do
|
||||
body = "{\"\_key\" : \"vertexTest_id\", \"optional1\" : \"val1\", \"optional2\" : \"val2\"}"
|
||||
doc = create_vertex( prefix, graph_name, body )
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
_id = doc.parsed_response['vertex']['_id'];
|
||||
|
||||
doc2 = get_vertex( prefix, graph_name, _id)
|
||||
doc2.code.should eq(200)
|
||||
doc2.parsed_response['error'].should eq(false)
|
||||
doc2.parsed_response['code'].should eq(200)
|
||||
doc2.parsed_response['vertex']['optional1'].should eq(doc.parsed_response['vertex']['optional1'])
|
||||
end
|
||||
|
||||
it "checks get vertex by wrong _key" do
|
||||
doc = get_vertex( prefix, graph_name, "vvv111")
|
||||
doc.code.should eq(400)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['code'].should eq(400)
|
||||
end
|
||||
|
||||
it "checks update vertex by _key" do
|
||||
body = "{\"\_key\" : \"vertexTest5\", \"optional1\" : \"val1\"}"
|
||||
doc = create_vertex( prefix, graph_name, body )
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
doc.parsed_response['vertex']['_key'].should eq("vertexTest5")
|
||||
doc.parsed_response['vertex']['optional1'].should eq("val1")
|
||||
|
||||
doc1 = get_vertex( prefix, graph_name, "vertexTest5")
|
||||
doc1.code.should eq(200)
|
||||
doc1.parsed_response['vertex']['optional1'].should eq("val1")
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}/vertex/vertexTest5"
|
||||
body = "{\"optional1\" : \"val2\"}"
|
||||
doc3 = ArangoDB.log_put("#{prefix}", cmd, :body => body)
|
||||
doc3.code.should eq(200)
|
||||
doc3.parsed_response['error'].should eq(false)
|
||||
doc3.parsed_response['code'].should eq(200)
|
||||
doc3.parsed_response['vertex']['optional1'].should eq("val2")
|
||||
|
||||
doc2 = get_vertex( prefix, graph_name, "vertexTest5")
|
||||
doc2.code.should eq(200)
|
||||
doc2.parsed_response['vertex']['optional1'].should eq("val2")
|
||||
end
|
||||
|
||||
it "checks update vertex" do
|
||||
body = "{\"optional1\" : \"val1\", \"optional2\" : \"val2\"}"
|
||||
doc = create_vertex( prefix, graph_name, body )
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
doc.parsed_response['vertex']['optional1'].should eq("val1")
|
||||
doc.parsed_response['vertex']['optional2'].should eq("val2")
|
||||
_key = doc.parsed_response['vertex']['_key'];
|
||||
|
||||
doc2 = get_vertex( prefix, graph_name, _key)
|
||||
doc2.code.should eq(200)
|
||||
doc2.parsed_response['error'].should eq(false)
|
||||
doc2.parsed_response['code'].should eq(200)
|
||||
doc2.parsed_response['vertex']['optional1'].should eq(doc.parsed_response['vertex']['optional1'])
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}/vertex/#{_key}"
|
||||
body = "{\"optional1\" : \"val2\"}"
|
||||
doc3 = ArangoDB.log_put("#{prefix}", cmd, :body => body)
|
||||
doc3.code.should eq(200)
|
||||
doc3.parsed_response['error'].should eq(false)
|
||||
doc3.parsed_response['code'].should eq(200)
|
||||
doc3.parsed_response['vertex']['optional1'].should eq("val2")
|
||||
doc3.parsed_response['vertex']['optional2'].should eq(nil)
|
||||
|
||||
doc4 = get_vertex( prefix, graph_name, _key)
|
||||
doc4.code.should eq(200)
|
||||
doc4.parsed_response['error'].should eq(false)
|
||||
doc4.parsed_response['code'].should eq(200)
|
||||
doc4.parsed_response['vertex']['optional1'].should eq("val2")
|
||||
doc4.parsed_response['vertex']['optional2'].should eq(nil)
|
||||
end
|
||||
|
||||
it "checks delete vertex" do
|
||||
body = "{\"optional1\" : \"vertexDelete1\"}"
|
||||
doc = create_vertex( prefix, graph_name, body )
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
_key = doc.parsed_response['vertex']['_key'];
|
||||
|
||||
doc3 = get_vertex( prefix, graph_name, _key)
|
||||
doc3.code.should eq(200)
|
||||
doc3.parsed_response['error'].should eq(false)
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}/vertex/#{_key}"
|
||||
doc2 = ArangoDB.log_delete("#{prefix}", cmd)
|
||||
doc2.code.should eq(200)
|
||||
doc2.parsed_response['error'].should eq(false)
|
||||
doc2.parsed_response['code'].should eq(200)
|
||||
doc2.parsed_response['deleted'].should eq(true)
|
||||
|
||||
doc4 = get_vertex( prefix, graph_name, _key)
|
||||
doc4.code.should eq(400)
|
||||
doc4.parsed_response['error'].should eq(true)
|
||||
doc4.parsed_response['code'].should eq(400)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
################################################################################
|
||||
## checking edge responses
|
||||
################################################################################
|
||||
|
||||
context "checks edge requests" do
|
||||
before do
|
||||
truncate_collection(prefix, "_graphs")
|
||||
doc = create_graph( prefix, graph_name, vertex_collection, edge_collection )
|
||||
create_simple_vertex( prefix, graph_name, "vert1" )
|
||||
create_simple_vertex( prefix, graph_name, "vert2" )
|
||||
create_simple_vertex( prefix, graph_name, "vert3" )
|
||||
end
|
||||
|
||||
after do
|
||||
truncate_collection(prefix, "_graphs")
|
||||
ArangoDB.drop_collection( vertex_collection )
|
||||
ArangoDB.drop_collection( edge_collection )
|
||||
end
|
||||
|
||||
it "checks create edge" do
|
||||
body = "{\"_key\" : \"edgeTest1\", \"_from\" : \"vert2\", \"_to\" : \"vert1\", \"optional1\" : \"val1\"}"
|
||||
doc = create_edge( prefix, graph_name, body )
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
doc.parsed_response['edge']['_key'].should eq("edgeTest1")
|
||||
doc.parsed_response['edge']['optional1'].should eq("val1")
|
||||
doc.parsed_response['edge']['$label'].should eq(nil)
|
||||
end
|
||||
|
||||
it "checks create second edge with same \_key" do
|
||||
body = "{\"_key\" : \"edgeTest2\", \"_from\" : \"vert2\", \"_to\" : \"vert1\", \"optional1\" : \"val1\"}"
|
||||
doc = create_edge( prefix, graph_name, body )
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
doc.parsed_response['edge']['_key'].should eq("edgeTest2")
|
||||
doc.parsed_response['edge']['optional1'].should eq("val1")
|
||||
doc.parsed_response['edge']['$label'].should eq(nil)
|
||||
|
||||
doc1 = create_edge( prefix, graph_name, body )
|
||||
doc1.code.should eq(400)
|
||||
doc1.parsed_response['error'].should eq(true)
|
||||
doc1.parsed_response['code'].should eq(400)
|
||||
end
|
||||
|
||||
it "checks create edge with unknown vertex" do
|
||||
body = "{\"_key\" : \"edgeTest3\", \"_from\" : \"unknownVertex\", \"_to\" : \"vert1\", \"optional1\" : \"val1\"}"
|
||||
doc = create_edge( prefix, graph_name, body )
|
||||
doc.code.should eq(400)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['code'].should eq(400)
|
||||
end
|
||||
|
||||
it "checks create edge with \$label" do
|
||||
body = "{\"_key\" : \"edgeTest4\", \"_from\" : \"vert2\", \"_to\" : \"vert1\", \"$label\" : \"label1\", \"optional1\" : \"val1\"}"
|
||||
doc = create_edge( prefix, graph_name, body )
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
doc.parsed_response['edge']['_key'].should eq("edgeTest4")
|
||||
doc.parsed_response['edge']['optional1'].should eq("val1")
|
||||
doc.parsed_response['edge']['$label'].should eq("label1")
|
||||
end
|
||||
|
||||
it "checks create edge with _id of vertex" do
|
||||
doc = create_simple_vertex( prefix, graph_name, "vert1a" )
|
||||
v_id1 = doc.parsed_response['vertex']['_id']
|
||||
|
||||
doc = create_simple_vertex( prefix, graph_name, "vert2a" )
|
||||
v_id2 = doc.parsed_response['vertex']['_id']
|
||||
|
||||
body = "{\"_key\" : \"edgeTest5\", \"_from\" : \"#{v_id1}\", \"_to\" : \"#{v_id2}\", \"$label\" : \"label1\", \"optional1\" : \"val1\"}"
|
||||
doc = create_edge( prefix, graph_name, body )
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
doc.parsed_response['edge']['_key'].should eq("edgeTest5")
|
||||
doc.parsed_response['edge']['optional1'].should eq("val1")
|
||||
doc.parsed_response['edge']['_from'].should eq(v_id1)
|
||||
doc.parsed_response['edge']['_to'].should eq(v_id2)
|
||||
end
|
||||
|
||||
it "checks get edge by _id" do
|
||||
body = "{\"_key\" : \"edgeTest6\", \"_from\" : \"vert2\", \"_to\" : \"vert1\", \"$label\" : \"label1\", \"optional1\" : \"val1\"}"
|
||||
doc = create_edge( prefix, graph_name, body )
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
doc.parsed_response['edge']['_key'].should eq("edgeTest6")
|
||||
doc.parsed_response['edge']['optional1'].should eq("val1")
|
||||
doc.parsed_response['edge']['$label'].should eq("label1")
|
||||
|
||||
e_key = doc.parsed_response['edge']['_key']
|
||||
e_id = doc.parsed_response['edge']['_id']
|
||||
|
||||
doc1 = get_edge( prefix, graph_name, e_key )
|
||||
|
||||
doc1.code.should eq(200)
|
||||
doc1.parsed_response['error'].should eq(false)
|
||||
doc1.parsed_response['code'].should eq(200)
|
||||
doc1.parsed_response['edge']['_id'].should eq(e_id)
|
||||
|
||||
doc2 = get_edge( prefix, graph_name, e_id )
|
||||
|
||||
doc2.code.should eq(200)
|
||||
doc2.parsed_response['error'].should eq(false)
|
||||
doc2.parsed_response['code'].should eq(200)
|
||||
doc2.parsed_response['edge']['_id'].should eq(e_id)
|
||||
end
|
||||
|
||||
it "checks replace edge properties by _id" do
|
||||
body = "{\"_key\" : \"edgeTest7\", \"_from\" : \"vert2\", \"_to\" : \"vert1\", \"$label\" : \"label1\", \"optional1\" : \"val1\"}"
|
||||
doc = create_edge( prefix, graph_name, body )
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
doc.parsed_response['edge']['optional1'].should eq("val1")
|
||||
doc.parsed_response['edge']['optional2'].should eq(nil)
|
||||
|
||||
e_key = doc.parsed_response['edge']['_key']
|
||||
e_id = doc.parsed_response['edge']['_id']
|
||||
e_to = doc.parsed_response['edge']['_to']
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}/edge/#{e_id}"
|
||||
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
|
||||
doc1 = ArangoDB.log_put("#{prefix}", cmd, :body => body)
|
||||
doc1.code.should eq(200)
|
||||
doc1.parsed_response['error'].should eq(false)
|
||||
doc1.parsed_response['code'].should eq(200)
|
||||
doc1.parsed_response['edge']['_key'].should eq(e_key)
|
||||
doc1.parsed_response['edge']['_id'].should eq(e_id)
|
||||
doc1.parsed_response['edge']['_to'].should eq(e_to)
|
||||
doc1.parsed_response['edge']['optional1'].should eq(nil)
|
||||
doc1.parsed_response['edge']['optional2'].should eq("val2")
|
||||
doc1.parsed_response['edge']['$label'].should eq("label1")
|
||||
end
|
||||
|
||||
it "checks delete edge by _id" do
|
||||
body = "{\"_key\" : \"edgeTest8\", \"_from\" : \"vert2\", \"_to\" : \"vert1\", \"$label\" : \"label1\", \"optional1\" : \"val1\"}"
|
||||
doc = create_edge( prefix, graph_name, body )
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
doc.parsed_response['edge']['optional1'].should eq("val1")
|
||||
doc.parsed_response['edge']['optional2'].should eq(nil)
|
||||
|
||||
e_id = doc.parsed_response['edge']['_id']
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}/edge/#{e_id}"
|
||||
doc1 = ArangoDB.log_delete("#{prefix}", cmd)
|
||||
doc1.code.should eq(200)
|
||||
doc1.parsed_response['error'].should eq(false)
|
||||
doc1.parsed_response['code'].should eq(200)
|
||||
|
||||
doc2 = get_edge( prefix, graph_name, e_id )
|
||||
doc2.code.should eq(400)
|
||||
doc2.parsed_response['error'].should eq(true)
|
||||
doc2.parsed_response['code'].should eq(400)
|
||||
end
|
||||
|
||||
it "checks delete edge by _key" do
|
||||
body = "{\"_key\" : \"edgeTest9\", \"_from\" : \"vert2\", \"_to\" : \"vert1\", \"$label\" : \"label1\", \"optional1\" : \"val1\"}"
|
||||
doc = create_edge( prefix, graph_name, body )
|
||||
doc.code.should eq(200)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(200)
|
||||
doc.parsed_response['edge']['optional1'].should eq("val1")
|
||||
doc.parsed_response['edge']['optional2'].should eq(nil)
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}/edge/edgeTest9"
|
||||
doc1 = ArangoDB.log_delete("#{prefix}", cmd)
|
||||
doc1.code.should eq(200)
|
||||
doc1.parsed_response['error'].should eq(false)
|
||||
doc1.parsed_response['code'].should eq(200)
|
||||
|
||||
doc2 = get_edge( prefix, graph_name, "edgeTest9" )
|
||||
doc2.code.should eq(400)
|
||||
doc2.parsed_response['error'].should eq(true)
|
||||
doc2.parsed_response['code'].should eq(400)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
################################################################################
|
||||
## checking vertices responses
|
||||
################################################################################
|
||||
|
||||
context "checks vertices requests" do
|
||||
before do
|
||||
truncate_collection(prefix, "_graphs")
|
||||
doc = create_graph( prefix, graph_name, vertex_collection, edge_collection )
|
||||
cmd = "/_api/graph/#{graph_name}/vertex"
|
||||
body = "{\"_key\" : \"id1\", \"optional1\" : \"val1\", \"optional2\" : 1}"
|
||||
ArangoDB.post(cmd, :body => body)
|
||||
body = "{\"_key\" : \"id2\", \"optional1\" : \"val1\", \"optional2\" : 2}"
|
||||
ArangoDB.post(cmd, :body => body)
|
||||
body = "{\"_key\" : \"id3\", \"optional1\" : \"val1\", \"optional2\" : 2}"
|
||||
ArangoDB.post(cmd, :body => body)
|
||||
body = "{\"_key\" : \"id4\", \"optional1\" : \"val1\", \"optional2\" : 3}"
|
||||
ArangoDB.post(cmd, :body => body)
|
||||
body = "{\"_key\" : \"id5\", \"optional2\" : \"val2\"}"
|
||||
ArangoDB.post(cmd, :body => body)
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}/edge"
|
||||
body = "{\"_key\" : \"edge1\", \"_from\" : \"id1\", \"_to\" : \"id2\", \"$label\" : \"l1\"}"
|
||||
doc = ArangoDB.post(cmd, :body => body)
|
||||
body = "{\"_key\" : \"edge2\", \"_from\" : \"id2\", \"_to\" : \"id3\", \"$label\" : \"l2\"}"
|
||||
doc = ArangoDB.post(cmd, :body => body)
|
||||
end
|
||||
|
||||
after do
|
||||
truncate_collection(prefix, "_graphs")
|
||||
ArangoDB.drop_collection( vertex_collection )
|
||||
ArangoDB.drop_collection( edge_collection )
|
||||
end
|
||||
|
||||
it "checks list of vertices of a graph" do
|
||||
cmd = "/_api/graph/#{graph_name}/vertices"
|
||||
body = "{\"batchSize\" : 100 }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(5)
|
||||
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"properties\" : [ { \"key\" : \"optional2\", \"value\" : 3 } ] } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(1)
|
||||
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"properties\" : [ { \"key\" : \"optional2\", \"value\" : 2 } ] } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(2)
|
||||
end
|
||||
|
||||
it "checks list of vertices of a vertex" do
|
||||
cmd = "/_api/graph/#{graph_name}/vertices"
|
||||
body = "{\"batchSize\" : 100 }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(5)
|
||||
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"properties\" : [ { \"key\" : \"optional2\", \"value\" : 3 } ] } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(1)
|
||||
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"properties\" : [ { \"key\" : \"optional2\", \"value\" : 2 } ] } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(2)
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}/vertices/id2"
|
||||
body = "{\"batchSize\" : 100 }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(2)
|
||||
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"direction\" : \"in\" } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(1)
|
||||
doc.parsed_response['result'][0]['_key'].should eq("id1")
|
||||
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"direction\" : \"out\" } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(1)
|
||||
doc.parsed_response['result'][0]['_key'].should eq("id3")
|
||||
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"labels\" : [\"l2\"] } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(1)
|
||||
doc.parsed_response['result'][0]['_key'].should eq("id3")
|
||||
|
||||
end
|
||||
|
||||
it "checks list of vertices of a vertex with compare" do
|
||||
cmd = "/_api/graph/#{graph_name}/vertices"
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"properties\" : [ { \"key\" : \"optional2\", \"value\" : 100 , \"compare\" : \"<\" } ] } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(4)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
################################################################################
|
||||
## checking edges responses
|
||||
################################################################################
|
||||
|
||||
context "checks edges requests" do
|
||||
before do
|
||||
truncate_collection(prefix, "_graphs")
|
||||
doc = create_graph( prefix, graph_name, vertex_collection, edge_collection )
|
||||
cmd = "/_api/graph/#{graph_name}/vertex"
|
||||
body = "{\"_key\" : \"id1\", \"optional1\" : \"val1a\", \"optional2\" : \"val2a\"}"
|
||||
ArangoDB.post(cmd, :body => body)
|
||||
body = "{\"_key\" : \"id2\", \"optional1\" : \"val1b\", \"optional2\" : \"val2b\"}"
|
||||
ArangoDB.post(cmd, :body => body)
|
||||
body = "{\"_key\" : \"id3\", \"optional1\" : \"val1c\", \"optional2\" : \"val2c\"}"
|
||||
ArangoDB.post(cmd, :body => body)
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}/edge"
|
||||
body1 = "{\"_key\" : \"edge1\", \"_from\" : \"id1\", \"_to\" : \"id2\", \"optional1\" : \"val1a\"}"
|
||||
ArangoDB.post(cmd, :body => body1)
|
||||
body2 = "{\"_key\" : \"edge2\", \"_from\" : \"id2\", \"_to\" : \"id3\", \"optional1\" : \"val1b\"}"
|
||||
ArangoDB.post(cmd, :body => body2)
|
||||
end
|
||||
|
||||
after do
|
||||
truncate_collection(prefix, "_graphs")
|
||||
ArangoDB.drop_collection( vertex_collection )
|
||||
ArangoDB.drop_collection( edge_collection )
|
||||
end
|
||||
|
||||
it "checks list of all edges" do
|
||||
cmd = "/_api/graph/#{graph_name}/edges"
|
||||
body = "{\"batchSize\" : 100}"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(2)
|
||||
end
|
||||
|
||||
it "checks list of all edges" do
|
||||
cmd = "/_api/graph/#{graph_name}/edges"
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"properties\" : [ { \"key\" : \"optional1\", \"value\" : \"val1a\" } ] } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(1)
|
||||
end
|
||||
|
||||
it "checks list of all edges of one vertex" do
|
||||
cmd = "/_api/graph/#{graph_name}/edges/id1"
|
||||
body = "{\"batchSize\" : 100 }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(1)
|
||||
doc.parsed_response['result'][0]['_key'].should eq("edge1")
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}/edges/id2"
|
||||
body = "{\"batchSize\" : 100 }"
|
||||
doc2 = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
|
||||
doc2.code.should eq(201)
|
||||
doc2.parsed_response['error'].should eq(false)
|
||||
doc2.parsed_response['code'].should eq(201)
|
||||
doc2.parsed_response['result'].count.should eq(2)
|
||||
end
|
||||
|
||||
it "checks list of all in edges of one vertex" do
|
||||
cmd = "/_api/graph/#{graph_name}/edges/id2"
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"direction\" : \"in\" } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(1)
|
||||
doc.parsed_response['result'][0]['_key'].should eq("edge1")
|
||||
end
|
||||
|
||||
it "checks list of all out edges of one vertex" do
|
||||
cmd = "/_api/graph/#{graph_name}/edges/id2"
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"direction\" : \"out\" } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(1)
|
||||
doc.parsed_response['result'][0]['_key'].should eq("edge2")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -4,6 +4,7 @@ test -d logs || mkdir logs
|
|||
rspec --format d \
|
||||
api-http-spec.rb \
|
||||
api-admin-spec.rb \
|
||||
api-graph-spec.rb \
|
||||
api-batch-spec.rb \
|
||||
api-collection-spec.rb \
|
||||
rest-key-spec.rb \
|
||||
|
@ -17,7 +18,6 @@ rspec --format d \
|
|||
api-index-bitarray-spec.rb \
|
||||
api-index-hash-spec.rb \
|
||||
api-index-skiplist-spec.rb \
|
||||
api-blueprints-spec.rb \
|
||||
api-explain-spec.rb \
|
||||
api-cursor-spec.rb \
|
||||
api-statistics-spec.rb \
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -139,7 +139,7 @@ function Edge (graph, id) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Edge.prototype.getId = function () {
|
||||
return this._properties.$id;
|
||||
return this._properties._key;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -200,11 +200,11 @@ Edge.prototype.getOutVertex = function () {
|
|||
/// @EXAMPLES
|
||||
///
|
||||
/// @code
|
||||
/// arango> v1 = g.addVertex(1);
|
||||
/// Vertex(1)
|
||||
/// arango> v1 = g.addVertex("1");
|
||||
/// Vertex("1")
|
||||
///
|
||||
/// arango> v2 = g.addVertex(2);
|
||||
/// Vertex(2)
|
||||
/// arango> v2 = g.addVertex("2");
|
||||
/// Vertex("2")
|
||||
///
|
||||
/// arango> e = g.addEdge(v1, v2, "1->2", "knows");
|
||||
/// Edge("1->2")
|
||||
|
@ -277,7 +277,6 @@ Edge.prototype.setProperty = function (name, value) {
|
|||
// Could potentially change the weight of edges
|
||||
this._graph.emptyCachedPredecessors();
|
||||
|
||||
shallow.$id = this._properties.$id;
|
||||
shallow.$label = this._properties.$label;
|
||||
shallow[name] = value;
|
||||
|
||||
|
@ -327,11 +326,11 @@ Edge.prototype._PRINT = function (seen, path, names) {
|
|||
|
||||
if (!this._id) {
|
||||
internal.output("[deleted Edge]");
|
||||
} else if (this._properties.$id !== undefined) {
|
||||
if (typeof this._properties.$id === "string") {
|
||||
internal.output("Edge(\"", this._properties.$id, "\")");
|
||||
} else if (this._properties._key !== undefined) {
|
||||
if (typeof this._properties._key === "string") {
|
||||
internal.output("Edge(\"", this._properties._key, "\")");
|
||||
} else {
|
||||
internal.output("Edge(", this._properties.$id, ")");
|
||||
internal.output("Edge(", this._properties._key, ")");
|
||||
}
|
||||
} else {
|
||||
internal.output("Edge(<", this._id, ">)");
|
||||
|
@ -480,7 +479,7 @@ Vertex.prototype.edges = function () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Vertex.prototype.getId = function () {
|
||||
return this._properties.$id;
|
||||
return this._properties._key;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -637,7 +636,6 @@ Vertex.prototype.setProperty = function (name, value) {
|
|||
var shallow = this._properties.shallowCopy,
|
||||
id;
|
||||
|
||||
shallow.$id = this._properties.$id;
|
||||
shallow[name] = value;
|
||||
|
||||
// TODO use "update" if this becomes available
|
||||
|
@ -1072,11 +1070,11 @@ Vertex.prototype._PRINT = function (seen, path, names) {
|
|||
|
||||
if (!this._id) {
|
||||
internal.output("[deleted Vertex]");
|
||||
} else if (this._properties.$id !== undefined) {
|
||||
if (typeof this._properties.$id === "string") {
|
||||
internal.output("Vertex(\"", this._properties.$id, "\")");
|
||||
} else if (this._properties._key !== undefined) {
|
||||
if (typeof this._properties._key === "string") {
|
||||
internal.output("Vertex(\"", this._properties._key, "\")");
|
||||
} else {
|
||||
internal.output("Vertex(", this._properties.$id, ")");
|
||||
internal.output("Vertex(", this._properties._key, ")");
|
||||
}
|
||||
} else {
|
||||
internal.output("Vertex(<", this._id, ">)");
|
||||
|
@ -1135,9 +1133,6 @@ function Graph(name, vertices, edges) {
|
|||
if (vertices === undefined && edges === undefined) {
|
||||
// Find an existing graph
|
||||
|
||||
graphProperties = gdb.firstExample('name', name);
|
||||
|
||||
if (graphProperties === null) {
|
||||
try {
|
||||
graphProperties = gdb.document(name);
|
||||
} catch (e) {
|
||||
|
@ -1147,7 +1142,6 @@ function Graph(name, vertices, edges) {
|
|||
if (graphProperties === null) {
|
||||
throw "no graph named '" + name + "' found";
|
||||
}
|
||||
}
|
||||
|
||||
vertices = internal.db._collection(graphProperties.vertices);
|
||||
|
||||
|
@ -1170,11 +1164,11 @@ function Graph(name, vertices, edges) {
|
|||
vertices = findOrCreateCollectionByName(vertices);
|
||||
edges = findOrCreateEdgeCollectionByName(edges);
|
||||
|
||||
// Currently buggy?
|
||||
edges.ensureUniqueConstraint("$id");
|
||||
vertices.ensureUniqueConstraint("$id");
|
||||
|
||||
graphProperties = gdb.firstExample('name', name);
|
||||
try {
|
||||
graphProperties = gdb.document(name);
|
||||
} catch (e) {
|
||||
graphProperties = null;
|
||||
}
|
||||
|
||||
// Graph doesn't exist yet
|
||||
if (graphProperties === null) {
|
||||
|
@ -1186,14 +1180,20 @@ function Graph(name, vertices, edges) {
|
|||
edges._id
|
||||
);
|
||||
|
||||
if (graphProperties === null) {
|
||||
|
||||
// check if edge is used in a graph
|
||||
graphProperties = gdb.firstExample('edges', edges._id);
|
||||
|
||||
if (graphProperties === null) {
|
||||
graphPropertiesId = gdb.save({ 'vertices' : vertices._id,
|
||||
'verticesName' : vertices.name(),
|
||||
'edges' : edges._id,
|
||||
'edgesName' : edges.name(),
|
||||
'name' : name });
|
||||
'_key' : name });
|
||||
|
||||
graphProperties = gdb.document(graphPropertiesId);
|
||||
} else {
|
||||
throw "edge collection already used";
|
||||
}
|
||||
} else {
|
||||
throw "found graph but has different <name>";
|
||||
}
|
||||
|
@ -1305,7 +1305,10 @@ Graph.prototype.addEdge = function (out_vertex, in_vertex, id, label, data) {
|
|||
shallow = data.shallowCopy || {};
|
||||
}
|
||||
|
||||
shallow.$id = id || null;
|
||||
if (id !== undefined) {
|
||||
shallow._key = id;
|
||||
}
|
||||
|
||||
shallow.$label = label || null;
|
||||
|
||||
ref = this._edges.save(out_vertex._id, in_vertex._id, shallow);
|
||||
|
@ -1348,7 +1351,9 @@ Graph.prototype.addVertex = function (id, data) {
|
|||
shallow = data.shallowCopy || {};
|
||||
}
|
||||
|
||||
shallow.$id = id || null;
|
||||
if (id !== undefined) {
|
||||
shallow._key = id;
|
||||
}
|
||||
|
||||
ref = this._vertices.save(shallow);
|
||||
|
||||
|
@ -1371,7 +1376,11 @@ Graph.prototype.getVertex = function (id) {
|
|||
var ref,
|
||||
vertex;
|
||||
|
||||
ref = this._vertices.firstExample('$id', id);
|
||||
try {
|
||||
ref = this._vertices.document(id);
|
||||
} catch (e) {
|
||||
ref = null;
|
||||
}
|
||||
|
||||
if (ref !== null) {
|
||||
vertex = this.constructVertex(ref._id);
|
||||
|
@ -1461,7 +1470,11 @@ Graph.prototype.getEdge = function (id) {
|
|||
var ref,
|
||||
edge;
|
||||
|
||||
ref = this._edges.firstExample('$id', id);
|
||||
try {
|
||||
ref = this._edges.document(id);
|
||||
} catch (e) {
|
||||
ref = null;
|
||||
}
|
||||
|
||||
if (ref !== null) {
|
||||
edge = this.constructEdge(ref._id);
|
||||
|
@ -1829,7 +1842,7 @@ Graph.prototype._PRINT = function (seen, path, names) {
|
|||
seen = path = names = null;
|
||||
|
||||
output = "Graph(\"";
|
||||
output += this._properties.name;
|
||||
output += this._properties._key;
|
||||
output += "\")";
|
||||
internal.output(output);
|
||||
};
|
||||
|
|
|
@ -98,9 +98,9 @@ function neighborSuite() {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testGetAllNeighbors : function () {
|
||||
var v1 = graph.addVertex(1),
|
||||
v2 = graph.addVertex(2),
|
||||
v3 = graph.addVertex(3),
|
||||
var v1 = graph.addVertex("1"),
|
||||
v2 = graph.addVertex("2"),
|
||||
v3 = graph.addVertex("3"),
|
||||
result_array = [];
|
||||
|
||||
graph.addEdge(v1, v2);
|
||||
|
@ -108,15 +108,15 @@ function neighborSuite() {
|
|||
|
||||
result_array = v1.getNeighbors({ direction: 'both' });
|
||||
|
||||
assertEqual(result_array.length, 2);
|
||||
assertEqual(result_array[0].id, 2);
|
||||
assertEqual(result_array[1].id, 3);
|
||||
assertEqual(result_array.length, "2");
|
||||
assertEqual(result_array[0].id, "2");
|
||||
assertEqual(result_array[1].id, "3");
|
||||
},
|
||||
|
||||
testGetOutboundNeighbors : function () {
|
||||
var v1 = graph.addVertex(1),
|
||||
v2 = graph.addVertex(2),
|
||||
v3 = graph.addVertex(3),
|
||||
var v1 = graph.addVertex("1"),
|
||||
v2 = graph.addVertex("2"),
|
||||
v3 = graph.addVertex("3"),
|
||||
result_array = [];
|
||||
|
||||
graph.addEdge(v1, v2);
|
||||
|
@ -124,14 +124,14 @@ function neighborSuite() {
|
|||
|
||||
result_array = v1.getNeighbors({ direction: 'outbound' });
|
||||
|
||||
assertEqual(result_array.length, 1);
|
||||
assertEqual(result_array[0].id, 2);
|
||||
assertEqual(result_array.length, "1");
|
||||
assertEqual(result_array[0].id, "2");
|
||||
},
|
||||
|
||||
testGetInboundNeighbors : function () {
|
||||
var v1 = graph.addVertex(1),
|
||||
v2 = graph.addVertex(2),
|
||||
v3 = graph.addVertex(3),
|
||||
var v1 = graph.addVertex("1"),
|
||||
v2 = graph.addVertex("2"),
|
||||
v3 = graph.addVertex("3"),
|
||||
result_array = [];
|
||||
|
||||
graph.addEdge(v1, v2);
|
||||
|
@ -139,14 +139,14 @@ function neighborSuite() {
|
|||
|
||||
result_array = v1.getNeighbors({ direction: 'inbound' });
|
||||
|
||||
assertEqual(result_array.length, 1);
|
||||
assertEqual(result_array[0].id, 3);
|
||||
assertEqual(result_array.length, "1");
|
||||
assertEqual(result_array[0].id, "3");
|
||||
},
|
||||
|
||||
testGetNeighborsWithPathLabel : function () {
|
||||
var v1 = graph.addVertex(1),
|
||||
v2 = graph.addVertex(2),
|
||||
v3 = graph.addVertex(3),
|
||||
var v1 = graph.addVertex("1"),
|
||||
v2 = graph.addVertex("2"),
|
||||
v3 = graph.addVertex("3"),
|
||||
result_array = [];
|
||||
|
||||
graph.addEdge(v1, v2, 8, 'a');
|
||||
|
@ -154,8 +154,8 @@ function neighborSuite() {
|
|||
|
||||
result_array = v1.getNeighbors({ direction: 'both', labels: ['a', 'c'] });
|
||||
|
||||
assertEqual(result_array.length, 1);
|
||||
assertEqual(result_array[0].id, 2);
|
||||
assertEqual(result_array.length, "1");
|
||||
assertEqual(result_array[0].id, "2");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ function GraphCreationSuite() {
|
|||
|
||||
graph = new Graph(graph_name, vertex, edge);
|
||||
|
||||
assertEqual(graph_name, graph._properties.name);
|
||||
assertEqual(graph_name, graph._properties._key);
|
||||
assertTrue(graph._vertices.type() == ArangoCollection.TYPE_DOCUMENT);
|
||||
assertTrue(graph._edges.type() == ArangoCollection.TYPE_EDGE);
|
||||
|
||||
|
@ -178,7 +178,6 @@ function GraphBasicsSuite() {
|
|||
|
||||
testCreateVertex : function () {
|
||||
var v = graph.addVertex("name1", { age : 23 });
|
||||
|
||||
assertEqual("name1", v.getId());
|
||||
assertEqual(23, v.getProperty("age"));
|
||||
},
|
||||
|
@ -227,7 +226,7 @@ function GraphBasicsSuite() {
|
|||
|
||||
edge = graph.addEdge(v1, v2);
|
||||
|
||||
assertEqual(null, edge.getId());
|
||||
assertEqual(edge._properties._key, edge.getId());
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -520,8 +519,8 @@ function EdgeSuite() {
|
|||
v2 = graph.addVertex();
|
||||
edge = graph.addEdge(v1, v2);
|
||||
|
||||
assertEqual(v1.getId(), edge.getInVertex().getId());
|
||||
assertEqual(v2.getId(), edge.getOutVertex().getId());
|
||||
assertEqual(v1.getId(), edge.getOutVertex().getId());
|
||||
assertEqual(v2.getId(), edge.getInVertex().getId());
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -28,14 +28,10 @@
|
|||
|
||||
#include "Utf8Helper.h"
|
||||
|
||||
#ifdef TRI_HAVE_ICU
|
||||
#include "unicode/normalizer2.h"
|
||||
#include "unicode/ucasemap.h"
|
||||
#include "unicode/brkiter.h"
|
||||
#include "unicode/ustdio.h"
|
||||
#else
|
||||
#include "string.h"
|
||||
#endif
|
||||
|
||||
#include "Logger/Logger.h"
|
||||
#include "BasicsC/strings.h"
|
||||
|
@ -71,7 +67,6 @@ Utf8Helper::~Utf8Helper () {
|
|||
}
|
||||
|
||||
int Utf8Helper::compareUtf8 (const char* left, const char* right) {
|
||||
#ifdef TRI_HAVE_ICU
|
||||
if (!_coll) {
|
||||
LOGGER_ERROR << "no Collator in Utf8Helper::compareUtf8()!";
|
||||
return (strcmp(left, right));
|
||||
|
@ -85,16 +80,11 @@ int Utf8Helper::compareUtf8 (const char* left, const char* right) {
|
|||
}
|
||||
|
||||
return result;
|
||||
#else
|
||||
return (strcmp(left, right));
|
||||
#endif
|
||||
}
|
||||
|
||||
int Utf8Helper::compareUtf16 (const uint16_t* left, size_t leftLength, const uint16_t* right, size_t rightLength) {
|
||||
#ifdef TRI_HAVE_ICU
|
||||
if (!_coll) {
|
||||
LOGGER_ERROR << "no Collator in Utf8Helper::compareUtf16()!";
|
||||
#endif
|
||||
|
||||
if (leftLength == rightLength) {
|
||||
return memcmp((const void*)left, (const void*)right, leftLength * 2);
|
||||
|
@ -110,16 +100,12 @@ int Utf8Helper::compareUtf16 (const uint16_t* left, size_t leftLength, const uin
|
|||
}
|
||||
|
||||
return result;
|
||||
#ifdef TRI_HAVE_ICU
|
||||
}
|
||||
|
||||
return _coll->compare((const UChar *)left, leftLength, (const UChar *)right, rightLength);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Utf8Helper::setCollatorLanguage (const string& lang) {
|
||||
#ifdef TRI_HAVE_ICU
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
if (_coll) {
|
||||
|
@ -169,11 +155,9 @@ void Utf8Helper::setCollatorLanguage (const string& lang) {
|
|||
}
|
||||
|
||||
_coll = coll;
|
||||
#endif
|
||||
}
|
||||
|
||||
string Utf8Helper::getCollatorLanguage () {
|
||||
#ifdef TRI_HAVE_ICU
|
||||
if (_coll) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
ULocDataLocaleType type = ULOC_VALID_LOCALE;
|
||||
|
@ -185,12 +169,10 @@ string Utf8Helper::getCollatorLanguage () {
|
|||
}
|
||||
return locale.getLanguage();
|
||||
}
|
||||
#endif
|
||||
return "";
|
||||
}
|
||||
|
||||
string Utf8Helper::getCollatorCountry () {
|
||||
#ifdef TRI_HAVE_ICU
|
||||
if (_coll) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
ULocDataLocaleType type = ULOC_VALID_LOCALE;
|
||||
|
@ -202,7 +184,6 @@ string Utf8Helper::getCollatorCountry () {
|
|||
}
|
||||
return locale.getCountry();
|
||||
}
|
||||
#endif
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -238,7 +219,6 @@ char* Utf8Helper::tolower (TRI_memory_zone_t* zone, const char *src, int32_t src
|
|||
return utf8_dest;
|
||||
}
|
||||
|
||||
#ifdef TRI_HAVE_ICU
|
||||
uint32_t options = U_FOLD_CASE_DEFAULT;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
@ -285,7 +265,6 @@ char* Utf8Helper::tolower (TRI_memory_zone_t* zone, const char *src, int32_t src
|
|||
return utf8_dest;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
utf8_dest = TRI_LowerAsciiStringZ(zone, src);
|
||||
if (utf8_dest != 0) {
|
||||
|
@ -326,7 +305,6 @@ char* Utf8Helper::toupper (TRI_memory_zone_t* zone, const char *src, int32_t src
|
|||
return utf8_dest;
|
||||
}
|
||||
|
||||
#ifdef TRI_HAVE_ICU
|
||||
uint32_t options = U_FOLD_CASE_DEFAULT;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
@ -373,7 +351,6 @@ char* Utf8Helper::toupper (TRI_memory_zone_t* zone, const char *src, int32_t src
|
|||
return utf8_dest;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
utf8_dest = TRI_UpperAsciiStringZ(zone, src);
|
||||
if (utf8_dest != NULL) {
|
||||
|
@ -405,8 +382,6 @@ TRI_vector_string_t* Utf8Helper::getWords (const char* const text,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef TRI_HAVE_ICU
|
||||
|
||||
size_t textUtf16Length = 0;
|
||||
UChar* textUtf16 = NULL;
|
||||
|
||||
|
@ -499,10 +474,6 @@ TRI_vector_string_t* Utf8Helper::getWords (const char* const text,
|
|||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, textUtf16);
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, tempUtf16);
|
||||
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
|
||||
if (words->_length == 0) {
|
||||
// no words found
|
||||
TRI_FreeVectorString(TRI_UNKNOWN_MEM_ZONE, words);
|
||||
|
|
|
@ -32,9 +32,8 @@
|
|||
#include "Basics/Common.h"
|
||||
#include "BasicsC/vector.h"
|
||||
|
||||
#ifdef TRI_HAVE_ICU
|
||||
#include "unicode/coll.h"
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class WriteLocker
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -160,11 +159,7 @@ namespace triagens {
|
|||
bool lowerCase);
|
||||
|
||||
private:
|
||||
#ifdef TRI_HAVE_ICU
|
||||
Collator* _coll;
|
||||
#else
|
||||
char* _coll;
|
||||
#endif
|
||||
};
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
|
||||
#include "utf8-helper.h"
|
||||
|
||||
#ifdef TRI_HAVE_ICU
|
||||
|
||||
#include "unicode/unorm2.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -219,8 +217,6 @@ char* TRI_normalize_utf16_to_NFC (TRI_memory_zone_t* zone,
|
|||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
||||
|
|
|
@ -31,9 +31,7 @@
|
|||
#include "BasicsC/common.h"
|
||||
#include "BasicsC/vector.h"
|
||||
|
||||
#ifdef TRI_HAVE_ICU
|
||||
#include "unicode/ustring.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -48,8 +46,6 @@ extern "C" {
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef TRI_HAVE_ICU
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief convert a utf-8 string to a uchar (utf-16)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -86,8 +82,6 @@ char * TRI_normalize_utf16_to_NFC (TRI_memory_zone_t* zone,
|
|||
size_t inLength,
|
||||
size_t* outLength);
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief compare two utf16 strings (implemented in Basic/Utf8Helper.cpp)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -6,11 +6,7 @@ dnl ----------------------------------------------------------------------------
|
|||
|
||||
AC_LANG(C)
|
||||
|
||||
AC_ARG_ENABLE(icu,
|
||||
AS_HELP_STRING([--enable-icu], [enable ICU support (default: yes)]),
|
||||
tr_ICU="$enableval",
|
||||
tr_ICU="yes"
|
||||
)
|
||||
|
||||
AC_ARG_WITH(icu-config,
|
||||
AS_HELP_STRING([--with-icu-config=FILE], [where the icu-config program is located]),
|
||||
|
|
Loading…
Reference in New Issue