rtm 0.2.0 → 0.2.1

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 (88) hide show
  1. data/README +38 -3
  2. data/lib/rtm.rb +25 -47
  3. data/lib/rtm/axes.rb +7 -4
  4. data/lib/rtm/axes/association.rb +1 -1
  5. data/lib/rtm/axes/associations.rb +1 -1
  6. data/lib/rtm/axes/characteristic.rb +1 -1
  7. data/lib/rtm/axes/characteristics.rb +1 -1
  8. data/lib/rtm/axes/topic.rb +3 -3
  9. data/lib/rtm/axes/topics.rb +3 -3
  10. data/lib/rtm/engine.rb +48 -5
  11. data/lib/rtm/extensions.rb +58 -8
  12. data/lib/rtm/io.rb +2 -1
  13. data/lib/rtm/io/tmapix_from.rb +155 -0
  14. data/lib/rtm/io/tmapix_to.rb +223 -0
  15. data/lib/rtm/io/to_hash.rb +79 -41
  16. data/lib/rtm/io/to_jtm.rb +1 -1
  17. data/lib/rtm/io/to_rdf.rb +20 -5
  18. data/lib/rtm/io/to_string.rb +13 -2
  19. data/lib/rtm/io/to_yaml.rb +39 -11
  20. data/lib/rtm/navigation.rb +1 -15
  21. data/lib/rtm/navigation/association/players.rb +1 -1
  22. data/lib/rtm/navigation/name/characteristics.rb +1 -1
  23. data/lib/rtm/navigation/occurrence/characteristics.rb +1 -1
  24. data/lib/rtm/navigation/topic/characteristics.rb +1 -1
  25. data/lib/rtm/navigation/topic/players.rb +1 -1
  26. data/lib/rtm/navigation/topic/supertypes.rb +21 -17
  27. data/lib/rtm/navigation/topic/traverse.rb +1 -1
  28. data/lib/rtm/navigation/topic/types.rb +6 -4
  29. data/lib/rtm/psi.rb +6 -0
  30. data/lib/rtm/sugar.rb +42 -29
  31. data/lib/rtm/sugar/association/hash_access.rb +3 -3
  32. data/lib/rtm/sugar/occurrence/dynamic_value.rb +39 -56
  33. data/lib/rtm/sugar/occurrence/external.rb +53 -0
  34. data/lib/rtm/sugar/reifiable/reifier.rb +21 -0
  35. data/lib/rtm/sugar/role/counterparts.rb +12 -6
  36. data/lib/rtm/sugar/topic/best_name.rb +74 -0
  37. data/lib/rtm/sugar/topic/characteristics.rb +10 -10
  38. data/lib/rtm/sugar/topic/counterparts.rb +131 -119
  39. data/lib/rtm/sugar/topic/scoped.rb +102 -53
  40. data/lib/rtm/sugar/topic/topic_ref.rb +63 -12
  41. data/lib/rtm/sugar/topic/typed.rb +50 -2
  42. data/lib/rtm/sugar/topic_map/query_cache.rb +66 -0
  43. data/lib/rtm/sugar/topic_map/themes.rb +53 -0
  44. data/lib/rtm/sugar/typed/types.rb +1 -1
  45. data/lib/rtm/validation.rb +2 -2
  46. data/lib/rtm/version.rb +18 -6
  47. data/spec/rtm/axes/string_spec.rb +7 -7
  48. data/spec/rtm/axes/strings_spec.rb +10 -10
  49. data/spec/rtm/io/tmapix_from_spec.rb +76 -0
  50. data/spec/rtm/io/tmapix_to_spec.rb +159 -0
  51. data/spec/rtm/io/to_hash_spec.rb +90 -0
  52. data/spec/rtm/io/to_rdf_spec.rb +37 -0
  53. data/spec/rtm/io/to_string_spec.rb +122 -0
  54. data/spec/rtm/io/to_yaml_spec.rb +89 -0
  55. data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +156 -1
  56. data/spec/rtm/sugar/occurrence/external_spec.rb +129 -0
  57. data/spec/rtm/sugar/reifiable/reifier_spec.rb +41 -0
  58. data/spec/rtm/sugar/role/counterparts_spec.rb +174 -172
  59. data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
  60. data/spec/rtm/sugar/topic/characteristics_spec.rb +20 -5
  61. data/spec/rtm/sugar/topic/counterparts_spec.rb +41 -1
  62. data/spec/rtm/sugar/topic/hash_access_spec.rb +1 -1
  63. data/spec/rtm/sugar/topic/scoped_spec.rb +178 -114
  64. data/spec/rtm/sugar/topic/topic_ref_spec.rb +10 -10
  65. data/spec/rtm/sugar/topic/typed_spec.rb +196 -134
  66. data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
  67. data/spec/rtm/sugar/typed/types_spec.rb +1 -1
  68. data/spec/rtm/tmapi/core/association_spec.rb +2 -2
  69. data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
  70. data/spec/rtm/tmapi/core/name_spec.rb +186 -1
  71. data/spec/rtm/tmapi/core/occurrence_spec.rb +24 -67
  72. data/spec/rtm/tmapi/core/reifiable_spec.rb +2 -2
  73. data/spec/rtm/tmapi/core/scoped_spec.rb +40 -2
  74. data/spec/rtm/tmapi/core/topic_map_spec.rb +98 -30
  75. data/spec/rtm/tmapi/core/topic_spec.rb +558 -82
  76. data/spec/rtm/tmapi/core/variant_spec.rb +3 -3
  77. data/spec/rtm_spec.rb +0 -1
  78. data/spec/spec_helper.rb +7 -2
  79. data/test/javalibs/junit-4.5.jar +0 -0
  80. data/test/javalibs/tmapi-2.0-tests.jar +0 -0
  81. data/test/tmapi_tests.rb +25 -0
  82. metadata +66 -11
  83. data/lib/rtm/io/ontopia_io.rb +0 -25
  84. data/lib/rtm/io/tmapix.rb +0 -234
  85. data/lib/rtm/sugar/occurrence/externalize.rb +0 -31
  86. data/spec/rtm/io/tmapix_spec.rb +0 -85
  87. data/test/base_unit_test.rb +0 -161
  88. data/test/base_unit_test_tmapi.rb +0 -165
@@ -15,82 +15,39 @@ module RTM::Occurrence
15
15
 
16
16
  describe "#parent" do
17
17
  it "should give back the Topic the Occurrence belongs to" do
18
- topic = @tm.create_topic_by("Haus")
18
+ topic = @tm.create_topic_by("House")
19
19
  topic.should be_a_kind_of RTM::Topic
20
- @tm.get("Haus").should be_a_kind_of RTM::Topic
21
- testocc = topic.create_occurrence("Hausnummer", "1")
20
+ @tm.get("House").should be_a_kind_of RTM::Topic
21
+ testocc = topic.create_occurrence("street number", "1")
22
22
  testocc.should be_a_kind_of RTM::Occurrence
23
23
  testocc.parent.should == topic
24
24
  end
25
25
  end
26
26
 
27
- describe "#value=" do
28
- before(:each) do
29
- @topic = @tm.create_topic_by("Haus")
30
- end
31
- it "should set an IRI value and the datatype to xsd:AnyURI if arguement is a Locator" do
32
- occ= @topic.create_occurrence("Hausnummer", "1")
33
- occ.datatype.to_external_form.should == RTM::PSI[:String]
34
- occ.value=(@tm.create_locator("http://www.haus.de"))
35
- occ.datatype.to_external_form.should == RTM::PSI[:IRI]
36
- occ.value.should include "http://www.haus.de" # since we dont know if not */ as in case of ontopia
37
- end
38
- it "should set an String value and the datatype to xsd:String if arguement is a String" do
39
- occ= @topic.create_occurrence("Webseite", @tm.create_locator("http://www.haus.de"))
40
- occ.datatype.to_external_form.should == RTM::PSI[:IRI]
41
- occ.value=("1")
42
- occ.datatype.to_external_form.should == RTM::PSI[:String]
43
- occ.value.should == "1"
44
- end
45
- it "should set a Float value and the datatype to xsd:Float if arguement is a Float" do
46
- occ= @topic.create_occurrence("Webseite", @tm.create_locator("http://www.haus.de"))
47
- occ.datatype.to_external_form.should == RTM::PSI[:IRI]
48
- 0.5.class.should == Float
49
- occ.value=(0.5)
50
- occ.datatype.to_external_form.should == RTM::PSI[:Float]
51
- occ.value.should == "0.5"
52
- end
53
- it "should set a Fixnum value and the datatype to xsd:long if arguement is a Fixnum" do
54
- occ= @topic.create_occurrence("Webseite", @tm.create_locator("http://www.haus.de"))
55
- occ.datatype.to_external_form.should == RTM::PSI[:IRI]
56
- 1.class.should == Fixnum
57
- occ.value=(1)
58
- occ.datatype.to_external_form.should == RTM::PSI[:Long]
59
- occ.value.should == "1"
60
- end
61
- it "should set a Bignum value and the datatype to xsd:integer if arguement is a Bignum" do
62
- occ= @topic.create_occurrence("Webseite", @tm.create_locator("http://www.haus.de"))
63
- occ.datatype.to_external_form.should == RTM::PSI[:IRI]
64
- 9999999999999999999.class.should == Bignum
65
- occ.value=(9999999999999999999)
66
- occ.datatype.to_external_form.should == RTM::PSI[:Integer]
67
- occ.value.should == "9999999999999999999"
68
- end
69
- end
70
27
  end # of describe self
