diametric 0.1.1-java

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.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +28 -0
  3. data/Jarfile +20 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +264 -0
  6. data/Rakefile +49 -0
  7. data/bin/datomic-rest +33 -0
  8. data/bin/download-datomic +13 -0
  9. data/datomic_version.yml +4 -0
  10. data/diametric-java.gemspec +39 -0
  11. data/ext/diametric/DiametricCollection.java +147 -0
  12. data/ext/diametric/DiametricConnection.java +113 -0
  13. data/ext/diametric/DiametricDatabase.java +107 -0
  14. data/ext/diametric/DiametricEntity.java +90 -0
  15. data/ext/diametric/DiametricListenableFuture.java +47 -0
  16. data/ext/diametric/DiametricObject.java +66 -0
  17. data/ext/diametric/DiametricPeer.java +414 -0
  18. data/ext/diametric/DiametricService.java +102 -0
  19. data/ext/diametric/DiametricUUID.java +61 -0
  20. data/ext/diametric/DiametricUtils.java +183 -0
  21. data/lib/boolean_type.rb +3 -0
  22. data/lib/diametric.rb +42 -0
  23. data/lib/diametric/config.rb +54 -0
  24. data/lib/diametric/config/environment.rb +42 -0
  25. data/lib/diametric/entity.rb +659 -0
  26. data/lib/diametric/errors.rb +13 -0
  27. data/lib/diametric/generators/active_model.rb +42 -0
  28. data/lib/diametric/persistence.rb +48 -0
  29. data/lib/diametric/persistence/common.rb +82 -0
  30. data/lib/diametric/persistence/peer.rb +154 -0
  31. data/lib/diametric/persistence/rest.rb +107 -0
  32. data/lib/diametric/query.rb +259 -0
  33. data/lib/diametric/railtie.rb +52 -0
  34. data/lib/diametric/rest_service.rb +74 -0
  35. data/lib/diametric/service_base.rb +77 -0
  36. data/lib/diametric/transactor.rb +86 -0
  37. data/lib/diametric/version.rb +3 -0
  38. data/lib/diametric_service.jar +0 -0
  39. data/lib/tasks/create_schema.rb +27 -0
  40. data/lib/tasks/diametric_config.rb +45 -0
  41. data/lib/value_enums.rb +8 -0
  42. data/spec/conf_helper.rb +55 -0
  43. data/spec/config/free-transactor-template.properties +73 -0
  44. data/spec/config/logback.xml +59 -0
  45. data/spec/data/seattle-data0.dtm +452 -0
  46. data/spec/data/seattle-data1.dtm +326 -0
  47. data/spec/developer_create_sample.rb +39 -0
  48. data/spec/developer_query_spec.rb +120 -0
  49. data/spec/diametric/config_spec.rb +60 -0
  50. data/spec/diametric/entity_spec.rb +476 -0
  51. data/spec/diametric/peer_api_spec.rb +147 -0
  52. data/spec/diametric/persistence/peer_many2many_spec.rb +76 -0
  53. data/spec/diametric/persistence/peer_spec.rb +27 -0
  54. data/spec/diametric/persistence/rest_spec.rb +30 -0
  55. data/spec/diametric/persistence_spec.rb +59 -0
  56. data/spec/diametric/query_spec.rb +118 -0
  57. data/spec/diametric/rest_service_spec.rb +56 -0
  58. data/spec/diametric/transactor_spec.rb +68 -0
  59. data/spec/integration_spec.rb +107 -0
  60. data/spec/parent_child_sample.rb +42 -0
  61. data/spec/peer_integration_spec.rb +121 -0
  62. data/spec/peer_seattle_spec.rb +200 -0
  63. data/spec/rc2013_seattle_big.rb +82 -0
  64. data/spec/rc2013_seattle_small.rb +60 -0
  65. data/spec/rc2013_simple_sample.rb +72 -0
  66. data/spec/seattle_integration_spec.rb +106 -0
  67. data/spec/simple_validation_sample.rb +31 -0
  68. data/spec/spec_helper.rb +63 -0
  69. data/spec/support/entities.rb +157 -0
  70. data/spec/support/gen_entity_class.rb +9 -0
  71. data/spec/support/persistence_examples.rb +104 -0
  72. data/spec/test_version_file.yml +4 -0
  73. metadata +290 -0
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe Diametric::Config do
4
+ before do
5
+ Diametric::Config.configuration.clear
6
+ end
7
+
8
+ describe ".configuration" do
9
+ it "is empty by default" do
10
+ Diametric::Config.configuration.should have(0).options
11
+ end
12
+ end
13
+
14
+ describe ".configured?" do
15
+ it "is true if configuration is present" do
16
+ Diametric::Config.configuration[:uri] = 'datomic:free://sample'
17
+ Diametric::Config.should be_configured
18
+ end
19
+
20
+ it "is false if no configuration has been added" do
21
+ Diametric::Config.should_not be_configured
22
+ end
23
+ end
24
+
25
+ describe ".load_and_connect!" do
26
+ let(:path) { "/path/to/diametric.yml" }
27
+ let(:env) { :test }
28
+ let(:settings) { {'uri' => 'diametric:free://test'} }
29
+
30
+ it "loads settings from the environment" do
31
+ Diametric::Config::Environment.should_receive(:load_yaml).with(path, env).and_return(settings)
32
+ Diametric::Config.stub(:connect!)
33
+
34
+ Diametric::Config.load_and_connect!(path, env)
35
+ end
36
+
37
+ it "sets the configuration" do
38
+ Diametric::Config::Environment.stub(:load_yaml => settings)
39
+ Diametric::Config.stub(:connect!)
40
+ Diametric::Config.load_and_connect!(path, env)
41
+
42
+ Diametric::Config.configuration.should == settings
43
+ end
44
+
45
+ it "connects" do
46
+ Diametric::Config::Environment.stub(:load_yaml => settings)
47
+ Diametric::Config.should_receive(:connect!).with(settings)
48
+
49
+ Diametric::Config.load_and_connect!(path, env)
50
+ end
51
+ end
52
+
53
+ describe ".connect!" do
54
+ it "establishes a base connection" do
55
+ settings = double
56
+ Diametric::Persistence.should_receive(:establish_base_connection).with(settings)
57
+ Diametric::Config.connect!(settings)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,476 @@
1
+ require 'spec_helper'
2
+ require 'diametric/entity'
3
+
4
+ require 'rspec/expectations'
5
+
6
+ RSpec::Matchers.define :be_an_equivalent_hash do |expected|
7
+ match do |actual|
8
+ status = true
9
+ expected.each do |k, v|
10
+ next if k == ":db/id"
11
+ status = false if actual[k].nil?
12
+ status = false unless actual[k] == v
13
+ end
14
+ status
15
+ end
16
+ end
17
+
18
+ RSpec::Matchers.define :be_an_equivalent_array do |expected|
19
+ match do |actual|
20
+ status = true
21
+ expected.each_with_index do |e, index|
22
+ next if e == "#db/id[:db.part/user]"
23
+ status = false unless actual[index] == e
24
+ end
25
+ status
26
+ end
27
+ end
28
+
29
+ describe Diametric::Entity do
30
+ describe "in a class" do
31
+ subject { Person }
32
+
33
+ it { should respond_to(:attribute) }
34
+ it { should respond_to(:schema) }
35
+ it { should respond_to(:from_query) }
36
+
37
+ it "should generate a schema" do
38
+ expected = [
39
+ { :"db/id" => Person.send(:tempid, :"db.part/db"),
40
+ :"db/ident" => :"person/name",
41
+ :"db/valueType" => :"db.type/string",
42
+ :"db/cardinality" => :"db.cardinality/one",
43
+ :"db/index" => true,
44
+ :"db.install/_attribute" => :"db.part/db" },
45
+ { :"db/id" => Person.send(:tempid, :"db.part/db"),
46
+ :"db/ident" => :"person/email",
47
+ :"db/valueType" => :"db.type/string",
48
+ :"db/cardinality" => :"db.cardinality/many",
49
+ :"db.install/_attribute" => :"db.part/db" },
50
+ { :"db/id" => Person.send(:tempid, :"db.part/db"),
51
+ :"db/ident" => :"person/birthday",
52
+ :"db/valueType" => :"db.type/instant",
53
+ :"db/cardinality" => :"db.cardinality/one",
54
+ :"db.install/_attribute" => :"db.part/db" },
55
+ { :"db/id" => Person.send(:tempid, :"db.part/db"),
56
+ :"db/ident" => :"person/awesome",
57
+ :"db/valueType" => :"db.type/boolean",
58
+ :"db/cardinality" => :"db.cardinality/one",
59
+ :"db/doc" => "Is this person awesome?",
60
+ :"db.install/_attribute" => :"db.part/db" },
61
+ { :"db/id" => Person.send(:tempid, :"db.part/db"),
62
+ :"db/ident" => :"person/ssn",
63
+ :"db/valueType" => :"db.type/string",
64
+ :"db/cardinality" => :"db.cardinality/one",
65
+ :"db/unique" => :"db.unique/value",
66
+ :"db.install/_attribute" => :"db.part/db" },
67
+ { :"db/id" => Person.send(:tempid, :"db.part/db"),
68
+ :"db/ident" => :"person/secret_name",
69
+ :"db/valueType" => :"db.type/string",
70
+ :"db/cardinality" => :"db.cardinality/one",
71
+ :"db/unique" => :"db.unique/identity",
72
+ :"db.install/_attribute" => :"db.part/db" },
73
+ { :"db/id" => Person.send(:tempid, :"db.part/db"),
74
+ :"db/ident" => :"person/bio",
75
+ :"db/valueType" => :"db.type/string",
76
+ :"db/cardinality" => :"db.cardinality/one",
77
+ :"db/fulltext" => true,
78
+ :"db.install/_attribute" => :"db.part/db" },
79
+ { :"db/id" => Person.send(:tempid, :"db.part/db"),
80
+ :"db/ident" => :"person/middle_name",
81
+ :"db/valueType" => :"db.type/string",
82
+ :"db/cardinality" => :"db.cardinality/one",
83
+ :"db.install/_attribute" => :"db.part/db" },
84
+ { :"db/id" => Person.send(:tempid, :"db.part/db"),
85
+ :"db/ident" => :"person/nicknames",
86
+ :"db/valueType" => :"db.type/string",
87
+ :"db/cardinality" => :"db.cardinality/many",
88
+ :"db.install/_attribute" => :"db.part/db" },
89
+ { :"db/id" => Person.send(:tempid, :"db.part/db"),
90
+ :"db/ident" => :"person/parent",
91
+ :"db/valueType" => :"db.type/ref",
92
+ :"db/cardinality" => :"db.cardinality/many",
93
+ :"db/doc" => "A person's parent",
94
+ :"db.install/_attribute" => :"db.part/db" }
95
+ ]
96
+ Person.schema.each do |s|
97
+ s.should == expected.shift
98
+ end
99
+ end
100
+ end
101
+
102
+ describe "in an instance" do
103
+ subject { Person.new }
104
+ let(:model) { Person.new }
105
+
106
+ it_should_behave_like "ActiveModel"
107
+
108
+ it { should respond_to(:tx_data) }
109
+
110
+ it "should handle attributes correctly" do
111
+ subject.name.should be_nil
112
+ subject.name = "Clinton"
113
+ subject.name.should == "Clinton"
114
+ end
115
+
116
+ it "should return attribute names" do
117
+ subject.attribute_names.should eql(Person.attribute_names)
118
+ end
119
+
120
+ it "should return a hash of attributes" do
121
+ attributes = subject.attributes
122
+
123
+ attributes.should be_a Hash
124
+ attributes.keys.should eql(subject.attribute_names)
125
+ attributes[:middle_name].should eql("Danger")
126
+ end
127
+
128
+ it "should raise a validation error" do
129
+ expect { Robin.new.save! }.to raise_error(Diametric::Errors::ValidationError)
130
+ end
131
+
132
+ end
133
+
134
+ describe ".new" do
135
+ it "should work without arguments" do
136
+ Person.new.should be_a(Person)
137
+ end
138
+
139
+ it "should assign attributes based off argument keys" do
140
+ person = Person.new(:name => "Dashiell D", :secret_name => "Monito")
141
+ person.name.should == "Dashiell D"
142
+ person.secret_name.should == "Monito"
143
+ end
144
+
145
+ it "should defaults attributes" do
146
+ Person.new.middle_name.should == "Danger"
147
+ end
148
+
149
+ it "should transform default arrays into sets" do
150
+ Person.new.nicknames.should == Set.new(["Buddy", "Pal"])
151
+ end
152
+ end
153
+
154
+ describe ".from_query" do
155
+ it "should assign dbid and attributes" do
156
+ goat = Goat.from_query([1, "Beans", DateTime.parse("1976/9/4")])
157
+ goat.dbid.should == 1
158
+ goat.name.should == "Beans"
159
+ goat.birthday.should == DateTime.parse("1976/9/4")
160
+ end
161
+ end
162
+
163
+ describe "#tx_data" do
164
+ context "for an entity with cardinality/many attributes" do
165
+
166
+ let(:entity_class) do
167
+ gen_entity_class(named = "test") do
168
+ attribute :many, String, :cardinality => :many
169
+ end
170
+ end
171
+
172
+ describe "with a dbid" do
173
+ it "should generate a protraction tx for added entries" do
174
+ entity = entity_class.new(:many => %w|foo bar|)
175
+ entity.many.should == Set["foo", "bar"]
176
+ entity.dbid = 1
177
+ entity.tx_data.should == [[:"db/add", 1, :"test/many", ["foo", "bar"]]]
178
+ end
179
+
180
+ it "should generate a retraction tx for removed entries" do
181
+ entity = entity_class.new
182
+ entity.dbid = 1
183
+ entity.instance_variable_set(:"@changed_attributes", { 'many' => Set["original", "unchanged"]})
184
+ entity.many = Set["unchanged", "new"]
185
+ entity.tx_data.should == [
186
+ [:"db/retract", 1, :"test/many", ["original"]],
187
+ [:"db/add", 1, :"test/many", ["new"]]
188
+ ]
189
+ end
190
+ end
191
+
192
+ describe "without a db/id" do
193
+ it "should generate a protraction tx" do
194
+ entity = entity_class.new(:many => %w|foo bar|)
195
+ tx = entity.tx_data.first
196
+ tx.should =~ [:"db/add", entity.send(:tempid), :"test/many", ['foo', 'bar']]
197
+ end
198
+ end
199
+ end
200
+
201
+ context "for an entity with only cardinality/one attributes" do
202
+ let(:goat) { Goat.new(:name => "Beans", :birthday => Date.parse("2002-04-15"))}
203
+
204
+ describe "without a dbid" do
205
+ it "should generate a transaction with a new tempid" do
206
+ # Equivalence is currently wrong on EDN tagged values.
207
+ tx = goat.tx_data.first
208
+ tx.keys.should =~ [:"db/id", :"goat/name", :"goat/birthday"]
209
+ tx[:"db/id"].to_edn.should match(%r"#db/id \[:db.part/user \-\d+\]")
210
+ tx[:"goat/name"].should == "Beans"
211
+ tx[:"goat/birthday"].should == goat.birthday
212
+ end
213
+ end
214
+
215
+ describe "with a dbid" do
216
+ it "should generate a transaction with the dbid" do
217
+ goat.dbid = 1
218
+ goat.tx_data.should == [
219
+ { :"db/id" => 1,
220
+ :"goat/name" => "Beans",
221
+ :"goat/birthday" => goat.birthday
222
+ }
223
+ ]
224
+ end
225
+
226
+ it "should generate a transaction with only specified attributes" do
227
+ goat.dbid = 1
228
+ goat.tx_data(:name).should == [
229
+ { :"db/id" => 1,
230
+ :"goat/name" => "Beans"
231
+ }
232
+ ]
233
+ end
234
+ end
235
+
236
+ end
237
+
238
+ end
239
+
240
+ context "boolean type" do
241
+ subject { Choice }
242
+
243
+ it "should generate a schema" do
244
+ expected = []
245
+ if is_jruby?
246
+ expected = [
247
+ { ":db/id" => subject.send(:tempid, ":db.part/db"),
248
+ ":db/ident" => ":choice/item",
249
+ ":db/valueType" => ":db.type/string",
250
+ ":db/cardinality" => ":db.cardinality/one",
251
+ ":db.install/_attribute" => ":db.part/db" },
252
+ { ":db/id" => subject.send(:tempid, ":db.part/db"),
253
+ ":db/ident" => ":choice/checked",
254
+ ":db/valueType" => ":db.type/boolean",
255
+ ":db/cardinality" => ":db.cardinality/one",
256
+ ":db.install/_attribute" => ":db.part/db" }
257
+ ]
258
+ else
259
+ expected = [
260
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
261
+ :"db/ident" => :"choice/item",
262
+ :"db/valueType" => :"db.type/string",
263
+ :"db/cardinality" => :"db.cardinality/one",
264
+ :"db.install/_attribute" => :"db.part/db" },
265
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
266
+ :"db/ident" => :"choice/checked",
267
+ :"db/valueType" => :"db.type/boolean",
268
+ :"db/cardinality" => :"db.cardinality/one",
269
+ :"db.install/_attribute" => :"db.part/db" }
270
+ ]
271
+ end
272
+ @created_schema = subject.schema
273
+ expected.each do |e|
274
+ @created_schema.shift.should be_an_equivalent_hash(e)
275
+ end
276
+ end
277
+ end
278
+
279
+ context "uuid type" do
280
+ subject { Customer }
281
+
282
+ it "should generate a schema" do
283
+ expected = []
284
+ if is_jruby?
285
+ expected = [
286
+ { ":db/id" => subject.send(:tempid, ":db.part/db"),
287
+ ":db/ident" => ":customer/name",
288
+ ":db/valueType" => ":db.type/string",
289
+ ":db/cardinality" => ":db.cardinality/one",
290
+ ":db.install/_attribute" => ":db.part/db" },
291
+ { ":db/id" => subject.send(:tempid, ":db.part/db"),
292
+ ":db/ident" => ":customer/id",
293
+ ":db/valueType" => ":db.type/uuid",
294
+ ":db/cardinality" => ":db.cardinality/one",
295
+ ":db.install/_attribute" => ":db.part/db" }
296
+ ]
297
+ else
298
+ expected = [
299
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
300
+ :"db/ident" => :"customer/name",
301
+ :"db/valueType" => :"db.type/string",
302
+ :"db/cardinality" => :"db.cardinality/one",
303
+ :"db.install/_attribute" => :"db.part/db" },
304
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
305
+ :"db/ident" => :"customer/id",
306
+ :"db/valueType" => :"db.type/uuid",
307
+ :"db/cardinality" => :"db.cardinality/one",
308
+ :"db.install/_attribute" => :"db.part/db" }
309
+ ]
310
+ end
311
+ @created_schema = subject.schema
312
+ expected.each do |e|
313
+ @created_schema.shift.should be_an_equivalent_hash(e)
314
+ end
315
+ end
316
+ end
317
+
318
+ context "Float, Double type" do
319
+ subject { Account }
320
+
321
+ it "should generate a schema" do
322
+ expected = []
323
+ if is_jruby?
324
+ expected = [
325
+ { ":db/id" => subject.send(:tempid, ":db.part/db"),
326
+ ":db/ident" => ":account/name",
327
+ ":db/valueType" => ":db.type/string",
328
+ ":db/cardinality" => ":db.cardinality/one",
329
+ ":db.install/_attribute" => ":db.part/db" },
330
+ { ":db/id" => subject.send(:tempid, ":db.part/db"),
331
+ ":db/ident" => ":account/deposit",
332
+ ":db/valueType" => ":db.type/double",
333
+ ":db/cardinality" => ":db.cardinality/many",
334
+ ":db.install/_attribute" => ":db.part/db" },
335
+ { ":db/id" => subject.send(:tempid, ":db.part/db"),
336
+ ":db/ident" => ":account/amount",
337
+ ":db/valueType" => ":db.type/double",
338
+ ":db/cardinality" => ":db.cardinality/one",
339
+ ":db.install/_attribute" => ":db.part/db" }
340
+ ]
341
+ else
342
+ expected = [
343
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
344
+ :"db/ident" => :"account/name",
345
+ :"db/valueType" => :"db.type/string",
346
+ :"db/cardinality" => :"db.cardinality/one",
347
+ :"db.install/_attribute" => :"db.part/db" },
348
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
349
+ :"db/ident" => :"account/deposit",
350
+ :"db/valueType" => :"db.type/double",
351
+ :"db/cardinality" => :"db.cardinality/many",
352
+ :"db.install/_attribute" => :"db.part/db" },
353
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
354
+ :"db/ident" => :"account/amount",
355
+ :"db/valueType" => :"db.type/double",
356
+ :"db/cardinality" => :"db.cardinality/one",
357
+ :"db.install/_attribute" => :"db.part/db" }
358
+ ]
359
+ end
360
+ @created_schema = subject.schema
361
+ expected.each do |e|
362
+ @created_schema.shift.should be_an_equivalent_hash(e)
363
+ end
364
+ end
365
+ end
366
+
367
+ context "community sample" do
368
+ subject { Organization }
369
+
370
+ it { should respond_to(:attribute) }
371
+ it { should respond_to(:enum) }
372
+ it { should respond_to(:schema) }
373
+
374
+ it "should generate a schema" do
375
+ expected = [
376
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
377
+ :"db/ident" => :"organization/name",
378
+ :"db/valueType" => :"db.type/string",
379
+ :"db/cardinality" => :"db.cardinality/one",
380
+ :"db/fulltext" => true,
381
+ :"db/doc" => "A organization's name",
382
+ :"db.install/_attribute" => :"db.part/db" },
383
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
384
+ :"db/ident" => :"organization/url",
385
+ :"db/valueType" => :"db.type/string",
386
+ :"db/cardinality" => :"db.cardinality/one",
387
+ :"db/doc" => "A organization's url",
388
+ :"db.install/_attribute" => :"db.part/db" },
389
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
390
+ :"db/ident" => :"organization/neighborhood",
391
+ :"db/valueType" => :"db.type/ref",
392
+ :"db/cardinality" => :"db.cardinality/one",
393
+ :"db/doc" => "A organization's neighborhood",
394
+ :"db.install/_attribute" => :"db.part/db" },
395
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
396
+ :"db/ident" => :"organization/category",
397
+ :"db/valueType" => :"db.type/string",
398
+ :"db/cardinality" => :"db.cardinality/many",
399
+ :"db/fulltext" => true,
400
+ :"db/doc" => "All organization categories",
401
+ :"db.install/_attribute" => :"db.part/db" },
402
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
403
+ :"db/ident" => :"organization/orgtype",
404
+ :"db/valueType" => :"db.type/ref",
405
+ :"db/cardinality" => :"db.cardinality/one",
406
+ :"db/doc" => "A organization orgtype enum value",
407
+ :"db.install/_attribute" => :"db.part/db" },
408
+ { :"db/id" => subject.send(:tempid, :"db.part/db"),
409
+ :"db/ident" => :"organization/type",
410
+ :"db/valueType" => :"db.type/ref",
411
+ :"db/cardinality" => :"db.cardinality/one",
412
+ :"db/doc" => "A organization type enum value",
413
+ :"db.install/_attribute" => :"db.part/db" },
414
+ [ :"db/add", subject.send(:tempid, :"db.part/user"), :"db/ident", :"organization.orgtype/community" ],
415
+ [ :"db/add", subject.send(:tempid, :"db.part/user"), :"db/ident", :"organization.orgtype/commercial" ],
416
+ [ :"db/add", subject.send(:tempid, :"db.part/user"), :"db/ident", :"organization.orgtype/nonprofit"],
417
+ [ :"db/add", subject.send(:tempid, :"db.part/user"), :"db/ident", :"organization.orgtype/personal"],
418
+ [ :"db/add", subject.send(:tempid, :"db.part/user"), :"db/ident", :"organization.type/email-list"],
419
+ [ :"db/add", subject.send(:tempid, :"db.part/user"), :"db/ident", :"organization.type/twitter"],
420
+ [ :"db/add", subject.send(:tempid, :"db.part/user"), :"db/ident", :"organization.type/facebook-page" ],
421
+ [ :"db/add", subject.send(:tempid, :"db.part/user"), :"db/ident", :"organization.type/blog" ],
422
+ [ :"db/add", subject.send(:tempid, :"db.part/user"), :"db/ident", :"organization.type/website" ],
423
+ [ :"db/add", subject.send(:tempid, :"db.part/user"), :"db/ident", :"organization.type/wiki" ],
424
+ [ :"db/add", subject.send(:tempid, :"db.part/user"), :"db/ident", :"organization.type/myspace" ],
425
+ [ :"db/add", subject.send(:tempid, :"db.part/user"), :"db/ident", :"organization.type/ning"]
426
+ ]
427
+
428
+ @created_schema = Organization.schema
429
+ expected.each do |e|
430
+ @created_schema.shift.should == e
431
+ end
432
+ end
433
+ end
434
+
435
+
436
+ context "seattle sample", :jruby do
437
+ describe Diametric::Entity do
438
+ subject { District }
439
+
440
+ it "should create peer schema" do
441
+ expected = [
442
+ { ":db/id" => subject.send(:tempid, ":db.part/db"),
443
+ ":db/ident" => ":district/name",
444
+ ":db/valueType" => ":db.type/string",
445
+ ":db/cardinality" => ":db.cardinality/one",
446
+ ":db/unique" => ":db.unique/identity",
447
+ ":db/doc" => "A unique district name (upsertable)",
448
+ ":db.install/_attribute" => ":db.part/db" },
449
+ { ":db/id" => subject.send(:tempid, ":db.part/db"),
450
+ ":db/ident" => ":district/region",
451
+ ":db/valueType" => ":db.type/ref",
452
+ ":db/cardinality" => ":db.cardinality/one",
453
+ ":db/doc" => "A district region enum value",
454
+ ":db.install/_attribute" => ":db.part/db" },
455
+ [ ":db/add", "#db/id[:db.part/user]", ":db/ident", ":district.region/n"],
456
+ [ ":db/add", "#db/id[:db.part/user]", ":db/ident", ":district.region/ne"],
457
+ [ ":db/add", "#db/id[:db.part/user]", ":db/ident", ":district.region/e"],
458
+ [ ":db/add", "#db/id[:db.part/user]", ":db/ident", ":district.region/se"],
459
+ [ ":db/add", "#db/id[:db.part/user]", ":db/ident", ":district.region/s"],
460
+ [ ":db/add", "#db/id[:db.part/user]", ":db/ident", ":district.region/sw"],
461
+ [ ":db/add", "#db/id[:db.part/user]", ":db/ident", ":district.region/w"],
462
+ [ ":db/add", "#db/id[:db.part/user]", ":db/ident", ":district.region/nw"]
463
+ ]
464
+ @created_schema = District.schema
465
+ expected.each do |e|
466
+ if e.is_a? Hash
467
+ @created_schema.shift.should be_an_equivalent_hash(e)
468
+ else
469
+ @created_schema.shift.should be_an_equivalent_array(e)
470
+ end
471
+ end
472
+ end
473
+ end
474
+ end
475
+
476
+ end