rtm 0.1.6 → 0.2

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 (163) hide show
  1. data/DISCLAIMER +10 -33
  2. data/LICENSE +201 -0
  3. data/README +32 -3
  4. data/lib/rtm.rb +126 -74
  5. data/lib/rtm/axes.rb +298 -0
  6. data/lib/rtm/axes/association.rb +76 -0
  7. data/lib/rtm/axes/associations.rb +96 -0
  8. data/lib/rtm/axes/assocs_names_occs.rb +56 -0
  9. data/lib/rtm/axes/characteristic.rb +68 -0
  10. data/lib/rtm/axes/characteristics.rb +93 -0
  11. data/lib/rtm/axes/string.rb +76 -0
  12. data/lib/rtm/axes/strings.rb +87 -0
  13. data/lib/rtm/axes/topic.rb +233 -0
  14. data/lib/rtm/axes/topics.rb +280 -0
  15. data/lib/rtm/{backward_compatibility.rb → deprecated/index_property_set.rb} +3 -0
  16. data/lib/rtm/engine.rb +101 -0
  17. data/lib/rtm/extensions.rb +65 -5
  18. data/lib/rtm/{locator_helpers.rb → helpers/locator.rb} +15 -4
  19. data/lib/rtm/{helpers.rb → helpers/no_output.rb} +3 -0
  20. data/lib/rtm/helpers/uri.rb +13 -0
  21. data/lib/rtm/io.rb +19 -0
  22. data/lib/rtm/io/from_xtm2_libxml.rb +2 -1
  23. data/lib/rtm/io/tmapix_from.rb +155 -0
  24. data/lib/rtm/io/tmapix_to.rb +223 -0
  25. data/lib/rtm/io/to_hash.rb +154 -0
  26. data/lib/rtm/io/to_jtm.rb +53 -103
  27. data/lib/rtm/io/to_rdf.rb +45 -0
  28. data/lib/rtm/io/to_string.rb +21 -8
  29. data/lib/rtm/io/to_xtm1.rb +6 -4
  30. data/lib/rtm/io/to_xtm2.rb +10 -8
  31. data/lib/rtm/io/to_yaml.rb +59 -100
  32. data/lib/rtm/navigation.rb +23 -0
  33. data/lib/rtm/navigation/association/players.rb +25 -0
  34. data/lib/rtm/navigation/name/atomify.rb +19 -0
  35. data/lib/rtm/navigation/name/characteristics.rb +33 -0
  36. data/lib/rtm/navigation/occurrence/atomify.rb +19 -0
  37. data/lib/rtm/navigation/occurrence/characteristics.rb +33 -0
  38. data/lib/rtm/navigation/topic/characteristics.rb +33 -0
  39. data/lib/rtm/navigation/topic/indicators.rb +31 -0
  40. data/lib/rtm/navigation/topic/items.rb +31 -0
  41. data/lib/rtm/navigation/topic/locators.rb +31 -0
  42. data/lib/rtm/navigation/topic/players.rb +27 -0
  43. data/lib/rtm/navigation/topic/supertypes.rb +166 -0
  44. data/lib/rtm/navigation/topic/traverse.rb +51 -0
  45. data/lib/rtm/navigation/topic/types.rb +109 -0
  46. data/lib/rtm/psi.rb +39 -2
  47. data/lib/rtm/sugar.rb +47 -0
  48. data/lib/rtm/sugar/association/hash_access.rb +46 -0
  49. data/lib/rtm/sugar/occurrence/dynamic_value.rb +58 -0
  50. data/lib/rtm/sugar/occurrence/external.rb +53 -0
  51. data/lib/rtm/sugar/reifiable/reifier.rb +21 -0
  52. data/lib/rtm/sugar/role/counterparts.rb +139 -46
  53. data/lib/rtm/sugar/topic/best_name.rb +74 -0
  54. data/lib/rtm/sugar/topic/characteristics.rb +126 -12
  55. data/lib/rtm/sugar/topic/counterparts.rb +145 -10
  56. data/lib/rtm/sugar/topic/hash_access.rb +140 -30
  57. data/lib/rtm/sugar/topic/scoped.rb +114 -0
  58. data/lib/rtm/sugar/topic/topic_ref.rb +86 -0
  59. data/lib/rtm/sugar/topic/typed.rb +207 -0
  60. data/lib/rtm/sugar/topic_map/query_cache.rb +66 -0
  61. data/lib/rtm/sugar/topic_map/themes.rb +53 -0
  62. data/lib/rtm/sugar/typed/types.rb +38 -0
  63. data/lib/rtm/validation.rb +7 -4
  64. data/lib/rtm/version.rb +30 -0
  65. data/spec/helpers/spec_exampleexamplegroup.rb +14 -0
  66. data/spec/rtm/axes/association_spec.rb +88 -0
  67. data/spec/rtm/axes/associations_spec.rb +60 -0
  68. data/spec/rtm/axes/assocs_names_occs_spec.rb +9 -0
  69. data/spec/rtm/axes/characteristic_spec.rb +90 -0
  70. data/spec/rtm/axes/characteristics_spec.rb +85 -0
  71. data/spec/rtm/axes/string_spec.rb +145 -0
  72. data/spec/rtm/axes/strings_spec.rb +168 -0
  73. data/spec/rtm/axes/topic_spec.rb +124 -0
  74. data/spec/rtm/axes/topics_spec.rb +103 -0
  75. data/spec/rtm/base_spec.rb +32 -0
  76. data/spec/rtm/io/tmapix_from_spec.rb +76 -0
  77. data/spec/rtm/io/tmapix_to_spec.rb +159 -0
  78. data/spec/rtm/io/to_hash_spec.rb +90 -0
  79. data/spec/rtm/io/to_rdf_spec.rb +37 -0
  80. data/spec/rtm/io/to_string_spec.rb +122 -0
  81. data/spec/rtm/io/to_yaml_spec.rb +89 -0
  82. data/spec/rtm/navigation/association/players_spec.rb +58 -0
  83. data/spec/rtm/navigation/association_spec.rb +52 -0
  84. data/spec/rtm/navigation/name/atomify_spec.rb +27 -0
  85. data/spec/rtm/navigation/name/characteristics_spec.rb +34 -0
  86. data/spec/rtm/navigation/name_spec.rb +52 -0
  87. data/spec/rtm/navigation/occurrence/atomify_spec.rb +27 -0
  88. data/spec/rtm/navigation/occurrence/characteristics_spec.rb +34 -0
  89. data/spec/rtm/navigation/occurrence_spec.rb +52 -0
  90. data/spec/rtm/navigation/string_spec.rb +51 -0
  91. data/spec/rtm/navigation/topic/characteristics_spec.rb +55 -0
  92. data/spec/rtm/navigation/topic/indicators_spec.rb +43 -0
  93. data/spec/rtm/navigation/topic/items_spec.rb +44 -0
  94. data/spec/rtm/navigation/topic/locators_spec.rb +44 -0
  95. data/spec/rtm/navigation/topic/players_spec.rb +48 -0
  96. data/spec/rtm/navigation/topic/scope_spec.rb +41 -0
  97. data/spec/rtm/navigation/topic/supertypes_spec.rb +376 -0
  98. data/spec/rtm/navigation/topic/traverse_spec.rb +64 -0
  99. data/spec/rtm/navigation/topic/types_spec.rb +195 -0
  100. data/spec/rtm/navigation/topic_spec.rb +153 -0
  101. data/spec/rtm/sugar/association/hash_access_spec.rb +55 -0
  102. data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +171 -0
  103. data/spec/rtm/sugar/occurrence/external_spec.rb +129 -0
  104. data/spec/rtm/sugar/reifiable/reifier_spec.rb +41 -0
  105. data/spec/rtm/sugar/role/counterparts_spec.rb +193 -0
  106. data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
  107. data/spec/rtm/sugar/topic/characteristics_spec.rb +333 -0
  108. data/spec/rtm/sugar/topic/counterparts_spec.rb +224 -0
  109. data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
  110. data/spec/rtm/sugar/topic/scoped_spec.rb +195 -0
  111. data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
  112. data/spec/rtm/sugar/topic/typed_spec.rb +217 -0
  113. data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
  114. data/spec/rtm/sugar/typed/types_spec.rb +24 -0
  115. data/spec/rtm/tmapi/core/association_spec.rb +169 -0
  116. data/spec/rtm/tmapi/core/construct_spec.rb +25 -0
  117. data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
  118. data/spec/rtm/tmapi/core/name_spec.rb +270 -0
  119. data/spec/rtm/tmapi/core/occurrence_spec.rb +53 -0
  120. data/spec/rtm/tmapi/core/reifiable_spec.rb +168 -0
  121. data/spec/rtm/tmapi/core/role_spec.rb +73 -0
  122. data/spec/rtm/tmapi/core/scoped_spec.rb +441 -0
  123. data/spec/rtm/tmapi/core/topic_map_spec.rb +716 -0
  124. data/spec/rtm/tmapi/core/topic_spec.rb +1468 -0
  125. data/spec/rtm/tmapi/core/typed_spec.rb +112 -0
  126. data/spec/rtm/tmapi/core/variant_spec.rb +52 -0
  127. data/spec/rtm/tmapi/ext/java_util_set_spec.rb +34 -0
  128. data/spec/rtm/tmapi_spec.rb +44 -0
  129. data/spec/rtm/utils/sparql_spec.rb +26 -0
  130. data/spec/rtm_spec.rb +93 -0
  131. data/spec/spec_helper.rb +28 -0
  132. data/test/javalibs/junit-4.5.jar +0 -0
  133. data/test/javalibs/tmapi-2.0-tests.jar +0 -0
  134. data/test/tmapi_tests.rb +25 -0
  135. metadata +169 -65
  136. data/COPYRIGHT +0 -4
  137. data/lib/Rakefile.rb +0 -42
  138. data/lib/activetopicmaps.rb +0 -278
  139. data/lib/rtm/backend/active_record.rb +0 -58
  140. data/lib/rtm/backend/active_record/001_initial_schema.rb +0 -116
  141. data/lib/rtm/backend/active_record/association_and_role.rb +0 -33
  142. data/lib/rtm/backend/active_record/locators.rb +0 -55
  143. data/lib/rtm/backend/active_record/name_variant_occurrence.rb +0 -45
  144. data/lib/rtm/backend/active_record/quaaxtm2rtm.rb +0 -113
  145. data/lib/rtm/backend/active_record/quaaxtm2rtmviews.rb +0 -134
  146. data/lib/rtm/backend/active_record/set_wrapper.rb +0 -98
  147. data/lib/rtm/backend/active_record/tm_construct.rb +0 -62
  148. data/lib/rtm/backend/active_record/tm_delegator.rb +0 -345
  149. data/lib/rtm/backend/active_record/tm_set_delegator.rb +0 -195
  150. data/lib/rtm/backend/active_record/tmdm.rb +0 -298
  151. data/lib/rtm/backend/active_record/topic.rb +0 -87
  152. data/lib/rtm/backend/active_record/topic_map.rb +0 -314
  153. data/lib/rtm/backend/active_record/traverse_associations.rb +0 -87
  154. data/lib/rtm/base.rb +0 -92
  155. data/lib/rtm/connect.rb +0 -92
  156. data/lib/rtm/core_ext.rb +0 -6
  157. data/lib/rtm/io/from_xtm2.rb +0 -263
  158. data/lib/rtm/merging/merging.rb +0 -307
  159. data/lib/rtm/pimp_my_api.rb +0 -28
  160. data/lib/rtm/sugar/topic/identifier_direct.rb +0 -11
  161. data/lib/rtm/sugar/topic/predefined_associations.rb +0 -42
  162. data/lib/run_main_project.rb +0 -16
  163. data/test/base_test.rb +0 -162