71
28
 
72
29
  describe self do
73
- describe "#remove" do
74
- before(:each) do
75
- @tm = get_used_tm_sys_tm
76
- @topic1 = @tm.get!("topic1")
77
- @topic2 = @tm.get!("topic2")
78
- @occ = @topic1.create_occurrence("birthyear","2000")
79
- @topic2.create_occurrence("birthyear","1980")
80
- @topic1.should have(1).occurrences
81
- @topic1.occurrences.should include @occ
82
- end
83
- after(:each) do
84
- @tm.close
85
- end
86
- it "should remove this name from the container (topic)" do
87
- @tm.literal_index.getOccurrences("2000").size.should == 1
88
- @occ.remove
89
- @tm.literal_index.getOccurrences("2000").size.should == 0
90
- @tm.literal_index.getOccurrences("1980").size.should == 1
91
- @topic1.should have(0).occurrences
92
- end
30
+ describe "#remove" do
31
+ before(:each) do
32
+ @tm = get_used_tm_sys_tm
33
+ @topic1 = @tm.get!("topic1")
34
+ @topic2 = @tm.get!("topic2")
35
+ @occ = @topic1.create_occurrence("birthyear","2000")
36
+ @topic2.create_occurrence("birthyear","1980")
37
+ @topic1.should have(1).occurrences
38
+ @topic1.occurrences.should include @occ
39
+ end
40
+ after(:each) do
41
+ @tm.close
42
+ end
43
+ it "should remove this name from the container (topic)" do
44
+ @tm.literal_index.getOccurrences("2000").size.should == 1
45
+ @occ.remove
46
+ @tm.literal_index.getOccurrences("2000").size.should == 0
47
+ @tm.literal_index.getOccurrences("1980").size.should == 1
48
+ @topic1.should have(0).occurrences
93
49
  end
94
- end # of describe self
50
+ end
51
+ end # of describe self
95
52
 
96
53
  end # of module
@@ -7,7 +7,6 @@ module RTM::Reifiable
7
7
  describe self do
8
8
  before(:each) do
9
9
  @tm = get_used_tm_sys_tm
10
- @topic = @tm.get!("test_topic")
11
10
  end
12
11
  after(:each) do
13
12
  @tm.close
@@ -15,6 +14,7 @@ module RTM::Reifiable
15
14
 
16
15
  describe "#reifier=" do
17
16
  before(:each) do
17
+ @topic = @tm.get!("test_topic")
18
18
  @a_reifier = @tm.get!("test_reifier")
19
19
  @a_reifier.should be_a_kind_of RTM::Topic
20
20
  @a_reifier["-"] = "since"
@@ -140,7 +140,7 @@ module RTM::Reifiable
140
140
  lambda{@occ.reifier = "test_reifier"}.should raise_error
141
141
  end
142
142
  end
143
-
143
+
144
144
  describe "merging of two reifier" do
145
145
  it "should merge two reifier if their reified constructs are merged" do
146
146
  topic = @tm.get!("Hans_Peter")
@@ -289,12 +289,22 @@ module RTM::Scoped
289
289
  @variant.should be_a_kind_of RTM::Variant
290
290
  ###
291
291
  @variant.should have(3).themes
292
- @variant.scope.should include @tm.get("home"), @tm.get("mom"), @tm.get("endearment")
292
+ @variant.scope.should include(@tm.get("home"), @tm.get("mom"), @tm.get("endearment"))
293
293
  @variant.remove_theme("endearment")
294
294
  @variant.should have(2).themes
295
295
  @variant.scope.should include @tm.get("home"), @tm.get("mom")
296
296
  @variant.should be_a_kind_of RTM::Variant
297
297
  end
298
+ it "should not remove a theme from the scope of an Variant is removed that occurrs in the scope of its parent Name also" do
299
+ @variant.should be_a_kind_of RTM::Variant
300
+ ###
301
+ @variant.should have(3).themes
302
+ @variant.scope.should include(@tm.get("home"), @tm.get("mom"), @tm.get("endearment"))
303
+ @variant.remove_theme("home")
304
+ @variant.should have(3).themes
305
+ @variant.scope.should include(@tm.get("home"), @tm.get("mom"), @tm.get("endearment"))
306
+ @variant.should be_a_kind_of RTM::Variant
307
+ end
298
308
  it "should remove a Topic from the scope of an Association" do
299
309
  @assoc.should be_a_kind_of RTM::Association
300
310
  ###
@@ -353,13 +363,41 @@ module RTM::Scoped
353
363
  @name2.should have(1).themes
354
364
  @name2.remove_theme("non_existing")
355
365
  end
366
+ it "should remove a theme that occurs in a variant also (given a Topic)" do
367
+ @name2 = @topic.create_name("first", "Hansi", ["home"])
368
+ @variant2 = @name2.create_variant("Bubi",["home","endearment"])
369
+ @name2.should have(1).themes
370
+ @name2.themes.should include(@tm.get("home"))
371
+ @variant2.should have(2).themes
372
+ @variant2.themes.should include(@tm.get("home"), @tm.get("endearment"))
373
+ @name2.remove_theme(@tm.get("home"))
374
+ @name2.should have(0).themes
375
+ if implementation_for_spec == :tinytim
376
+ @variant2.should have(2).themes
377
+ elsif implementation_for_spec == :ontopia
378
+ @variant2.should have(1).themes
379
+ else
380
+ ### ???
381
+ @variant2.should have(2).themes
382
+ end
383
+ end
356
384
  it "should remove a theme that occurs in a variant also" do
357
385
  @name2 = @topic.create_name("first", "Hansi", ["home"])
358
386
  @variant2 = @name2.create_variant("Bubi",["home","endearment"])
359
387
  @name2.should have(1).themes
388
+ @name2.themes.should include(@tm.get("home"))
389
+ @variant2.should have(2).themes
390
+ @variant2.themes.should include(@tm.get("home"), @tm.get("endearment"))
360
391
  @name2.remove_theme("home")
361
392
  @name2.should have(0).themes
362
- @variant2.should have(2).themes
393
+ if implementation_for_spec == :tinytim
394
+ @variant2.should have(2).themes
395
+ elsif implementation_for_spec == :ontopia
396
+ @variant2.should have(1).themes
397
+ else
398
+ ### ???
399
+ @variant2.should have(2).themes
400
+ end
363
401
  end
364
402
  it "should remove several themes if several arguments are given" do
365
403
  @name2 = @topic.create_name("first", "Hansi", ["home","endearment","mom"])
@@ -48,24 +48,24 @@ module RTM::TopicMap
48
48
 
49
49
  describe "#add_prefix" do
50
50
  it "should raise an error if the identifier or reference are not Strings" do
51
- lambda{@tm.add_prefix(1,"www.test.de")}.should raise_error
51
+ lambda{@tm.add_prefix(1,"www.example.org")}.should raise_error
52
52
  lambda{@tm.add_prefix("a",2)}.should raise_error
53
53
  end
54
54
  it "should be allowed to set a prefix" do
55
55
  @tm.prefixes.should be_empty
56
- @tm.add_prefix("a","www.qnametest.com")
56
+ @tm.add_prefix("a","www.example.org")
57
57
  @tm.prefixes.size.should == 1
58
- @tm.prefixes["a"].should == "www.qnametest.com"
58
+ @tm.prefixes["a"].should == "www.example.org"
59
59
  end
60
60
  it "should replace the reference if prefix already exists" do
