rtm 0.1.6 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
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,64 @@
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::Navigation::Topic
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
+ describe "#traverse" do
15
+ before(:each) do
16
+ @topic = @tm.get!("person")
17
+ @topic.add_supertype(@tm.get!("mensch"))
18
+ @topic.add_supertype(@tm.get!("wasanderes"))
19
+ @topic.add_subtype(@tm.get!("noch_wasanderes"))
20
+ asso = @tm.create_association("http://psi.topicmaps.org/smeasso")
21
+ asso["role1"] = @topic
22
+ asso["role2"] = @tm.get!("player2")
23
+ @tm.get!("something")
24
+ end
25
+ it "should give back an empty set if the Topic plays no Role in an Association" do
26
+ @tm.get!("something").traverse.should be_empty
27
+ end
28
+ it "should give back all the players of all Associations in which this Topic plays a Role" do
29
+ @topic.traverse.size.should == 4 #self deducted once for each association
30
+ @topic.traverse.should include(@tm.get("mensch"))
31
+ @topic.traverse.should include(@tm.get("wasanderes"))
32
+ @topic.traverse.should include(@tm.get("noch_wasanderes"))
33
+ @topic.traverse.should include(@tm.get("player2"))
34
+ end
35
+ it "should be constrainable with the optional item" do
36
+ @topic.traverse(RTM::PSI[:supertype_subtype]).size.should == 3
37
+ @topic.traverse(RTM::PSI[:supertype_subtype]).should include(@tm.get("mensch"))
38
+ @topic.traverse(RTM::PSI[:supertype_subtype]).should include(@tm.get("wasanderes"))
39
+ @topic.traverse(RTM::PSI[:supertype_subtype]).should include(@tm.get("noch_wasanderes"))
40
+ @topic.traverse("http://psi.topicmaps.org/wrong_type").should be_empty
41
+ @topic.traverse("http://psi.topicmaps.org/smeasso").size.should == 1
42
+ @topic.traverse("http://psi.topicmaps.org/smeasso").should include(@tm.get("player2"))
43
+ end
44
+ it "should give back an empty Array if the optional item is not included as Topic in the TopicMap" do
45
+ @tm.get("nothing").should be_nil
46
+ @topic.traverse("nothing").should be_empty
47
+ end
48
+ it "should give back an empty Array if the optional item exists as Topic in the TopicMap but is not an Association type" do
49
+ @tm.get("something").should be_a_kind_of RTM::Topic
50
+ @topic.traverse("something").should be_empty
51
+ end
52
+ describe "#reverse_traverse" do
53
+ it "should always give back an empty set" do
54
+ @tm.get!("nikolaus").add_supertype(@tm.get!("mensch"))
55
+ @tm.get!("nikolaus").add_supertype(@tm.get!("wasanderes"))
56
+ @tm.get!("nikolaus").add_subtype(@tm.get!("noch_wasanderes"))
57
+ @tm.get("nikolaus").reverse_traverse.should be_empty
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ end
64
+
@@ -0,0 +1,195 @@
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::Navigation::Topic
7
+ describe self do
8
+ before(:each) do
9
+ @tm = get_used_tm_sys_tm
10
+ @t1,@t2,@t3,@t4,@t5 = @tm.get!(["t1","t2","t3","t4","t5"])
11
+ @t1.add_type(@t3)
12
+ @t2.add_type(@t3)
13
+ @t2.add_type(@t4)
14
+ end
15
+ after(:each) do
16
+ @tm.close
17
+ end
18
+
19
+ describe "#types" do
20
+ it "should give back the types this Topic is an instance of" do
21
+ @t1.types.size.should == 1
22
+ @t1.types.should include(@t3)
23
+ @t2.types.size.should == 2
24
+ @t2.types.should include(@t3)
25
+ @t2.types.should include(@t4)
26
+ end
27
+ it "should give back an empty Set if Topic has no type" do
28
+ @t5.types.should be_empty
29
+ end
30
+ it "should never raise the error because type calls the TMAPI function" do
31
+ lambda{@t1.types}.should_not raise_error
32
+ end
33
+ end
34
+
35
+ describe "#type" do
36
+ it "should raise an error if this Topic has more than one type" do
37
+ @t2.types.size.should > 1
38
+ lambda{@t2.type}.should raise_error
39
+ end
40
+ it "should give back the type if this Topic is instance of exactly one type" do
41
+ @t1.type.should == @t3
42
+ end
43
+ it "should give back nil if this Topic has no type, aka is no instance" do
44
+ @t5.type.should be_nil
45
+ end
46
+ end
47
+
48
+ describe "#instances" do
49
+ it "schould give back the Instances of this Topic" do
50
+ @t3.instances.size.should == 2
51
+ @t3.instances.should include(@t1)
52
+ @t3.instances.should include(@t2)
53
+ @t4.instances.size.should == 1
54
+ @t4.instances.should include(@t2)
55
+ end
56
+ it "should give back an empty Set if this Topic has no instances" do
57
+ @t1.instances.should be_empty
58
+ end
59
+ end
60
+
61
+ describe "#instance" do
62
+ it "should raise an error if this Topic has more than one instance" do
63
+ @t3.instances.size.should > 1
64
+ lambda{@t3.instance}.should raise_error
65
+ end
66
+ it "should give back the instance if this Topic is type of exactly one instance" do
67
+ @t4.instance.should == @t2
68
+ end
69
+ it "should give back nil if this Topic has no instance, aka is no type" do
70
+ @t5.instance.should be_nil
71
+ end
72
+ end
73
+
74
+ describe "#reverse_instances" do
75
+ it "reverse_instances should call types" do
76
+ # proof through example, not nice
77
+ @t1.reverse_instances.should == @t1.types
78
+ end
79
+ end
80
+
81
+ describe "#reverse_types" do
82
+ it "reverse_types should call instances" do
83
+ @t2.method(:reverse_types).should == @t2.method(:instances)
84
+ end
85
+ end
86
+
87
+ describe "#transitive_types" do
88
+ before(:each) do
89
+ @st1, @st2, @st3, @st4, @st5 = @tm.get!(["st1","st2","st3", "st4", "st5"])
90
+ end
91
+ it "should give back the types only if the topic has no supertypes" do
92
+ @t1.types.should respond_to(:each)
93
+ @t1.types.size.should == 1
94
+ @t1.transitive_types.size.should == 1
95
+ ###
96
+ @t2.types.should respond_to(:each)
97
+ @t2.types.size.should == 2
98
+ @t2.transitive_types.size.should == 2
99
+ end
100
+ it "should give back the types and supertypes of the topic if supertypes exist" do
101
+ @t3.add_supertype(@st1)
102
+ @t3.add_supertype(@st2)
103
+ @t4.add_supertype(@st3)
104
+ ###
105
+ @t1.transitive_types.size.should == 3
106
+ @t1.transitive_types.should include(@t3, @st1, @st2)
107
+ ###
108
+ @t2.transitive_types.size.should == 5
109
+ @t2.transitive_types.should include(@t3, @st1, @st2, @t4, @st3)
110
+ end
111
+ it "should give back the supertypes of the supertypes also" do
112
+ @t3.add_supertype(@st1)
113
+ @t3.add_supertype(@st2)
114
+ @t4.add_supertype(@st3)
115
+ @st1.add_supertype(@st4)
116
+ @st3.add_supertype(@st5)
117
+ ###
118
+ @t1.transitive_types.size.should == 4
119
+ @t1.transitive_types.should include(@t3, @st1, @st2, @st4)
120
+ ###
121
+ @t2.transitive_types.size.should == 7
122
+ @t2.transitive_types.should include(@t3, @st1, @st2, @st4, @t4, @st3, @st5)
123
+ end
124
+ it "should not give back supertypes" do
125
+ @t3.add_supertype(@st1)
126
+ @t3.transitive_types.should be_empty
127
+ end
128
+ it "should give back supertypes of types without duplicates" do
129
+ @t3.add_supertype(@st1)
130
+ @t3.add_supertype(@st2)
131
+ @t4.add_supertype(@st3)
132
+ @t4.add_supertype(@st2)
133
+ @st1.add_supertype(@st4)
134
+ @st2.add_supertype(@st4)
135
+ @st3.add_supertype(@st5)
136
+ ###
137
+ @t1.transitive_types.size.should == 4
138
+ @t1.transitive_types.should include(@t3, @st1, @st2, @st4)
139
+ ###
140
+ @t2.transitive_types.size.should == 7
141
+ @t2.transitive_types.should include(@t3, @st1, @st2, @st4, @t4, @st3, @st5)
142
+ end
143
+ it "should give back an empty Array if no types exist" do
144
+ @t3.transitive_types.should be_empty
145
+ end
146
+ end
147
+
148
+ describe "#transitive_instances" do
149
+ before(:each) do
150
+ @st1, @st2, @st3, @st4, @st5 = @tm.get!(["st1","st2","st3", "st4", "st5"])
151
+ end
152
+ it "should give back the instances if existing (and no subtypes exist)" do
153
+ @t3.transitive_instances.size.should == 2
154
+ @t3.transitive_instances.should include(@t1, @t2)
155
+ end
156
+ it "should give back the instances and instances of subtypes" do
157
+ @t3.add_subtype(@st1)
158
+ @t3.add_subtype(@st2)
159
+ @t3.add_subtype(@st3)
160
+ @st1.add_instance(@t4)
161
+ @st2.add_instance(@t5)
162
+ ###
163
+ @t3.transitive_instances.size.should == 4
164
+ @t3.transitive_instances.should include(@t1, @t2, @t4, @t5)
165
+ end
166
+ it "should give back the instances and but no subtypes" do
167
+ @t3.add_subtype(@st1)
168
+ @t3.add_subtype(@st2)
169
+ @t3.add_subtype(@st3)
170
+ @t3.transitive_instances.size.should == 2
171
+ @t3.transitive_instances.should include(@t1, @t2)
172
+ end
173
+ it "should give back the instances and instances of transitive subtypes" do
174
+ @t3.add_subtype(@st1)
175
+ @t3.add_subtype(@st2)
176
+ @t3.add_subtype(@st3)
177
+ @st3.add_subtype(@st4)
178
+ @st1.add_instance(@t4)
179
+ @st2.add_instance(@t5)
180
+ @st4.add_instance(@t3) #bad user
181
+ ###
182
+ @t3.transitive_instances.size.should == 5
183
+ @t3.transitive_instances.should include(@t1, @t2, @t3, @t4, @t5)
184
+ end
185
+ it "should give back no duplicates" do
186
+ @t3.add_subtype(@st1)
187
+ @t3.add_subtype(@t3) #bad user
188
+ @st1.add_instance(@t2) #duplicate also
189
+ ###
190
+ @t3.transitive_instances.size.should == 2
191
+ @t3.transitive_instances.should include(@t1, @t2)
192
+ end
193
+ end
194
+ end
195
+ end
@@ -0,0 +1,153 @@
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::Navigation::Topic
7
+ describe self do
8
+ before(:all) do
9
+ @tm = get_used_tm_sys_tm
10
+ @topic = @tm.get!("person")
11
+ @methods_array = @topic.methods
12
+ end
13
+ after(:all) do
14
+ @tm.close
15
+ end
16
+
17
+ describe "#axes" do
18
+ it "should give back a RTM::Axes::Topic" do
19
+ proxy = @topic.axes
20
+ proxy.should be_a_kind_of(RTM::Axes::Topic)
21
+ proxy.construct.should == @topic
22
+ proxy.tm.should == @tm
23
+ end
24
+ end
25
+
26
+ describe "#characteristics" do
27
+ it "should be allowed to call" do
28
+ @methods_array.should include("characteristics")
29
+ end
30
+ end
31
+
32
+ describe "#indicators" do
33
+ it "should be allowed to call" do
34
+ @methods_array.should include("indicators")
35
+ end
36
+ end
37
+
38
+ describe "#indicator" do
39
+ it "should be allowed to call" do
40
+ @methods_array.should include("indicator")
41
+ end
42
+ end
43
+
44
+ describe "#item" do
45
+ it "should be allowed to call" do
46
+ @methods_array.should include("item")
47
+ end
48
+ end
49
+
50
+ describe "#locators" do
51
+ it "should be allowed to call" do
52
+ @methods_array.should include("locators")
53
+ end
54
+ end
55
+
56
+ describe "#reverse_players" do
57
+ it "should be allowed to call" do
58
+ @methods_array.should include("reverse_players")
59
+ end
60
+ end
61
+
62
+ describe "#reifier" do
63
+ it "should not be allowed to call" do
64
+ @methods_array.should_not include("reifier")
65
+ end
66
+ end
67
+
68
+ describe "#reverse_roles" do
69
+ it "should not be allowed to call" do
70
+ @methods_array.should_not include("reverse_roles")
71
+ end
72
+ end
73
+
74
+ describe "#reverse_scope" do
75
+ it "should not be allowed to call" do
76
+ @methods_array.should_not include("reverse_scope")
77
+ end
78
+ end
79
+
80
+ describe "#supertypes" do
81
+ it "should be allowed to call" do
82
+ @methods_array.should include("supertypes")
83
+ end
84
+ end
85
+
86
+ describe "#reverse_subtypes" do
87
+ it "should be allowed to call" do
88
+ @methods_array.should include("reverse_subtypes")
89
+ end
90
+ end
91
+
92
+ describe "#subtypes" do
93
+ it "should be allowed to call" do
94
+ @methods_array.should include("subtypes")
95
+ end
96
+ end
97
+
98
+ describe "#reverse_supertypes" do
99
+ it "should be allowed to call" do
100
+ @methods_array.should include("reverse_supertypes")
101
+ end
102
+ end
103
+
104
+ describe "#traverse" do
105
+ it "should be allowed to call" do
106
+ @methods_array.should include("traverse")
107
+ end
108
+ end
109
+
110
+ describe "#reverse_traverse" do
111
+ it "should be allowed to call" do
112
+ @methods_array.should include("reverse_traverse")
113
+ end
114
+ end
115
+
116
+ describe "#types" do
117
+ it "should be allowed to call" do
118
+ @methods_array.should include("types")
119
+ end
120
+ end
121
+
122
+ describe "#reverse_instances" do
123
+ it "should be allowed to call" do
124
+ @methods_array.should include("reverse_instances")
125
+ end
126
+ end
127
+
128
+ describe "#type" do
129
+ it "should be allowed to call" do
130
+ @methods_array.should include("type")
131
+ end
132
+ end
133
+
134
+ describe "#instances" do
135
+ it "should be allowed to call" do
136
+ @methods_array.should include("instances")
137
+ end
138
+ end
139
+
140
+ describe "#reverse_types" do
141
+ it "should be allowed to call" do
142
+ @methods_array.should include("reverse_types")
143
+ end
144
+ end
145
+
146
+ describe "#instance" do
147
+ it "should be allowed to call" do
148
+ @methods_array.should include("instance")
149
+ end
150
+ end
151
+
152
+ end
153
+ end
@@ -0,0 +1,55 @@
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 Sugar
7
+ module Association
8
+ module HashAccess
9
+
10
+ describe "#[]" do
11
+ before(:each) do
12
+ @tm = get_used_tm_sys_tm
13
+ @assoc = @tm.create_association("assoc_type")
14
+ @assoc2 = @tm.create_association("assoc_type2")
15
+ @role1 = @assoc.create_role("role_type1", "player1")
16
+ @role2 = @assoc.create_role("role_type2","player2")
17
+ @role3 = @assoc2.create_role("role_type3","player3")
18
+ @role4 = @assoc.create_role("role_type2","player4")
19
+ end
20
+ after(:each) do
21
+ @tm.close
22
+ end
23
+ it "should give back Roles which have the specified Role type" do
24
+ @assoc["role_type1"].size.should == 1
25
+ @assoc["role_type1"].should include(@role1)
26
+ @assoc["role_type2"].size.should == 2
27
+ @assoc["role_type2"].should include(@role2)
28
+ @assoc["role_type2"].should include(@role4)
29
+ end
30
+ it "should give back an empty Array if the type does not exist" do
31
+ @assoc["wrong_type"].should == []
32
+ end
33
+ it "should give back all roles of the association if no type is given or type==:any" do
34
+ @assoc[].size.should == 3
35
+ @assoc[:any].size.should == 3
36
+ @assoc[].should include(@role1)
37
+ @assoc[].should include(@role2)
38
+ @assoc[].should include(@role4)
39
+ @assoc[:any].should include(@role1)
40
+ @assoc[:any].should include(@role2)
41
+ @assoc[:any].should include(@role4)
42
+ end
43
+ end
44
+ describe "#[]=" do
45
+ before(:each) do
46
+ @tm = get_used_tm_sys_tm
47
+ end
48
+ after(:each) do
49
+ @tm.close
50
+ end
51
+ it "should test []="
52
+ end
53
+ end
54
+ end
55
+ end