orientdb4r 0.2.7 → 0.2.8

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.
@@ -40,6 +40,8 @@ class TestDocumentCrud < Test::Unit::TestCase
40
40
  end
41
41
  rid = @client.create_document({ '@class' => CLASS, 'prop1' => 1, 'prop2' => 'text' })
42
42
  doc = @client.get_document rid
43
+ assert_equal CLASS, doc.doc_class
44
+ assert_equal rid, doc.doc_rid
43
45
  assert_equal 0, doc.doc_version
44
46
 
45
47
  # no effect if an unknown class
@@ -51,6 +53,8 @@ class TestDocumentCrud < Test::Unit::TestCase
51
53
  assert_nil doc.doc_class
52
54
  assert_equal 11, doc['a']
53
55
  assert_equal 'text1', doc['b']
56
+ # or missing class
57
+ assert_nothing_thrown do @client.create_document({ 'a' => 1, 'b' => 'text' }); end
54
58
 
55
59
  # no mandatory property
56
60
  assert_raise Orientdb4r::DataError do @client.create_document({ '@class' => CLASS, 'prop1' => 1 }); end
@@ -84,6 +88,8 @@ class TestDocumentCrud < Test::Unit::TestCase
84
88
  # not existing RID
85
89
  rid1 = rid.sub(/[0-9]+$/, (rid.split(':')[1].to_i + 1).to_s) # '#6:0' > '#6:1' or '#6:11' > '#6:12'
86
90
  assert_raise Orientdb4r::NotFoundError do @client.get_document rid1; end
91
+ # bad RID format
92
+ assert_raise Orientdb4r::ServerError do @client.get_document('xx'); end
87
93
  end
88
94
 
89
95
  ###
@@ -129,8 +135,18 @@ class TestDocumentCrud < Test::Unit::TestCase
129
135
  assert_not_nil doc
130
136
 
131
137
  assert_nothing_thrown do @client.delete_document rid; end
132
- # already deleted
133
138
  assert_raise Orientdb4r::NotFoundError do @client.get_document rid; end
139
+
140
+ # already deleted
141
+ # v1.1.0 allows call of DELETE on already deleted record (bug?!)
142
+ if @client.compare_versions(@client.server_version, '1.1.0') < 0
143
+ assert_raise Orientdb4r::NotFoundError do @client.delete_document rid; end
144
+ end
145
+
146
+ # not existing RID
147
+ assert_raise Orientdb4r::NotFoundError do @client.delete_document '#4:1111'; end
148
+ # bad RID format
149
+ assert_raise Orientdb4r::ServerError do @client.delete_document 'xx'; end
134
150
  end
135
151
 
136
152
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orientdb4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-07 00:00:00.000000000 Z
12
+ date: 2012-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -41,18 +41,27 @@ files:
41
41
  - README.rdoc
42
42
  - Rakefile
43
43
  - changelog.txt
44
+ - fstudy/design_v1.dia
45
+ - fstudy/design_v1.png
46
+ - fstudy/domain_model.dia
47
+ - fstudy/domain_model.png
48
+ - fstudy/flat_class_perf.rb
49
+ - fstudy/sample1_object_diagram.dia
50
+ - fstudy/sample1_object_diagram.png
51
+ - fstudy/study_case.rb
52
+ - fstudy/technical_feasibility.rb
44
53
  - lib/orientdb4r.rb
45
54
  - lib/orientdb4r/chained_error.rb
46
55
  - lib/orientdb4r/client.rb
47
56
  - lib/orientdb4r/node.rb
48
57
  - lib/orientdb4r/rest/client.rb
58
+ - lib/orientdb4r/rest/excon_node.rb
49
59
  - lib/orientdb4r/rest/model.rb
50
60
  - lib/orientdb4r/rest/node.rb
51
61
  - lib/orientdb4r/rest/restclient_node.rb
52
62
  - lib/orientdb4r/utils.rb
53
63
  - lib/orientdb4r/version.rb
54
64
  - orientdb4r.gemspec
55
- - test/graphs.rb
56
65
  - test/readme_sample.rb
57
66
  - test/test_database.rb
58
67
  - test/test_ddo.rb
@@ -85,7 +94,6 @@ signing_key:
85
94
  specification_version: 3
86
95
  summary: Ruby binding for Orient DB.
87
96
  test_files:
88
- - test/graphs.rb
89
97
  - test/readme_sample.rb
90
98
  - test/test_database.rb
91
99
  - test/test_ddo.rb