61
- @tm.add_prefix("a","www.qnametest.com")
62
- @tm.prefixes["a"].should == "www.qnametest.com"
63
- @tm.add_prefix("a","www.test.de")
64
- @tm.prefixes["a"].should == "www.test.de"
61
+ @tm.add_prefix("a","www.example.com")
62
+ @tm.prefixes["a"].should == "www.example.com"
63
+ @tm.add_prefix("a","www.example.org")
64
+ @tm.prefixes["a"].should == "www.example.org"
65
65
  end
66
66
  it "should give back the prefixes-Hash" do
67
- @tm.add_prefix("a","www.qnametest.com").should == @tm.prefixes
68
- @tm.add_prefix("g","www.qnametest2.com").should == @tm.prefixes
67
+ @tm.add_prefix("a","www.example.com").should == @tm.prefixes
68
+ @tm.add_prefix("g","www.example.org").should == @tm.prefixes
69
69
  end
70
70
  # it "should warn if identifier equals sl, si or ii" do
71
71
  # lambda{@tm.add_prefix("sl","test")}.should ?
@@ -76,9 +76,9 @@ module RTM::TopicMap
76
76
 
77
77
  describe "#delete_prefix" do
78
78
  before(:each) do
79
- @tm.add_prefix("a","www.qnametest.com/a/")
80
- @tm.add_prefix("b","www.qnametest.com/b/")
81
- @tm.add_prefix("c","www.qnametest.com/c/")
79
+ @tm.add_prefix("a","www.example.org/a/")
80
+ @tm.add_prefix("b","www.example.org/b/")
81
+ @tm.add_prefix("c","www.example.org/c/")
82
82
  end
83
83
  it "should delete the right prefix" do
84
84
  @tm.prefixes.length.should == 3
@@ -89,7 +89,7 @@ module RTM::TopicMap
89
89
  end
90
90
  it "should delete the right prefix if the reference is given" do
91
91
  @tm.prefixes.length.should == 3
92
- @tm.delete_prefix("a","www.qnametest.com/a/").size.should == 2
92
+ @tm.delete_prefix("a","www.example.org/a/").size.should == 2
93
93
  @tm.find_prefix(:identifier => "a").should be_empty
94
94
  @tm.find_prefix(:identifier => "b").should_not be_empty
95
95
  @tm.find_prefix(:identifier => "c").should_not be_empty
@@ -273,12 +273,19 @@ module RTM::TopicMap
273
273
  @tm.get(array).size.should == array.size
274
274
  @tm.get(array).should == array.map{|i| @tm.get(i)}
275
275
  end
276
+ it "should give back a Multiarray of Topics and nils if argument is a Multiarray of identifiers and nils" do
277
+ array = [["si","","=sl","",nil,"something"],"^ii",@tm.create_locator("blub")]
278
+ @tm.get(array).size.should == array.size
279
+ @tm.get(array)[0].should == @tm.get(["si","","=sl","",nil,"something"])
280
+ @tm.get(array)[1].should == @tm.get("^ii")
281
+ @tm.get(array)[2].should == @tm.get(@tm.create_locator("blub"))
282
+ end
276
283
  it "should handle identifier which are qnames (get)" do
277
- @tm.add_prefix("x","http://www.test.de/x/")
278
- @tm.add_prefix("y","http://www.test.de/y/")
279
- topic = @tm.create_topic_by_subject_identifier("http://www.test.de/x/something")
284
+ @tm.add_prefix("x","http://www.example.org/x/")
285
+ @tm.add_prefix("y","http://www.example.org/y/")
286
+ topic = @tm.create_topic_by_subject_identifier("http://www.example.org/x/something")
280
287
  @tm.get("x:something").should == topic
281
- topic2 = @tm.create_topic_by_item_identifier("http://www.test.de/y/something")
288
+ topic2 = @tm.create_topic_by_item_identifier("http://www.example.org/y/something")
282
289
  @tm.get("ii:y:something").should == topic2
283
290
  end
284
291
  end
@@ -301,33 +308,33 @@ module RTM::TopicMap
301
308
  @tm.get!(topic).should == topic
302
309
  end
303
310
  it "should give back a Topic if argument is a Locator and the Topic defined by the Locator (si) already exists" do
304
- locator = @tm.create_locator("http://www.uni-leipzig.de")
311
+ locator = @tm.create_locator("http://www.example.org/uni-leipzig")
305
312
  locator.should be_a_kind_of RTM::Locator
306
313
  topic = @tm.create_topic_by_subject_identifier(locator)
307
314
  topic.should be_a_kind_of RTM::Topic
308
315
  @tm.get!(locator).should == topic
309
316
  end
310
317
  it "should give back a Topic if argument is a Locator and the Topic defined by the Locator (ii) already exists" do
311
- locator = @tm.create_locator("http://www.uni-leipzig.de")
318
+ locator = @tm.create_locator("http://www.example.org/uni-leipzig")
312
319
  locator.should be_a_kind_of RTM::Locator
313
320
  topic = @tm.create_topic_by_item_identifier(locator)
314
321
  topic.should be_a_kind_of RTM::Topic
315
322
  @tm.get!(locator).should == topic
316
323
  end
317
324
  it "should give back a Topic if argument is a String(absolute IRI,si) and the Topic defined by the String already exists" do
318
- string = "http://www.uni-leipzig.de/"
325
+ string = "http://www.example.org/uni-leipzig"
319
326
  topic = @tm.create_topic_by_subject_identifier(@tm.create_locator(string))
320
327
  @tm.get!(string).should == topic
321
328
  @tm.get!("si:" + string).should == topic
322
329
  end
323
330
  it "should give back a Topic if argument is a String(absolute IRI,sl) and the Topic defined by the String already exists" do
324
- string = "http://www.uni-leipzig.de/"
331
+ string = "http://www.example.org/uni-leipzig"
325
332
  topic = @tm.create_topic_by_subject_locator(@tm.create_locator(string))
326
333
  @tm.get!("sl:" + string).should == topic
327
334
  @tm.get!("=" + string).should == topic
328
335
  end
329
336
  it "should give back a Topic if argument is a String(absolute IRI,ii) and the Topic defined by the String already exists" do
330
- string = "http://www.uni-leipzig.de/"
337
+ string = "http://www.example.org/uni-leipzig"
331
338
  topic = @tm.create_topic_by_item_identifier(@tm.create_locator(string))
332
339
  @tm.get!("ii:" + string).should == topic
333
340
  @tm.get!("^" + string).should == topic
@@ -463,24 +470,29 @@ module RTM::TopicMap
463
470
  it "should allow to create/get several Topics wheras some already exist and others not" do
464
471
  array = ["dummy_si",@tm.create_locator("something"),"sl:Hans"]
465
472
  @tm.get!(array).size.should == array.size
466
- #TODO
467
- #@tm.get!("")
468
473
  @tm.get!(array).should == array.map{|i| @tm.get!(i)}
469
474
  end
470
- it "should handle identifier which are qnames (get!)" do
471
- @tm.add_prefix("x","http://www.test.de/x/")
472
- @tm.add_prefix("y","http://www.test.de/y/")
475
+ it "should give back a Multiarray of Topics if argument is a Multiarray of identifiers and nils" do
476
+ array = [["si","","=sl","",nil,"something"],"^ii",@tm.create_locator("blub")]
477
+ @tm.get!(array).size.should == array.size
478
+ @tm.get!(array)[0].should == @tm.get!(["si","","=sl","",nil,"something"])
479
+ @tm.get!(array)[1].should == @tm.get!("^ii")
480
+ @tm.get!(array)[2].should == @tm.get!(@tm.create_locator("blub"))
481
+ end
482
+ it "should handle identifier which are qnames" do
483
+ @tm.add_prefix("x","http://www.example.org/x/")
484
+ @tm.add_prefix("y","http://www.example.org/y/")
473
485
  topic = @tm.get!("x:something")
474
- topic.indicators.should include "http://www.test.de/x/something"
486
+ topic.indicators.should include("http://www.example.org/x/something")
475
487
  topic2 = @tm.get!("sl:y:something")
476
- topic2.locators.should include "http://www.test.de/y/something"
488
+ topic2.locators.should include("http://www.example.org/y/something")
477
489
  end
478
490
  end
479
491
 
480
492
  describe "#create_locator" do
481
493
  it "should handle identifier which are qnames (create_locator)" do
482
494
  identifier = "x"
483
- reference = "http://www.test.de/"
495
+ reference = "http://www.example.org/"
484
496
  @tm.add_prefix(identifier, reference)