@@ -0,0 +1,217 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../../spec_helper'
5
+
6
+ module RTM::Sugar::Topic
7
+ module Typed
8
+ describe self do
9
+ before(:each) do
10
+ @tm = get_used_tm_sys_tm
11
+ @type0 = @tm.get!("negative")
12
+ @default_name_type = @tm.get!(RTM::PSI[:name_type])
13
+ @dummy_type = @tm.get!("dummy_type")
14
+ @container = @tm.get!("container")
15
+ @containee = @tm.get!("containee")
16
+ @contained = @tm.get!("contained")
17
+ @leipzig = @tm.get!("leipzig")
18
+ @germany = @tm.get!("germany")
19
+ @dummy = @tm.get!("dummy")
20
+ @name1 = @leipzig.create_name(@dummy_type, "Leipzig")
21
+ @name2 = @germany.create_name("Germany")
22
+ @name3 = @germany.create_name("Deutschland")
23
+ @name4 = @leipzig.create_name("Leipzisch")
24
+ @name5 = @leipzig.create_name("Lipsk")
25
+ @occ1 = @leipzig.create_occurrence("inhabitants","500000")
26
+ @occ2 = @germany.create_occurrence("states","16")
27
+ @occ3 = @leipzig.create_occurrence("state","Sachsen")
28
+ @occ2 = @germany.create_occurrence(@dummy_type,"0")
29
+ @assoc1 = @tm.create_association(@dummy_type,["assoc_dummy"])
30
+ @assoc2 = @tm.create_association(@contained)
31
+ @role1 = @assoc2.create_role(@containee,@leipzig)
32
+ @role2 = @assoc2.create_role(@container,@germany)
33
+ @dummy_role = @assoc1.create_role(@dummy_type,@dummy)
34
+ end
35
+ after(:each) do
36
+ @tm.close
37
+ end
38
+
39
+ describe "#typed" do
40
+ it "should give back all constructs which have this Topic as type" do
41
+ @default_name_type.typed.size.should == 4
42
+ @default_name_type.typed.should include(@name2)
43
+ @default_name_type.typed.should include(@name3)
44
+ @default_name_type.typed.should include(@name4)
45
+ @default_name_type.typed.should include(@name5)
46
+ @container.typed.size.should == 1
47
+ @container.typed.should include(@role2)
48
+ @containee.typed.size.should == 1
49
+ @containee.typed.should include(@role1)
50
+ @contained.typed.size.should == 1
51
+ @contained.typed.should include(@assoc2)
52
+ @dummy_type.typed.size.should == 4
53
+ @dummy_type.typed.should include(@name1)
54
+ @dummy_type.typed.should include(@occ2)
55
+ @dummy_type.typed.should include(@assoc1)
56
+ @dummy_type.typed.should include(@dummy_role)
57
+ end
58
+ it "should give back an empty Array if there are no Constructs which have this Topic as type" do
59
+ @type0.typed.should be_empty
60
+ end
61
+ end
62
+
63
+ describe "#typed_associations" do
64
+ it "should give back all Associations which have this Topic as type" do
65
+ @default_name_type.typed_associations.should be_empty
66
+ @container.typed_associations.should be_empty
67
+ @containee.typed_associations.should be_empty
68
+ @contained.typed_associations.size.should == 1
69
+ @contained.typed_associations.should include(@assoc2)
70
+ @dummy_type.typed_associations.size.should == 1
71
+ @dummy_type.typed_associations.should include(@assoc1)
72
+ end
73
+ it "should give back an empty Array if there are no Associations which have this Topic as type" do
74
+ @type0.typed_associations.should be_empty
75
+ end
76
+ end
77
+
78
+ describe "#typed_names" do
79
+ it "should give back all Names which have this Topic as type" do
80
+ @default_name_type.typed_names.size.should == 4
81
+ @default_name_type.typed_names.should include(@name2)
82
+ @default_name_type.typed_names.should include(@name3)
83
+ @default_name_type.typed_names.should include(@name4)
84
+ @default_name_type.typed_names.should include(@name5)
85
+ @container.typed_names.should be_empty
86
+ @containee.typed_names.should be_empty
87
+ @contained.typed_names.should be_empty
88
+ @dummy_type.typed_names.size.should == 1
89
+ @dummy_type.typed_names.should include(@name1)
90
+ end
91
+ it "should give back an empty Array if there are no Names which have this Topic as type" do
92
+ @type0.typed_names.should be_empty
93
+ end
94
+ end
95
+
96
+ describe "#typed_occurrences" do
97
+ it "should give back all Occurrences which have this Topic as type" do
98
+ @default_name_type.typed_occurrences.should be_empty
99
+ @container.typed_occurrences.should be_empty
100
+ @containee.typed_occurrences.should be_empty
101
+ @contained.typed_occurrences.should be_empty
102
+ @dummy_type.typed_occurrences.size.should == 1
103
+ @dummy_type.typed_occurrences.should include(@occ2)
104
+ end
105
+ it "should give back an empty Array if there are no Occurrences which have this Topic as type" do
106
+ @type0.typed_occurrences.should be_empty
107
+ end
108
+ end
109
+
110
+ describe "#typed_roles" do
111
+ it "should give back all Roles which have this Topic as type" do
112
+ @default_name_type.typed_roles.should be_empty
113
+ @container.typed_roles.size.should == 1
114
+ @container.typed_roles.should include(@role2)
115
+ @containee.typed_roles.size.should == 1
116
+ @containee.typed_roles.should include(@role1)
117
+ @contained.typed_roles.should be_empty
118
+ @dummy_type.typed_roles.size.should == 1
119
+ @dummy_type.typed_roles.should include(@dummy_role)
120
+ end
121
+ it "should give back an empty Array if there are no Roles which have this Topic as type" do
122
+ @type0.typed_roles.should be_empty
123
+ end
124
+ end
125
+
126
+ describe "#topic_is_a?" do
127
+ before(:each) do
128
+ @t1, @t2, @t3, @t4, @t5 = @tm.get!(["t1", "t2", "t3", "t4", "t5"])
129
+ @t1.add_types(@t1, @t2)
130
+ @t1.add_instance(@t3)
131
+ @t2.add_supertype(@t4)
132
+ @t4.add_supertype(@t5)
133
+ end
134
+ it "give back true, if the argument is a type of this topic" do
135
+ @t1.topic_is_a?(@t1).should be_true
136
+ @t1.topic_is_a?("t2").should be_true
137
+ end
138
+ it "should give back false, if the argument is no type of this topic" do
139
+ @t1.topic_is_a?(@t3).should be_false
140
+ end
141
+ it "should give back false, if the argument is not a topic in the topic map" do
142
+ @t1.topic_is_a?("t6").should be_false
143
+ end
144
+ it "should give back true, if the argument is a supertype of the type of this topic" do
145
+ @t1.topic_is_a?(@t4).should be_true
146
+ @t1.topic_is_a?("t5").should be_true
147
+ end
148
+ end
149
+
150
+
151
+ describe "#used_as_type?" do
152
+ it "should give back true if this topic is used as type in a scope" do
153
+ @default_name_type.used_as_type?.should be_true
154
+ @dummy_type.used_as_type?.should be_true
155
+ @contained.used_as_type?.should be_true
156
+ @tm.get("inhabitants").used_as_type?.should be_true
157
+ @tm.get("states").used_as_type?.should be_true
158
+ @tm.get("state").used_as_type?.should be_true
159
+ @containee.used_as_type?.should be_true
160
+ @container.used_as_type?.should be_true
161
+ end
162
+ it "should give back false if this topic is not used as type in a scope" do
163
+ @type0.used_as_type?.should be_false
164
+ end
165
+ end
166
+
167
+ describe "#used_as_association_type?" do
168
+ it "should give back true if this topic is used as type in a scope of an association" do
169
+ @dummy_type.used_as_association_type?.should be_true
170
+ @contained.used_as_association_type?.should be_true
171
+ end
172
+ it "should give back false if this topic is not used as type in a scope of an association" do
173
+ @default_name_type.used_as_association_type?.should be_false
174
+ @type0.used_as_association_type?.should be_false
175
+ end
176
+ end
177
+
178
+ describe "#used_as_name_type?" do
179
+ it "should give back true if this topic is used as type in a scope of a name" do
180
+ @default_name_type.used_as_name_type?.should be_true
181
+ @dummy_type.used_as_name_type?.should be_true
182
+
183
+ end
184
+ it "should give back false if this topic is not used as type in a scope of a name" do
185
+ @type0.used_as_name_type?.should be_false
186
+ end
187
+ end
188
+
189
+ describe "#used_as_occurrence_type?" do
190
+ it "should give back true if this topic is used as type in a scope of an occurrence" do
191
+ @dummy_type.used_as_occurrence_type?.should be_true
192
+ @tm.get("inhabitants").used_as_occurrence_type?.should be_true
193
+ @tm.get("states").used_as_occurrence_type?.should be_true
194
+ @tm.get("state").used_as_occurrence_type?.should be_true
195
+ end
196
+ it "should give back false if this topic is not used as type in a scope of an occurrence" do
197
+ @default_name_type.used_as_occurrence_type?.should be_false
198
+ @type0.used_as_occurrence_type?.should be_false
199
+ end
200
+ end
201
+
202
+ describe "#used_as_role_type?" do
203
+ it "should give back true if this topic is used as type in a scope of a role" do
204
+ @dummy_type.used_as_role_type?.should be_true
205
+ @containee.used_as_role_type?.should be_true
206
+ @container.used_as_role_type?.should be_true
207
+ end
208
+ it "should give back false if this topic is not used as type in a scope of a role" do
209
+ @default_name_type.used_as_role_type?.should be_false
210
+ @type0.used_as_role_type?.should be_false
211
+ end
212
+ end
213
+
214
+ end #of describe self
215
+
216
+ end
217
+ end
@@ -0,0 +1,67 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../../spec_helper'
5
+
6
+ module RTM::Sugar::TopicMap
7
+ module Themes
8
+ describe self do
9
+ before(:each) do
10
+ @tm = get_used_tm_sys_tm
11
+ @theme0 = @tm.get!("negative")
12
+ @theme1 = @tm.get!("german")
13
+ @theme2 = @tm.get!("english")
14
+ @theme3 = @tm.get!("2009")
15
+ @theme4 = @tm.get!("sorbian")
16
+ @test_theme = @tm.get!("dummy")
17
+ @leipzig = @tm.get!("leipzig")
18
+ @germany = @tm.get!("germany")
19
+ @name1 = @leipzig.create_name("Leipzig",[@theme1,@theme2])
20
+ @name2 = @germany.create_name("Germany",[@theme2,@test_theme])
21
+ @name3 = @germany.create_name("Deutschland",[@theme1])
22
+ @name4 = @leipzig.create_name("Leipzisch")
23
+ @name5 = @leipzig.create_name("Lipsk",[@theme4])
24
+ @occ1 = @leipzig.create_occurrence("inhabitants","500000", :scope => [@theme3])
25
+ @occ2 = @germany.create_occurrence("states","16", :scope => [@test_theme])
26
+ @occ3 = @leipzig.create_occurrence("state","Sachsen")
27
+ @tm.create_association("assoc_dummy")
28
+ @assoc = @tm.create_association("contained", [@test_theme])
29
+ @role1 = @assoc.create_role("containee",@leipzig)
30
+ @role2 = @assoc.create_role("container",@germany)
31
+ @variant = @name1.create_variant("LE",[@test_theme])
32
+ end
33
+ after(:each) do
34
+ @tm.close
35
+ end
36
+
37
+ describe "#association_themes" do
38
+ it "return all topics that are used in the scope of Associations" do
39
+ @tm.should have(1).association_themes
40
+ @tm.association_themes.should include(@test_theme)
41
+ end
42
+ end
43
+
44
+ describe "#name_themes" do
45
+ it "return all topics that are used in the scope of Names" do
46
+ @tm.should have(4).name_themes
47
+ @tm.name_themes.should include(@theme1, @theme2, @test_theme, @theme4)
48
+ end
49
+ end
50
+
51
+ describe "#occurrence_themes" do
52
+ it "return all topics that are used in the scope of Occurrences" do
53
+ @tm.should have(2).occurrence_themes
54
+ @tm.occurrence_themes.should include(@theme3, @test_theme)
55
+ end
56
+ end
57
+
58
+ describe "#variant_themes" do
59
+ it "return all topics that are used in the scope of Variants" do
60
+ @tm.should have(3).variant_themes
61
+ @tm.variant_themes.should include(@theme1, @theme2, @test_theme)
62
+ end
63
+ end
64
+
65
+ end # of describe self
66
+ end # of module
67
+ end # of module
@@ -0,0 +1,24 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../../spec_helper'
5
+
6
+ module RTM::Sugar::Typed::Types
7
+ describe self do
8
+ before(:each) do
9
+ @tm = get_used_tm_sys_tm
10
+ end
11
+ after(:each) do
12
+ @tm.close
13
+ end
14
+
15
+ describe "#types" do
16
+ it "should be tested"
17
+ end
18
+
19
+ describe "#transitive_types" do
20
+ it "should be tested"
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,169 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../../spec_helper'
5
+
6
+ module RTM::Association
7
+ describe self do
8
+ before(:each) do
9
+ @tm = get_used_tm_sys_tm
10
+ @asso = @tm.create_association("a_type")
11
+ end
12
+ after(:each) do
13
+ @tm.close
14
+ end
15
+
16
+ describe "#role_types" do
17
+ it "should give back all types of the roles on a association" do
18
+ @asso.create_role("a_type_1","a_player")
19
+ @asso.role_types.include?(@tm.get("a_type_1")).should be_true
20
+ end
21
+ end
22
+
23
+ describe "#create_role" do
24
+ it "should allow to create a role using a String-reference" do
25
+ asso = @tm.create_association("a_type")
26
+ role1 = asso.create_role("type1", "player1")
27
+ type2 = @tm.get!("type2")
28
+ player2 = @tm.get!("player2")
29
+ role2 = asso.create_role("type2", "player2")
30
+ role1.should be_a_kind_of RTM::Role
31
+ role2.should be_a_kind_of RTM::Role
32
+ @tm.get("type1").should be_a_kind_of RTM::Topic
33
+ @tm.get("player1").should be_a_kind_of RTM::Topic
34
+ @tm.get("player1").roles(@tm.get("type1")).size.should == 1
35
+ player2.roles(type2).size.should == 1
36
+ asso.roles.size.should == 2
37
+ asso.roles(@tm.get("type1")).size.should == 1
38
+ asso.roles(type2).size.should == 1
39
+ end
40
+ it "should allow to create a role using Topics" do
41
+ asso = @tm.create_association("a_type")
42
+ type = @tm.get!("type")
43
+ player = @tm.get!("player")
44
+ type.should be_a_kind_of RTM::Topic
45
+ player.should be_a_kind_of RTM::Topic
46
+ role = asso.create_role(type, player)
47
+ role.should be_a_kind_of RTM::Role
48
+ player.roles(type).size.should == 1
49
+ asso.roles.size.should == 1
50
+ asso.roles(type).size.should == 1
51
+ asso.roles(type).should include(role)
52
+ player.roles(type).size.should == 1
53
+ end
54
+ it "should allow to create a role using Locators" do
55
+ asso = @tm.create_association("a_type")
56
+ loc1 = @tm.create_locator("type")
57
+ loc2 = @tm.create_locator("player")
58
+ loc1.should be_a_kind_of RTM::Locator
59
+ loc2.should be_a_kind_of RTM::Locator
60
+ role = asso.create_role(loc1,loc2)
61
+ role.should be_a_kind_of RTM::Role
62
+ asso.roles.size.should == 1
63
+ asso.roles(@tm.get(loc1)).size.should == 1
64
+ asso.roles(@tm.get(loc1)).should include(role)
65
+ @tm.get(loc2).roles(@tm.get(loc1)).size.should == 1
66
+ @tm.get(loc2).roles(@tm.get(loc1)).should include(role)
67
+ end
68
+ end
69
+
70
+ describe "#parent" do
71
+ it "should give back the TopicMap the Association belongs to" do
72
+ testassoc = @tm.create_association("Haus-Nummer-Beziehung")
73
+ testassoc.should be_a_kind_of RTM::Association
74
+ testassoc.parent.should == @tm
75
+ end
76
+ end
77
+
78
+ describe "#children" do
79
+ it "should return all Roles belonging to an Association" do
80
+ topic = @tm.create_topic_by("Haus")
81
+ topic_instance = @tm.create_topic_by("Weisses_Haus")
82
+ topic_instance2 = @tm.create_topic_by("Anderes_Haus")
83
+ testassoc = @tm.create_association("Haus-Nummer-Beziehung")
84
+
85
+ testrole = testassoc.create_role(topic, topic_instance) #TMAPI function
86
+ testrole2 = testassoc.create_role(topic, topic_instance2) #TMAPI function
87
+ testassoc.should be_a_kind_of RTM::Association
88
+ testrole.should be_a_kind_of RTM::Role
89
+ testrole2.should be_a_kind_of RTM::Role
90
+
91
+ testassoc.children.size.should == 2
92
+ testassoc.children.should include(testrole)
93
+ testassoc.children.should include(testrole2)
94
+ end
95
+ end
96
+
97
+ describe "#roles" do
98
+ it "should return an empty Set if the Association has no Roles" do
99
+ @asso.roles.should be_empty
100
+ @asso.roles.should_not be_nil
101
+ end
102
+ it "should return an empty Array if type is no Roletype of a Role in this Association" do
103
+ @asso.create_role("type1","player1")
104
+ @asso.create_role("type1","player2")
105
+ @asso.create_role("type2","player3")
106
+ other_asso = @tm.create_association("a_type")
107
+ other_asso.create_role("type3","player4")
108
+ @asso.roles("typex").should be_empty
109
+ @asso.roles(nil).should be_empty
110
+ @asso.roles("type3").should be_empty
111
+ end
112
+ it "should return the right Roles, also if type is a Topic, String-Reference or Locator" do
113
+ t_type1,t_type2,t_type3 = @tm.get!(["type1","type2","type3"])
114
+ t_player1,t_player2,t_player3,t_player4 = @tm.get!(["player1","player2","player3","player4"])
115
+ role1 = @asso.create_role(t_type1,t_player1)
116
+ role2 = @asso.create_role(t_type1,t_player2)
117
+ role3 = @asso.create_role(t_type2,t_player3)
118
+
119
+ other_asso = @tm.create_association("a_type")
120
+ role4 = other_asso.create_role(t_type3,t_player4)
121
+
122
+ @asso.roles.size.should == 3
123
+ @asso.roles.should include(role1)
124
+ @asso.roles.should include(role2)
125
+ @asso.roles.should include(role3)
126
+ other_asso.roles.size.should == 1
127
+ other_asso.roles.should include(role4)
128
+
129
+ @asso.roles("type1").size.should == 2
130
+ @asso.roles("type1").should include(role1)
131
+ @asso.roles("type1").should include(role2)
132
+ @asso.roles(t_type2).size.should == 1
133
+ @asso.roles(t_type2).should include(role3)
134
+
135
+ other_asso.roles(t_type3.references_as_locators.first).size.should == 1
136
+ other_asso.roles(t_type3.references_as_locators.first).should include(role4)
137
+ end
138
+ end
139
+ end # of describe self
140
+
141
+ describe self do
142
+
143
+ describe "#remove" do
144
+ before(:each) do
145
+ @tm = get_used_tm_sys_tm
146
+ @assoc1 = @tm.create_association("assoc1")
147
+ @assoc2 = @tm.create_association("assoc2")
148
+ @assoc3 = @tm.create_association("assoc1")
149
+ @assoc1.create_role("r1","topic1")
150
+ @assoc1.create_role("r2","topic2")
151
+ @tm.should have(3).associations
152
+ end
153
+ after(:each) do
154
+ @tm.close
155
+ end
156
+ it "should remove this assocition from the container (topic map)" do
157
+ @assoc1.remove
158
+ @tm.should have(2).associations
159
+ @tm.associations.should include @assoc2, @assoc3
160
+ @assoc2.remove
161
+ @tm.should have(1).associations
162
+ @tm.associations.should include @assoc3
163
+ @assoc3.remove
164
+ @tm.should have(0).associations
165
+ end
166
+ end
167
+
168
+ end # of describe self
169
+ end #of module