data/test/graphs.rb DELETED
@@ -1,114 +0,0 @@
1
- require 'orientdb4r'
2
-
3
- DB = 'temp'
4
-
5
- c = Orientdb4r.client
6
- c.connect :database => DB, :user => 'admin', :password => 'admin'
7
- dg = Orientdb4r::Utils::DataGenerator.new
8
-
9
-
10
- def clear(conn)
11
- conn.drop_class 'Community'
12
- puts "droped class: Community"
13
- conn.drop_class 'OrgUnit'
14
- puts "droped class: OrgUnit"
15
- conn.drop_class 'User'
16
- puts "droped class: User"
17
- end
18
-
19
- if ARGV.include?('--clear')
20
- clear(c)
21
- end
22
-
23
- if ARGV.include?('--schema')
24
- clear(c)
25
- # OrgUnit
26
- c.create_class 'OrgUnit' do |c|
27
- c.property 'name', :string, :mandatory => true
28
- c.property 'network', :boolean
29
- c.link 'descendants', :linkset, 'OrgUnit'
30
- end
31
- puts "created class: OrgUnit"
32
- # Community
33
- c.create_class 'Community' do |c|
34
- c.property 'name', :string, :mandatory => true
35
- end
36
- puts "created class: Community"
37
- # User
38
- c.create_class 'User' do |c|
39
- c.property 'username', :string, :mandatory => true
40
- c.property 'name', :string, :mandatory => true
41
- c.link 'unit', :link, 'OrgUnit', :mandatory => true
42
- c.link 'communities', :linkset, 'Community'
43
- end
44
- puts "created class: User"
45
- end
46
-
47
- if ARGV.include?('--data')
48
-
49
- # Organisational Units
50
- c. command 'DELETE FROM OrgUnit'
51
- units = []
52
-
53
- comp_rids = []
54
- auto_rids = []
55
- auto_rids << c.create_document({ '@class' => 'OrgUnit', :name => 'Sales', :network => true })
56
- auto_rids << c.create_document({ '@class' => 'OrgUnit', :name => 'Marketing', :network => true })
57
- auto_rids << c.create_document({ '@class' => 'OrgUnit', :name => 'Design', :network => true })
58
- comp_rids << c.create_document({ '@class' => 'OrgUnit', :name => 'Automotive', :network => true, :descendants => auto_rids })
59
- #
60
- research_rids = []
61
- research_rids << c.create_document({ '@class' => 'OrgUnit', :name => 'Scientist', :network => false })
62
- research_rids << c.create_document({ '@class' => 'OrgUnit', :name => 'Spies', :network => false })
63
- comp_rids << c.create_document({ '@class' => 'OrgUnit', :name => 'Research', :network => false, :descendants => research_rids })
64
- #
65
- infra_rids = []
66
- recruit_rid = c.create_document({ '@class' => 'OrgUnit', :name => 'Recruitment', :network => false })
67
- infra_rids << c.create_document({ '@class' => 'OrgUnit', :name => 'Human Resources', :network => false, :descendants => [recruit_rid] })
68
- infra_rids << c.create_document({ '@class' => 'OrgUnit', :name => 'Accounting', :network => false })
69
- comp_rids << c.create_document({ '@class' => 'OrgUnit', :name => 'Company Infrastructure', :network => false, :descendants => infra_rids })
70
- #
71
- units << c.create_document({ '@class' => 'OrgUnit', :name => 'Big Company', :network => false, :descendants => comp_rids })
72
- units << auto_rids << research_rids << infra_rids << comp_rids
73
- units.flatten!.uniq!
74
- puts "created units: #{units}"
75
-
76
- # Communities
77
- c. command 'DELETE FROM Community'
78
- communities = []
79
- communities << c.create_document({ '@class' => 'Community', :name => 'Pianists' })
80
- communities << c.create_document({ '@class' => 'Community', :name => 'Violinists' })
81
- communities << c.create_document({ '@class' => 'Community', :name => 'Dog fanciers' })
82
- communities << c.create_document({ '@class' => 'Community', :name => 'Cat fanciers' })
83
- communities << c.create_document({ '@class' => 'Community', :name => 'Soccer fans' })
84
- communities << c.create_document({ '@class' => 'Community', :name => 'Ski fans' })
85
- communities << c.create_document({ '@class' => 'Community', :name => 'Basket fans' })
86
- communities << c.create_document({ '@class' => 'Community', :name => 'Gourmets' })
87
- communities << c.create_document({ '@class' => 'Community', :name => 'Scifi reader' })
88
- communities << c.create_document({ '@class' => 'Community', :name => 'Comic reader' })
89
- puts "created communities: #{communities}"
90
-
91
- # Users
92
- c. command 'DELETE FROM User'
93
- 1.upto(1000) do
94
- first_name = dg.word.capitalize
95
- surname = dg.word.capitalize
96
- # random distribution of Units (1) & Communities (0..3)
97
- unit = units[rand(units.size)]
98
- comms = []
99
- 0.upto(rand(4)) { |i| comms << communities[rand(communities.size)] if i > 0 }
100
-
101
- c.create_document({ '@class' => 'User', \
102
- :username => "#{first_name.downcase}.#{surname.downcase}", \
103
- :name => "#{first_name.capitalize} #{surname.capitalize}", \
104
- :unit => unit, \
105
- :communities => comms })
106
- end
107
-
108
- end
109
-
110
- # FIND REFERENCES #6:5 [OrgUnit] # get parent
111
-
112
- # TRAVERSE descendants FROM #6:10 WHERE $depth < 2 # get first level of descendants
113
- # SELECT FROM (TRAVERSE descendants FROM #6:10 WHERE $depth < 2) WHERE $depth > 0 # eliminate root of query
114
- # SELECT FROM orgunit WHERE any() traverse(0,10) (name = 'Recruitment') # get ancestors