485
497
  topic = @tm.create_topic_by(identifier + ":" + "something")
486
498
  topic.should be_a_kind_of RTM::Topic
@@ -632,6 +644,62 @@ module RTM::TopicMap
632
644
  assoc.roles.map{|r| r.player}.should include @tm.get("France"), @tm.get("Germany")
633
645
  end
634
646
  end
647
+
648
+ describe "#associations" do
649
+ before(:each) do
650
+ @assoc1 = @tm.create_association("at1")
651
+ @assoc2 = @tm.create_association("at2", "rt21" => "rp21")
652
+ @assoc3 = @tm.create_association("at3", "rt31" => "rp31", "rt32" => "rp32")
653
+ @assoc4 = @tm.create_association("at3")
654
+ @no_assoc_type = @tm.get!("no_assoc_type")
655
+ end
656
+ it "should give back all associations" do
657
+ @tm.should have(4).associations
658
+ @tm.associations.should include(@assoc1, @assoc2, @assoc3, @assoc4)
659
+ end
660
+ it "should give back some associations if argument type (String) is given" do
661
+ @tm.associations("at1").size.should == 1
662
+ @tm.associations("at1").should include(@assoc1)
663
+ @tm.associations("at3").size.should == 2
664
+ @tm.associations("at3").should include(@assoc3, @assoc4)
665
+ @tm.associations("no_assoc_type").should be_empty
666
+ end
667
+ it "should give back some associations if argument type (Locator) is given" do
668
+ at2_loc = @tm.create_locator("at2")
669
+ at2_loc.should_not be_nil
670
+ at3_loc = @tm.create_locator("at3")
671
+ at3_loc.should_not be_nil
672
+ @tm.associations(at2_loc).size.should == 1
673
+ @tm.associations(at2_loc).should include(@assoc2)
674
+ @tm.associations(at3_loc).size.should == 2
675
+ @tm.associations(at3_loc).should include(@assoc3, @assoc4)
676
+ @tm.associations(@tm.create_locator("no_assoc_type")).should be_empty
677
+ end
678
+ it "should give back some associations if argument type (Topic) is given" do
679
+ at1 = @tm.get("at1")
680
+ at1.should_not be_nil
681
+ at3 = @tm.get("at3")
682
+ at3.should_not be_nil
683
+ @tm.associations(at1).size.should == 1
684
+ @tm.associations(at1).should include(@assoc1)
685
+ @tm.associations(at3).size.should == 2
686
+ @tm.associations(at3).should include(@assoc3, @assoc4)
687
+ @tm.associations(@no_assoc_type).should be_empty
688
+ end
689
+ it "should raise error if argument type is nil" do
690
+ lambda{@tm.associations(nil)}.should raise_error
691
+ end
692
+ it "should raise error if argument type is an array" do
693
+ lambda{@tm.associations(["a"])}.should raise_error
694
+ end
695
+ it "should give back no associations if argument type is a String but no Topic with this identifier exists" do
696
+ @tm.associations("not_existing").should be_empty
697
+ end
698
+ it "should give back no associations if argument type is a Locator but no Topic with this identifier exists" do
699
+ @tm.associations(@tm.create_locator("not_existing")).should be_empty
700
+ end
701
+ end
702
+
635
703
  end # of describe self
636
704
 
637
705
  describe self do
@@ -286,6 +286,53 @@ module RTM::Topic
286
286
  end
287
287
  end
288
288
 
289
+ describe "#remove_instance" do
290
+ before(:each) do
291
+ @t1,@t2,@t3,@t4 = @tm.get!(["t1","t2","t3","t4"])
292
+ @t1.add_type(@t2)
293
+ @t1.add_type(@t3)
294
+ @t4.add_type(@t2)
295
+ @t2.should have(2).instances
296
+ @t2.instances.should include @t1, @t4
297
+ end
298
+ it "should remove an instance if argument is a String" do
299
+ @t2.remove_instance("t1")
300
+ @t2.should have(1).instances
301
+ @t2.instances.should include @t4
302
+ @t2.remove_instance("t4")
303
+ @t2.should have(0).instances
304
+ end
305
+ it "should remove an instance if argument is a Locator" do
306
+ @t2.remove_instance(@tm.create_locator("t4"))
307
+ @t2.should have(1).instances
308
+ @t2.instances.should include @t1
309
+ @t2.remove_instance(@tm.create_locator("t1"))
310
+ @t2.should have(0).instances
311
+ end
312
+ it "should remove an instance if argument is a Topic" do
313
+ @t2.remove_instance(@t1)
314
+ @t2.should have(1).instances
315
+ @t2.instances.should include @t4
316
+ @t2.remove_instance(@t4)
317
+ @t2.should have(0).instances
318
+ end
319
+ it "should not remove an instance if argument does not match an instance of this Topic" do
320
+ @t2.remove_instance("t3")
321
+ @t2.should have(2).instances
322
+ @t2.remove_instance("t5")
323
+ @t2.should have(2).instances
324
+ @t2.remove_instance(@tm.create_locator("t3"))
325
+ @t2.should have(2).instances
326
+ @t2.remove_instance(@tm.create_locator("t5"))
327
+ @t2.should have(2).instances
328
+ @t2.remove_instance(@t3)
329
+ @t2.should have(2).instances
330
+ @t2.remove_instance(@t5)
331
+ @t2.should have(2).instances
332
+ @t2.instances.should include @t1, @t4
333
+ end
334
+ end
335
+
289
336
  describe "#parent" do
290
337
  it "should give back the Topic Map" do
291
338
  topic = @tm.create_topic_by("=weihnachtsmann")
@@ -496,7 +543,7 @@ module RTM::Topic
496
543
  name1 = topic.create_name("Universitaet Leipzig")
497
544
  name2 = topic.create_name("University of Leipzig")
498
545
  occ1 = topic.create_occurrence("Gruendungsjahr", "1409")
499
- occ2 = topic.create_occurrence("Webseite", "http://www.uni-leipzig.de")
546
+ occ2 = topic.create_occurrence("Webseite", "http://www.example.org/uni-leipzig")
500
547
  topic.should have(4).children
501
548
  topic.children.should include(name1, name2, occ1, occ2)
502
549
  end
@@ -594,77 +641,506 @@ module RTM::Topic
594
641
  before(:each) do
595
642
  @topic = @tm.get!("person")
596
643
  end
