-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e0087d
commit 74204e8
Showing
9 changed files
with
196 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Neography | ||
class NodeTraverser | ||
include Enumerable | ||
|
||
attr_accessor :order, :uniqueness, :depth, :prune, :filter | ||
|
||
def initialize(from, types = nil, dir=nil) | ||
@from = from | ||
@depth = 1 | ||
@order = "depth first" | ||
@uniqueness = "none" | ||
if types.nil? || dir.nil? | ||
# @td = org.neo4j.kernel.impl.traversal.TraversalDescriptionImpl.new.breadth_first() | ||
else | ||
# @types = type_to_java(type) | ||
# @dir = dir_to_java(dir) | ||
# @td = org.neo4j.kernel.impl.traversal.TraversalDescriptionImpl.new.breadth_first().relationships(@type, @dir) | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,71 @@ | ||
require File.join(File.dirname(__FILE__), '..', 'spec_helper') | ||
|
||
describe Neography::Relationship do | ||
it "#new(:family, p1, p2) creates a new relationship between to nodes of given type" do | ||
p1 = Neography::Node.create | ||
p2 = Neography::Node.create | ||
|
||
new_rel = Neography::Relationship.create(:family, p1, p2) | ||
puts new_rel.inspect | ||
new_rel.start_node.should == p1 | ||
new_rel.end_node.should == p2 | ||
# p1.outgoing(:family).should include(p2) | ||
# p2.incoming(:family).should include(p1) | ||
end | ||
describe "create relationship" do | ||
it "#new(:family, p1, p2) creates a new relationship between to nodes of given type" do | ||
p1 = Neography::Node.create | ||
p2 = Neography::Node.create | ||
|
||
new_rel = Neography::Relationship.create(:family, p1, p2) | ||
puts new_rel.inspect | ||
new_rel.start_node.should == p1 | ||
new_rel.end_node.should == p2 | ||
|
||
|
||
# p1.outgoing(:family).should include(p2) | ||
# p2.incoming(:family).should include(p1) | ||
end | ||
|
||
it "#new(:family, p1, p2, :since => '1998', :colour => 'blue') creates relationship and sets its properties" do | ||
p1 = Neography::Node.create | ||
p2 = Neography::Node.create | ||
it "#new(:family, p1, p2, :since => '1998', :colour => 'blue') creates relationship and sets its properties" do | ||
p1 = Neography::Node.create | ||
p2 = Neography::Node.create | ||
|
||
rel = Neography::Relationship.create(:family, p1, p2, :since => 1998, :colour => 'blue') | ||
rel[:since].should == 1998 | ||
rel[:colour].should == 'blue' | ||
rel.since.should == 1998 | ||
rel.colourshould == 'blue' | ||
end | ||
|
||
rel = Neography::Relationship.create(:family, p1, p2, :since => 1998, :colour => 'blue') | ||
rel[:since].should == 1998 | ||
rel[:colour].should == 'blue' | ||
rel.since.should == 1998 | ||
rel.colourshould == 'blue' | ||
it "#outgoing(:friends).create(other) creates a new relationship between self and other node" do | ||
p1 = Neography::Node.create | ||
p2 = Neography::Node.create | ||
|
||
rel = p1.outgoing(:foo).create(p2) | ||
p1.outgoing(:foo).first.should == p2 | ||
rel.should be_kind_of(Neography::Relationship) | ||
end | ||
end | ||
|
||
it "#outgoing(:friends).new(other) creates a new relationship between self and other node" do | ||
p1 = Neography::Node.create | ||
p2 = Neography::Node.create | ||
describe "rel?" do | ||
it "#rel? returns true if there are any relationships" do | ||
n1 = Neography::Node.create | ||
n2 = Neography::Node.create | ||
new_rel = Neography::Relationship.create(:foo, n1, n2) | ||
n1.rel?.should be_true | ||
n1.rel?(:bar).should be_false | ||
n1.rel?(:foo).should be_true | ||
n1.rel?(:incoming, :foo).should be_false | ||
n1.rel?(:outgoing, :foo).should be_true | ||
n1.rel?(:foo, :incoming).should be_false | ||
n1.rel?(:foo, :outgoing).should be_true | ||
|
||
rel = p1.outgoing(:foo).create(p2) | ||
p1.outgoing(:foo).first.should == p2 | ||
rel.should be_kind_of(Neography::Relationship) | ||
n1.rel?(:incoming).should be_false | ||
n1.rel?(:outgoing).should be_true | ||
n1.rel?(:both).should be_true | ||
n1.rel?(:all).should be_true | ||
n1.rel?.should be_true | ||
end | ||
end | ||
|
||
|
||
describe "delete relationship" do | ||
it "can delete an existing relationship" do | ||
p1 = Neography::Node.create | ||
p2 = Neography::Node.create | ||
new_rel = Neography::Relationship.create(:family, p1, p2) | ||
new_rel.del | ||
Neography::Relationship.load(new_rel).should be_nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require File.join(File.dirname(__FILE__), '..', 'spec_helper') | ||
|
||
describe Neography::Rest do | ||
before(:each) do | ||
@neo = Neography::Rest.new | ||
end | ||
|
||
|
||
describe "get_nodes" do | ||
it "can get nodes that exists" do | ||
existing_nodes = @neo.get_nodes | ||
existing_nodes.should_not be_nil | ||
puts existing_nodes.inspect | ||
end | ||
|
||
it "can get all nodes that exists the ugly way" do | ||
new_node = @neo.create_node | ||
last_node_id = new_node["self"].split('/').last.to_i | ||
existing_nodes = @neo.get_nodes((1..last_node_id).to_a) | ||
existing_nodes.should_not be_nil | ||
end | ||
end | ||
end |