597
- it "should create an occurrence if only type and value=string is given" do
598
- occ = @topic.create_occurrence("Geburtsort","Leipzig")
599
- occ.should be_a_kind_of(RTM::Occurrence)
600
- @tm.get("Geburtsort").should be_a_kind_of(RTM::Topic)
601
- occ.type.should == @tm.get("Geburtsort")
602
- occ.value.should == "Leipzig"
603
- occ.scope.should respond_to(:each)
604
- occ.scope.should be_empty
605
- end
606
- it "should create an occurrence if only type and value=URI(Locator) is given" do
607
- t = @tm.get!("Webseite")
608
- occ = @topic.create_occurrence(t,@tm.create_locator("http://www.uni-leipzig.de/"))
609
- occ.should be_a_kind_of(RTM::Occurrence)
610
- occ.type.should == t
611
- occ.datatype.to_external_form.should == RTM::PSI[:IRI]
612
- occ.value.should == "http://www.uni-leipzig.de/"
613
- occ.scope.should respond_to(:each)
614
- occ.scope.should be_empty
615
- end
616
- it "should create an occurrence if only type and value=string and a scope is given" do
617
- occ = @topic.create_occurrence("Geburtsort","Leipzig",{:scope => ["deutsch"]})
618
- occ.should be_a_kind_of(RTM::Occurrence)
619
- @tm.get("Geburtsort").should be_a_kind_of(RTM::Topic)
620
- occ.type.should == @tm.get("Geburtsort")
621
- occ.value.should == "Leipzig"
622
- occ.scope.should respond_to(:each)
623
- occ.scope.should include(@tm.get("deutsch"))
624
- occ.datatype.to_external_form.should_not == RTM::PSI[:IRI]
625
- end
626
- it "should create an occurrence if several scope-items are given" do
627
- occ = @topic.create_occurrence("Geburtsort","Leipzig",{:scope => ["deutsch","test"]})
628
- occ.should be_a_kind_of(RTM::Occurrence)
629
- @tm.get("Geburtsort").should be_a_kind_of(RTM::Topic)
630
- occ.type.should == @tm.get("Geburtsort")
631
- occ.value.should == "Leipzig"
632
- occ.scope.should respond_to(:each)
633
- occ.scope.size.should == 2
634
- occ.scope.should include(@tm.get("deutsch"), @tm.get("test"))
635
- end
636
- it "should create an occurrence if only type and value=string and a datatype is given" do
637
- occ = @topic.create_occurrence("Alter","26",{:datatype => @tm.create_locator(RTM::PSI[:anyType])})
638
- occ.should be_a_kind_of(RTM::Occurrence)
639
- @tm.get("Alter").should be_a_kind_of(RTM::Topic)
640
- occ.type.should == @tm.get("Alter")
641
- occ.value.should == "26"
642
- occ.datatype.should == @tm.create_locator(RTM::PSI[:anyType])
643
- occ.datatype.to_external_form.should ==RTM::PSI[:anyType]
644
- occ.scope.should respond_to(:each)
645
- occ.scope.should be_empty
646
- end
647
- it "should create an occurrence if type, value=string, datatype and scope is given" do
648
- occ = @topic.create_occurrence("Heimat","Sachsen",{:datatype => RTM::PSI[:String], :scope => ["deutsch"]})
649
- occ.should be_a_kind_of(RTM::Occurrence)
650
- @tm.get("Heimat").should be_a_kind_of(RTM::Topic)
651
- occ.type.should == @tm.get("Heimat")
652
- occ.value.should == "Sachsen"
653
- occ.datatype.should == @tm.create_locator(RTM::PSI[:String])
654
- occ.datatype.to_external_form.should == RTM::PSI[:String]
655
- occ.scope.should respond_to(:each)
656
- occ.scope.should include(@tm.get("deutsch"))
644
+ after(:each) do
645
+ end
646
+ describe "with false arguments" do
647
+ it "should raise an error if type is a String and the value's datatype is not supported" do
648
+ lambda{@topic.create_occurrence("Age", {:a => :b})}.should raise_error
649
+ end
650
+ it "should not raise an error if type is String, datatype is given, the value's datatype is not supported but the value may be converted to string" do
651
+ lambda{:a.to_s}.should_not raise_error
652
+ lambda{@topic.create_occurrence("Age", :a, :datatype => RTM::PSI[:String])}.should_not raise_error
653
+ end
654
+ it "should raise an error if type is a Locator and the value's type is not supported" do
655
+ lambda{@topic.create_occurrence(@tm.create_locator("Age"), {:a => :b})}.should raise_error
656
+ end
657
+ it "should raise an error if type is a Topic and the value's type is not supported" do
658
+ lambda{@topic.create_occurrence(@tm.get!("Age"), {:a => :b})}.should raise_error
659
+ end
660
+ it "should raise an error if scope is not an array"
661
+ it "should raise an error if datatype is not of type String or Locator"
662
+ it "should raise an error if datatype is nil" do
663
+ @occ = @topic.create_occurrence("birthplace","Leipzig", :datatype => nil)
664
+ end
665
+ end
666
+ describe "given type and value" do
667
+ after(:each) do
668
+ @occ.should be_a_kind_of(RTM::Occurrence)
669
+ @occ.scope.should respond_to(:each)
670
+ @occ.scope.should be_empty
671
+ end
672
+ describe "and type is a String" do
673
+ it "should create an occurrence if value is a String" do
674
+ @occ = @topic.create_occurrence("birthplace","Leipzig")
675
+ @tm.get("birthplace").should be_a_kind_of(RTM::Topic)
676
+ @occ.type.should == @tm.get("birthplace")
677
+ @occ.value.should == "Leipzig"
678
+ @occ.datatype.should == @tm.create_locator(RTM::PSI[:String])
679
+ end
680
+ it "should create an occurrence if value is a Locator" do
681
+ @occ = @topic.create_occurrence("Website" ,@tm.create_locator("http://www.example.org/uni-leipzig"))
682
+ @tm.get("Website").should be_a_kind_of(RTM::Topic)
683
+ @occ.type.should == @tm.get("Website")
684
+ @occ.datatype.to_external_form.should == RTM::PSI[:IRI]
685
+ @occ.value.should == "http://www.example.org/uni-leipzig"
686
+ end
687
+ it "should create an occurrnce if value is a Float" do
688
+ @occ = @topic.create_occurrence("Age", 23.5)
689
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
690
+ @occ.type.should == @tm.get("Age")
691
+ @occ.datatype.to_external_form.should == RTM::PSI[:Float]
692
+ @occ.value.should == "23.5"
693
+ end
694
+ it "should create an occurrence if value is a Fixum" do
695
+ @occ = @topic.create_occurrence("Age", 23)
696
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
697
+ @occ.type.should == @tm.get("Age")
698
+ @occ.datatype.to_external_form.should == RTM::PSI[:Long]
699
+ @occ.value.should == "23"
700
+ end
701
+ it "should create an occurrence if value is Bignum" do
702
+ number = 9999999999999999999
703
+ number.class.should == Bignum
704
+ @occ = @topic.create_occurrence("Age", number)
705
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
706
+ @occ.type.should == @tm.get("Age")
707
+ @occ.datatype.to_external_form.should == RTM::PSI[:Integer]
708
+ @occ.value.should == number.to_s
709
+ end
710
+ end
711
+ describe "and type is a Locator" do
712
+ it "should create an occurrence if value is a String" do
713
+ @occ = @topic.create_occurrence(@tm.create_locator("birthplace"),"Leipzig")
714
+ @tm.get("birthplace").should be_a_kind_of(RTM::Topic)
715
+ @occ.type.should == @tm.get("birthplace")
716
+ @occ.value.should == "Leipzig"
717
+ @occ.datatype.should == @tm.create_locator(RTM::PSI[:String])
718
+ end
719
+ it "should create an occurrence if value is an IRI" do
720
+ @occ = @topic.create_occurrence(@tm.create_locator("Website"), @tm.create_locator("http://www.example.org/uni-leipzig"))
721
+ @tm.get("Website").should be_a_kind_of(RTM::Topic)
722
+ @occ.type.should == @tm.get("Website")
723
+ @occ.value.should == "http://www.example.org/uni-leipzig"
724
+ @occ.datatype.should == @tm.create_locator(RTM::PSI[:IRI])
725
+ end
726
+ it "should create an occurrnce if value is a Float" do
727
+ @occ = @topic.create_occurrence(@tm.create_locator("Age"), 23.5)
728
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
729
+ @occ.type.should == @tm.get("Age")
730
+ @occ.datatype.to_external_form.should == RTM::PSI[:Float]
731
+ @occ.value.should == "23.5"
732
+ end
733
+ it "should create an occurrence if value is a Fixum" do
734
+ @occ = @topic.create_occurrence(@tm.create_locator("Age"), 23)
735
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
736
+ @occ.type.should == @tm.get("Age")
737
+ @occ.datatype.to_external_form.should == RTM::PSI[:Long]
738
+ @occ.value.should == "23"
739
+ end
740
+ it "should create an occurrence if value is Bignum" do
741
+ number = 9999999999999999999
742
+ number.class.should == Bignum
743
+ @occ = @topic.create_occurrence(@tm.create_locator("Age"), number)
744
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
745
+ @occ.type.should == @tm.get("Age")
746
+ @occ.datatype.to_external_form.should == RTM::PSI[:Integer]
747
+ @occ.value.should == number.to_s
748
+ end
749
+ end
750
+ describe "and type is a Topic" do
751
+ it "should create an occurrence if value is a String" do
752
+ type = @tm.get!("Website")
753
+ @occ = @topic.create_occurrence(type, "http://www.example.org/uni-leipzig")
754
+ @occ.type.should == type
755
+ @occ.datatype.to_external_form.should == RTM::PSI[:String]
756
+ @occ.value.should == "http://www.example.org/uni-leipzig"
757
+ end
758
+ it "should create an occurrence if value is an IRI" do
759
+ type = @tm.get!("Website")
760
+ @occ = @topic.create_occurrence(type, @tm.create_locator("http://www.example.org/uni-leipzig"))
761
+ @occ.type.should == type
762
+ @occ.datatype.to_external_form.should == RTM::PSI[:IRI]
763
+ @occ.value.should == "http://www.example.org/uni-leipzig"
764
+ end
765
+ it "should create an occurrnce if value is a Float" do
766
+ type = @tm.get!("Age")
767
+ @occ = @topic.create_occurrence(type, 23.5)
768
+ @occ.type.should == type
769
+ @occ.datatype.to_external_form.should == RTM::PSI[:Float]
770
+ @occ.value.should == "23.5"
771
+ end
772
+ it "should create an occurrence if value is a Fixum" do
773
+ type = @tm.get!("Age")
774
+ @occ = @topic.create_occurrence(type, 23)
775
+ @occ.type.should == type
776
+ @occ.datatype.to_external_form.should == RTM::PSI[:Long]
777
+ @occ.value.should == "23"
778
+ end
779
+ it "should create an occurrence if value is Bignum" do
780
+ number = 9999999999999999999
781
+ number.class.should == Bignum
782
+ type = @tm.get!("Age")
783
+ @occ = @topic.create_occurrence(type, number)
784
+ @occ.type.should == type
785
+ @occ.datatype.to_external_form.should == RTM::PSI[:Integer]
786
+ @occ.value.should == number.to_s
787
+ end
788
+ end
789
+ end
790
+ describe "given type, value and datatype" do
791
+ after(:each) do
792
+ @occ.should be_a_kind_of(RTM::Occurrence)
793
+ @occ.scope.should respond_to(:each)
794
+ @occ.scope.should be_empty
795
+ end
796
+ describe "and type is a String" do
797
+ describe "and value is a String" do
798
+ it "should create an occurrence if datatype is xsd:String" do
799
+ @occ = @topic.create_occurrence("birthplace","Leipzig", :datatype => RTM::PSI[:String])
800
+ @tm.get("birthplace").should be_a_kind_of(RTM::Topic)
801
+ @occ.type.should == @tm.get("birthplace")
802
+ @occ.value.should == "Leipzig"
803
+ @occ.datatype.should == @tm.create_locator(RTM::PSI[:String])
804
+ end
805
+ it "should create an occurrence if datatype is xsd:anyURI ?"
806
+ it "should create an occurrence if datatype is xsd:float ?"
807
+ it "should create an occurrence if datatype is xsd:long ?"
808
+ it "should create an occurrence if datatype is xsd:integer ?"
809
+ it "should create an occurrence if datatype is xsd:?? ?"
810
+ end
811
+ describe "and value is a Locator" do
812
+ it "should create an occurrence if datatype is xsd:String" do
813
+ @occ = @topic.create_occurrence("Website" ,@tm.create_locator("http://www.example.org/uni-leipzig"), :datatype => RTM::PSI[:String])
814
+ @tm.get("Website").should be_a_kind_of(RTM::Topic)
815
+ @occ.type.should == @tm.get("Website")
816
+ @occ.datatype.to_external_form.should == RTM::PSI[:String]
817
+ @occ.value.should == "http://www.example.org/uni-leipzig"
818
+ end
819
+ it "should create an occurrence if datatype is xsd:anyURI ?"
820
+ it "should create an occurrence if datatype is xsd:float ?"
821
+ it "should create an occurrence if datatype is xsd:long ?"
822
+ it "should create an occurrence if datatype is xsd:integer ?"
823
+ it "should create an occurrence if datatype is xsd:?? ?"
824
+ end
825
+ describe "and value is a Float" do
826
+ it "should create an occurrence if datatype is xsd:String" do
827
+ @occ = @topic.create_occurrence("Age", 23.5, :datatype => RTM::PSI[:String])
828
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
829
+ @occ.type.should == @tm.get("Age")
830
+ @occ.datatype.to_external_form.should == RTM::PSI[:String]
831
+ @occ.value.should == "23.5"
832
+ end
833
+ it "should create an occurrence if datatype is xsd:anyURI ?"
834
+ it "should create an occurrence if datatype is xsd:float ?"
835
+ it "should create an occurrence if datatype is xsd:long ?"
836
+ it "should create an occurrence if datatype is xsd:integer ?"
837
+ it "should create an occurrence if datatype is xsd:?? ?"
838
+ end
839
+ describe "and value is a Fixnum" do
840
+ it "should create an occurrence if datatype is xsd:String" do
841
+ @occ = @topic.create_occurrence("Age", 23, :datatype => RTM::PSI[:String])
842
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
843
+ @occ.type.should == @tm.get("Age")
844
+ @occ.datatype.to_external_form.should == RTM::PSI[:String]
845
+ @occ.value.should == "23"
846
+ end
847
+ it "should create an occurrence if datatype is xsd:anyURI ?"
848
+ it "should create an occurrence if datatype is xsd:float ?"
849
+ it "should create an occurrence if datatype is xsd:long ?"
850
+ it "should create an occurrence if datatype is xsd:integer ?"
851
+ it "should create an occurrence if datatype is xsd:?? ?"
852
+ end
853
+ describe "and value is a Bignum" do
854
+ it "should create an occurrence if datatype is xsd:String" do
855
+ number = 9999999999999999999
856
+ number.class.should == Bignum
857
+ @occ = @topic.create_occurrence("Age", number, :datatype => RTM::PSI[:String])
858
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
859
+ @occ.type.should == @tm.get("Age")
860
+ @occ.datatype.to_external_form.should == RTM::PSI[:String]
861
+ @occ.value.should == number.to_s
862
+ end
863
+ it "should create an occurrence if datatype is xsd:anyURI ?"
864
+ it "should create an occurrence if datatype is xsd:float ?"
865
+ it "should create an occurrence if datatype is xsd:long ?"
866
+ it "should create an occurrence if datatype is xsd:integer ?"
867
+ it "should create an occurrence if datatype is xsd:?? ?"
868
+ end
869
+ end
870
+ it "should create an occurrence if type is a Locator and value and datatype is given" do
871
+ @occ = @topic.create_occurrence(@tm.create_locator("birthplace"), "Leipzig", :datatype => RTM::PSI[:IRI])
872
+ @tm.get("birthplace").should be_a_kind_of(RTM::Topic)
873
+ @occ.type.should == @tm.get("birthplace")
874
+ @occ.value.should == "http://www.topicmapslab.de/Leipzig"
875
+ @occ.datatype.should == @tm.create_locator(RTM::PSI[:IRI])
876
+ end
877
+ it "should create an occurrence if type is a Topic and value and datatype is given" do
878
+ type = @tm.get!("Website")
879
+ @occ = @topic.create_occurrence(type, "1", :datatype => RTM::PSI[:String])
880
+ @occ.type.should == type
881
+ @occ.datatype.to_external_form.should == RTM::PSI[:String]
882
+ @occ.value.should == "1"
883
+ end
884
+ end
885
+ describe "given type, value and scope" do
886
+ after(:each) do
887
+ @occ.should be_a_kind_of(RTM::Occurrence)
888
+ @occ.scope.should respond_to(:each)
889
+ end
890
+ describe "given one theme" do
891
+ after(:each) do
892
+ @occ.scope.size.should == 1
893
+ @occ.scope.should include(@tm.get("test_theme"))
894
+ end
895
+ it "should create an occurrence if type is a String and value is a String" do
896
+ @occ = @topic.create_occurrence("birthplace","Leipzig", :scope => ["test_theme"])
897
+ @tm.get("birthplace").should be_a_kind_of(RTM::Topic)
898
+ @occ.type.should == @tm.get("birthplace")
899
+ @occ.value.should == "Leipzig"
900
+ @occ.datatype.should == @tm.create_locator(RTM::PSI[:String])
901
+ end
902
+ it "should create an occurrence if type is a String and value is a Locator" do
903
+ @occ = @topic.create_occurrence("Website" ,@tm.create_locator("http://www.example.org/uni-leipzig"), :scope => ["test_theme"])
904
+ @tm.get("Website").should be_a_kind_of(RTM::Topic)
905
+ @occ.type.should == @tm.get("Website")
906
+ @occ.datatype.to_external_form.should == RTM::PSI[:IRI]
907
+ @occ.value.should == "http://www.example.org/uni-leipzig"
908
+ end
909
+ it "should create an occurrnce if type is a String and value is a Float" do
910
+ @occ = @topic.create_occurrence("Age", 23.5, :scope => ["test_theme"])
911
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
912
+ @occ.type.should == @tm.get("Age")
913
+ @occ.datatype.to_external_form.should == RTM::PSI[:Float]
914
+ @occ.value.should == "23.5"
915
+ end
916
+ it "should create an occurrence if type is a String and value is a Fixum" do
917
+ @occ = @topic.create_occurrence("Age", 23, :scope => ["test_theme"])
918
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
919
+ @occ.type.should == @tm.get("Age")
920
+ @occ.datatype.to_external_form.should == RTM::PSI[:Long]
921
+ @occ.value.should == "23"
922
+ end
923
+ it "should create an occurrence if type is a String and value is Bignum" do
924
+ number = 9999999999999999999
925
+ number.class.should == Bignum
926
+ @occ = @topic.create_occurrence("Age", number, :scope => ["test_theme"])
927
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
928
+ @occ.type.should == @tm.get("Age")
929
+ @occ.datatype.to_external_form.should == RTM::PSI[:Integer]
930
+ @occ.value.should == number.to_s
931
+ end
932
+ it "should create an occurrence if type is a Locator and value is a String" do
933
+ @occ = @topic.create_occurrence(@tm.create_locator("birthplace"), "Leipzig", :scope => ["test_theme"])
934
+ @tm.get("birthplace").should be_a_kind_of(RTM::Topic)
935
+ @occ.type.should == @tm.get("birthplace")
936
+ @occ.value.should == "Leipzig"
937
+ @occ.datatype.should == @tm.create_locator(RTM::PSI[:String])
938
+ end
939
+ it "should create an occurrence if type is a Locator and value is an IRI" do
940
+ @occ = @topic.create_occurrence(@tm.create_locator("Website"), @tm.create_locator("http://www.example.org/uni-leipzig"), :scope => ["test_theme"])
941
+ @tm.get("Website").should be_a_kind_of(RTM::Topic)
942
+ @occ.type.should == @tm.get("Website")
943
+ @occ.value.should == "http://www.example.org/uni-leipzig"
944
+ @occ.datatype.should == @tm.create_locator(RTM::PSI[:IRI])
945
+ end
946
+ it "should create an occurrnce if type is a Locator and value is a Float" do
947
+ @occ = @topic.create_occurrence(@tm.create_locator("Age"), 23.5, :scope => ["test_theme"])
948
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
949
+ @occ.type.should == @tm.get("Age")
950
+ @occ.datatype.to_external_form.should == RTM::PSI[:Float]
951
+ @occ.value.should == "23.5"
952
+ end
953
+ it "should create an occurrence if type is a Locator and value is a Fixum" do
954
+ @occ = @topic.create_occurrence(@tm.create_locator("Age"), 23, :scope => ["test_theme"])
955
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
956
+ @occ.type.should == @tm.get("Age")
957
+ @occ.datatype.to_external_form.should == RTM::PSI[:Long]
958
+ @occ.value.should == "23"
959
+ end
960
+ it "should create an occurrence if type is a Locator and value is Bignum" do
961
+ number = 9999999999999999999
962
+ number.class.should == Bignum
963
+ @occ = @topic.create_occurrence(@tm.create_locator("Age"), number, :scope => ["test_theme"])
964
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
965
+ @occ.type.should == @tm.get("Age")
966
+ @occ.datatype.to_external_form.should == RTM::PSI[:Integer]
967
+ @occ.value.should == number.to_s
968
+ end
969
+ it "should create an occurrence if type is a Topic and value is a String" do
970
+ type = @tm.get!("Website")
971
+ @occ = @topic.create_occurrence(type, "http://www.example.org/uni-leipzig", :scope => ["test_theme"])
972
+ @occ.type.should == type
973
+ @occ.datatype.to_external_form.should == RTM::PSI[:String]
974
+ @occ.value.should == "http://www.example.org/uni-leipzig"
975
+ end
976
+ it "should create an occurrence if type is a Topic and value is an IRI" do
977
+ type = @tm.get!("Website")
978
+ @occ = @topic.create_occurrence(type, @tm.create_locator("http://www.example.org/uni-leipzig"), :scope => ["test_theme"])
979
+ @occ.type.should == type
980
+ @occ.datatype.to_external_form.should == RTM::PSI[:IRI]
981
+ @occ.value.should == "http://www.example.org/uni-leipzig"
982
+ end
983
+ it "should create an occurrnce if type is a Topic and value is a Float" do
984
+ type = @tm.get!("Age")
985
+ @occ = @topic.create_occurrence(type, 23.5, :scope => ["test_theme"])
986
+ @occ.type.should == type
987
+ @occ.datatype.to_external_form.should == RTM::PSI[:Float]
988
+ @occ.value.should == "23.5"
989
+ end
990
+ it "should create an occurrence if type is a Topic and value is a Fixum" do
991
+ type = @tm.get!("Age")
992
+ @occ = @topic.create_occurrence(type, 23, :scope => ["test_theme"])
993
+ @occ.type.should == type
994
+ @occ.datatype.to_external_form.should == RTM::PSI[:Long]
995
+ @occ.value.should == "23"
996
+ end
997
+ it "should create an occurrence if type is a Topic and value is Bignum" do
998
+ number = 9999999999999999999
999
+ number.class.should == Bignum
1000
+ type = @tm.get!("Age")
1001
+ @occ = @topic.create_occurrence(type, number, :scope => ["test_theme"])
1002
+ @occ.type.should == type
1003
+ @occ.datatype.to_external_form.should == RTM::PSI[:Integer]
1004
+ @occ.value.should == number.to_s
1005
+ end
1006
+ end
1007
+ describe "given several themes" do
1008
+ before(:each) do
1009
+ @locator_theme = @tm.create_locator("test_theme2")
1010
+ @locator_theme.should be_a_kind_of RTM::Locator
1011
+ @topic_theme = @tm.get!("test_theme3")
1012
+ @topic_theme.should be_a_kind_of RTM::Topic
1013
+ end
1014
+ after(:each) do
1015
+ @occ.scope.size.should == 3
1016
+ @occ.scope.should include(@tm.get("test_theme1"), @tm.get("test_theme2"), @tm.get("test_theme3"))
1017
+ end
1018
+ it "should create an occurrence if type is a String and value is a String" do
1019
+ @occ = @topic.create_occurrence("birthplace","Leipzig", :scope => ["test_theme1", @locator_theme, @topic_theme])
1020
+ @tm.get("birthplace").should be_a_kind_of(RTM::Topic)
1021
+ @occ.type.should == @tm.get("birthplace")
1022
+ @occ.value.should == "Leipzig"
1023
+ @occ.datatype.should == @tm.create_locator(RTM::PSI[:String])
1024
+ end
1025
+ it "should create an occurrence if type is a String and value is a Locator" do
1026
+ @occ = @topic.create_occurrence("Website" ,@tm.create_locator("http://www.example.org/uni-leipzig"), :scope => ["test_theme1", @locator_theme, @topic_theme])
1027
+ @tm.get("Website").should be_a_kind_of(RTM::Topic)
1028
+ @occ.type.should == @tm.get("Website")
1029
+ @occ.datatype.to_external_form.should == RTM::PSI[:IRI]
1030
+ @occ.value.should == "http://www.example.org/uni-leipzig"
1031
+ end
1032
+ it "should create an occurrnce if type is a String and value is a Float" do
1033
+ @occ = @topic.create_occurrence("Age", 23.5, :scope => ["test_theme1", @locator_theme, @topic_theme])
1034
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
1035
+ @occ.type.should == @tm.get("Age")
1036
+ @occ.datatype.to_external_form.should == RTM::PSI[:Float]
1037
+ @occ.value.should == "23.5"
1038
+ end
1039
+ it "should create an occurrence if type is a String and value is a Fixum" do
1040
+ @occ = @topic.create_occurrence("Age", 23, :scope => ["test_theme1", @locator_theme, @topic_theme])
1041
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
1042
+ @occ.type.should == @tm.get("Age")
1043
+ @occ.datatype.to_external_form.should == RTM::PSI[:Long]
1044
+ @occ.value.should == "23"
1045
+ end
1046
+ it "should create an occurrence if type is a String and value is Bignum" do
1047
+ number = 9999999999999999999
1048
+ number.class.should == Bignum
1049
+ @occ = @topic.create_occurrence("Age", number, :scope => ["test_theme1", @locator_theme, @topic_theme])
1050
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
1051
+ @occ.type.should == @tm.get("Age")
1052
+ @occ.datatype.to_external_form.should == RTM::PSI[:Integer]
1053
+ @occ.value.should == number.to_s
1054
+ end
1055
+ it "should create an occurrence if type is a Locator and value is a String" do
1056
+ @occ = @topic.create_occurrence(@tm.create_locator("birthplace"), "Leipzig", :scope => ["test_theme1", @locator_theme, @topic_theme])
1057
+ @tm.get("birthplace").should be_a_kind_of(RTM::Topic)
1058
+ @occ.type.should == @tm.get("birthplace")
1059
+ @occ.value.should == "Leipzig"
1060
+ @occ.datatype.should == @tm.create_locator(RTM::PSI[:String])
1061
+ end
1062
+ it "should create an occurrence if type is a Locator and value is an IRI" do
1063
+ @occ = @topic.create_occurrence(@tm.create_locator("Website"), @tm.create_locator("http://www.example.org/uni-leipzig"), :scope => ["test_theme1", @locator_theme, @topic_theme])
1064
+ @tm.get("Website").should be_a_kind_of(RTM::Topic)
1065
+ @occ.type.should == @tm.get("Website")
1066
+ @occ.value.should == "http://www.example.org/uni-leipzig"
1067
+ @occ.datatype.should == @tm.create_locator(RTM::PSI[:IRI])
1068
+ end
1069
+ it "should create an occurrnce if type is a Locator and value is a Float" do
1070
+ @occ = @topic.create_occurrence(@tm.create_locator("Age"), 23.5, :scope => ["test_theme1", @locator_theme, @topic_theme])
1071
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
1072
+ @occ.type.should == @tm.get("Age")
1073
+ @occ.datatype.to_external_form.should == RTM::PSI[:Float]
1074
+ @occ.value.should == "23.5"
1075
+ end
1076
+ it "should create an occurrence if type is a Locator and value is a Fixum" do
1077
+ @occ = @topic.create_occurrence(@tm.create_locator("Age"), 23, :scope => ["test_theme1", @locator_theme, @topic_theme])
1078
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
1079
+ @occ.type.should == @tm.get("Age")
1080
+ @occ.datatype.to_external_form.should == RTM::PSI[:Long]
1081
+ @occ.value.should == "23"
1082
+ end
1083
+ it "should create an occurrence if type is a Locator and value is Bignum" do
1084
+ number = 9999999999999999999
1085
+ number.class.should == Bignum
1086
+ @occ = @topic.create_occurrence(@tm.create_locator("Age"), number, :scope => ["test_theme1", @locator_theme, @topic_theme])
1087
+ @tm.get("Age").should be_a_kind_of(RTM::Topic)
1088
+ @occ.type.should == @tm.get("Age")
1089
+ @occ.datatype.to_external_form.should == RTM::PSI[:Integer]
1090
+ @occ.value.should == number.to_s
1091
+ end
1092
+ it "should create an occurrence if type is a Topic and value is a String" do
1093
+ type = @tm.get!("Website")
1094
+ @occ = @topic.create_occurrence(type, "http://www.example.org/uni-leipzig", :scope => ["test_theme1", @locator_theme, @topic_theme])
1095
+ @occ.type.should == type
1096
+ @occ.datatype.to_external_form.should == RTM::PSI[:String]
1097
+ @occ.value.should == "http://www.example.org/uni-leipzig"
1098
+ end
1099
+ it "should create an occurrence if type is a Topic and value is an IRI" do
1100
+ type = @tm.get!("Website")
1101
+ @occ = @topic.create_occurrence(type, @tm.create_locator("http://www.example.org/uni-leipzig"), :scope => ["test_theme1", @locator_theme, @topic_theme])
1102
+ @occ.type.should == type
1103
+ @occ.datatype.to_external_form.should == RTM::PSI[:IRI]
1104
+ @occ.value.should == "http://www.example.org/uni-leipzig"
1105
+ end
1106
+ it "should create an occurrnce if type is a Topic and value is a Float" do
1107
+ type = @tm.get!("Age")
1108
+ @occ = @topic.create_occurrence(type, 23.5, :scope => ["test_theme1", @locator_theme, @topic_theme])
1109
+ @occ.type.should == type
1110
+ @occ.datatype.to_external_form.should == RTM::PSI[:Float]
1111
+ @occ.value.should == "23.5"
1112
+ end
1113
+ it "should create an occurrence if type is a Topic and value is a Fixum" do
1114
+ type = @tm.get!("Age")
1115
+ @occ = @topic.create_occurrence(type, 23, :scope => ["test_theme1", @locator_theme, @topic_theme])
1116
+ @occ.type.should == type
1117
+ @occ.datatype.to_external_form.should == RTM::PSI[:Long]
1118
+ @occ.value.should == "23"
1119
+ end
1120
+ it "should create an occurrence if type is a Topic and value is Bignum" do
1121
+ number = 9999999999999999999
1122
+ number.class.should == Bignum
1123
+ type = @tm.get!("Age")
1124
+ @occ = @topic.create_occurrence(type, number, :scope => ["test_theme1", @locator_theme, @topic_theme])
1125
+ @occ.type.should == type
1126
+ @occ.datatype.to_external_form.should == RTM::PSI[:Integer]
1127
+ @occ.value.should == number.to_s
1128
+ end
1129
+ end
1130
+ end
1131
+ describe "given type, value, datatype and scope" do
1132
+ it "should be tested"
657
1133
  end
658
1134
  end #of describe "#create_occurrences"
659
1135
 
660
1136
  describe "#add_subject_identifier" do
661
1137
  before(:each) do
662
- @ii_1 = "http://www.specs.de/ii_1"
663
- @ii_2 = "http://www.specs.de/ii_2"
664
- @si_1 = "http://www.specs.de/si_1"
665
- @si_2 = "http://www.specs.de/si_2"
666
- @sl_1 = "http://www.specs.de/sl_1"
667
- @sl_2 = "http://www.specs.de/sl_2"
1138
+ @ii_1 = "http://www.example.org/ii_1"
1139
+ @ii_2 = "http://www.example.org/ii_2"
1140
+ @si_1 = "http://www.example.org/si_1"
1141
+ @si_2 = "http://www.example.org/si_2"
1142
+ @sl_1 = "http://www.example.org/sl_1"
1143
+ @sl_2 = "http://www.example.org/sl_2"
668
1144
  end
669
1145
  it "should add an identifier as subject identifier if the topic already has another si" do
670
1146
  topic = @tm.get!("si:" + @si_1)
@@ -715,32 +1191,32 @@ module RTM::Topic
715
1191
  end
716
1192
  it "should do what? if the topic already has this identifier as sl"
717
1193
  it "should merge the topic A with another topic B that has the same identifier as ii or si when adding this identifier to A, but throws an exception" do
718
- topic_a = @tm.get!("ii:" + @ii_1)
719
- topic_b = @tm.get!("ii:" + @ii_2)
720
- lambda{topic_a.add_subject_identifier(@ii_2)}.should raise_error
1194
+ topicA = @tm.get!("ii:" + @ii_1)
1195
+ topicB = @tm.get!("ii:" + @ii_2)
1196
+ lambda{topicA.add_subject_identifier(@ii_2)}.should raise_error
721
1197
  end
722
1198
  end # of describe add_subject_indentifier
723
1199
 
724
1200
  describe "#add_item_identifier" do
725
1201
  before(:each) do
726
- @ii_1 = "http://www.specs.de/ii_1"
727
- @ii_2 = "http://www.specs.de/ii_2"
728
- @si_1 = "http://www.specs.de/si_1"
729
- @si_2 = "http://www.specs.de/si_2"
730
- @sl_1 = "http://www.specs.de/sl_1"
731
- @sl_2 = "http://www.specs.de/sl_2"
1202
+ @ii_1 = "http://www.example.org/ii_1"
1203
+ @ii_2 = "http://www.example.org/ii_2"
1204
+ @si_1 = "http://www.example.org/si_1"
1205
+ @si_2 = "http://www.example.org/si_2"
1206
+ @sl_1 = "http://www.example.org/sl_1"
1207
+ @sl_2 = "http://www.example.org/sl_2"
732
1208
  end
733
1209
  it "should be tested"
734
1210
  end #of describe add_item_identifier
735
1211
 
736
1212
  describe "#add_subject_locator" do
737
1213
  before(:each) do
738
- @ii_1 = "http://www.specs.de/ii_1"
739
- @ii_2 = "http://www.specs.de/ii_2"
740
- @si_1 = "http://www.specs.de/si_1"
741
- @si_2 = "http://www.specs.de/si_2"
742
- @sl_1 = "http://www.specs.de/sl_1"
743
- @sl_2 = "http://www.specs.de/sl_2"
1214
+ @ii_1 = "http://www.example.org/ii_1"
1215
+ @ii_2 = "http://www.example.org/ii_2"
1216
+ @si_1 = "http://www.example.org/si_1"
1217
+ @si_2 = "http://www.example.org/si_2"
1218
+ @sl_1 = "http://www.example.org/sl_1"
1219
+ @sl_2 = "http://www.example.org/sl_2"
744
1220
  end
745
1221
  it "should be tested"
746
1222
  end # of describe add_subject_locator