rtm 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +38 -3
- data/lib/rtm.rb +25 -47
- data/lib/rtm/axes.rb +7 -4
- data/lib/rtm/axes/association.rb +1 -1
- data/lib/rtm/axes/associations.rb +1 -1
- data/lib/rtm/axes/characteristic.rb +1 -1
- data/lib/rtm/axes/characteristics.rb +1 -1
- data/lib/rtm/axes/topic.rb +3 -3
- data/lib/rtm/axes/topics.rb +3 -3
- data/lib/rtm/engine.rb +48 -5
- data/lib/rtm/extensions.rb +58 -8
- data/lib/rtm/io.rb +2 -1
- data/lib/rtm/io/tmapix_from.rb +155 -0
- data/lib/rtm/io/tmapix_to.rb +223 -0
- data/lib/rtm/io/to_hash.rb +79 -41
- data/lib/rtm/io/to_jtm.rb +1 -1
- data/lib/rtm/io/to_rdf.rb +20 -5
- data/lib/rtm/io/to_string.rb +13 -2
- data/lib/rtm/io/to_yaml.rb +39 -11
- data/lib/rtm/navigation.rb +1 -15
- data/lib/rtm/navigation/association/players.rb +1 -1
- data/lib/rtm/navigation/name/characteristics.rb +1 -1
- data/lib/rtm/navigation/occurrence/characteristics.rb +1 -1
- data/lib/rtm/navigation/topic/characteristics.rb +1 -1
- data/lib/rtm/navigation/topic/players.rb +1 -1
- data/lib/rtm/navigation/topic/supertypes.rb +21 -17
- data/lib/rtm/navigation/topic/traverse.rb +1 -1
- data/lib/rtm/navigation/topic/types.rb +6 -4
- data/lib/rtm/psi.rb +6 -0
- data/lib/rtm/sugar.rb +42 -29
- data/lib/rtm/sugar/association/hash_access.rb +3 -3
- data/lib/rtm/sugar/occurrence/dynamic_value.rb +39 -56
- data/lib/rtm/sugar/occurrence/external.rb +53 -0
- data/lib/rtm/sugar/reifiable/reifier.rb +21 -0
- data/lib/rtm/sugar/role/counterparts.rb +12 -6
- data/lib/rtm/sugar/topic/best_name.rb +74 -0
- data/lib/rtm/sugar/topic/characteristics.rb +10 -10
- data/lib/rtm/sugar/topic/counterparts.rb +131 -119
- data/lib/rtm/sugar/topic/scoped.rb +102 -53
- data/lib/rtm/sugar/topic/topic_ref.rb +63 -12
- data/lib/rtm/sugar/topic/typed.rb +50 -2
- data/lib/rtm/sugar/topic_map/query_cache.rb +66 -0
- data/lib/rtm/sugar/topic_map/themes.rb +53 -0
- data/lib/rtm/sugar/typed/types.rb +1 -1
- data/lib/rtm/validation.rb +2 -2
- data/lib/rtm/version.rb +18 -6
- data/spec/rtm/axes/string_spec.rb +7 -7
- data/spec/rtm/axes/strings_spec.rb +10 -10
- data/spec/rtm/io/tmapix_from_spec.rb +76 -0
- data/spec/rtm/io/tmapix_to_spec.rb +159 -0
- data/spec/rtm/io/to_hash_spec.rb +90 -0
- data/spec/rtm/io/to_rdf_spec.rb +37 -0
- data/spec/rtm/io/to_string_spec.rb +122 -0
- data/spec/rtm/io/to_yaml_spec.rb +89 -0
- data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +156 -1
- data/spec/rtm/sugar/occurrence/external_spec.rb +129 -0
- data/spec/rtm/sugar/reifiable/reifier_spec.rb +41 -0
- data/spec/rtm/sugar/role/counterparts_spec.rb +174 -172
- data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
- data/spec/rtm/sugar/topic/characteristics_spec.rb +20 -5
- data/spec/rtm/sugar/topic/counterparts_spec.rb +41 -1
- data/spec/rtm/sugar/topic/hash_access_spec.rb +1 -1
- data/spec/rtm/sugar/topic/scoped_spec.rb +178 -114
- data/spec/rtm/sugar/topic/topic_ref_spec.rb +10 -10
- data/spec/rtm/sugar/topic/typed_spec.rb +196 -134
- data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
- data/spec/rtm/sugar/typed/types_spec.rb +1 -1
- data/spec/rtm/tmapi/core/association_spec.rb +2 -2
- data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
- data/spec/rtm/tmapi/core/name_spec.rb +186 -1
- data/spec/rtm/tmapi/core/occurrence_spec.rb +24 -67
- data/spec/rtm/tmapi/core/reifiable_spec.rb +2 -2
- data/spec/rtm/tmapi/core/scoped_spec.rb +40 -2
- data/spec/rtm/tmapi/core/topic_map_spec.rb +98 -30
- data/spec/rtm/tmapi/core/topic_spec.rb +558 -82
- data/spec/rtm/tmapi/core/variant_spec.rb +3 -3
- data/spec/rtm_spec.rb +0 -1
- data/spec/spec_helper.rb +7 -2
- data/test/javalibs/junit-4.5.jar +0 -0
- data/test/javalibs/tmapi-2.0-tests.jar +0 -0
- data/test/tmapi_tests.rb +25 -0
- metadata +66 -11
- data/lib/rtm/io/ontopia_io.rb +0 -25
- data/lib/rtm/io/tmapix.rb +0 -234
- data/lib/rtm/sugar/occurrence/externalize.rb +0 -31
- data/spec/rtm/io/tmapix_spec.rb +0 -85
- data/test/base_unit_test.rb +0 -161
- data/test/base_unit_test_tmapi.rb +0 -165
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
5
5
|
|
6
|
-
module Sugar::Topic::Counterparts
|
6
|
+
module RTM::Sugar::Topic::Counterparts
|
7
7
|
describe self do
|
8
8
|
before(:each) do
|
9
9
|
@tm = get_used_tm_sys_tm
|
@@ -180,5 +180,45 @@ module Sugar::Topic::Counterparts
|
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
|
+
describe self do
|
184
|
+
describe "unary associations" do
|
185
|
+
before(:each) do
|
186
|
+
@tm = get_used_tm_sys_tm
|
187
|
+
@player = @tm.get!("player")
|
188
|
+
end
|
189
|
+
after(:each) do
|
190
|
+
@tm.close
|
191
|
+
end
|
192
|
+
describe "#counterparts" do
|
193
|
+
it "should handle unary associations" do
|
194
|
+
@tm.create_association("assoc_type", "roletype" => "player")
|
195
|
+
@player.counterparts.should be_empty
|
196
|
+
@player.counterparts(:atype => "1", :rtype => "2", :otype => "3").should be_empty
|
197
|
+
end
|
198
|
+
end
|
199
|
+
describe "#counterplayers" do
|
200
|
+
it "should handle unary associations" do
|
201
|
+
@tm.create_association("assoc_type", "roletype" => "player")
|
202
|
+
@player.counterplayers.should be_empty
|
203
|
+
@player.counterplayers(:atype => "1", :rtype => "2", :otype => "3").should be_empty
|
204
|
+
end
|
205
|
+
end
|
206
|
+
describe "#peers" do
|
207
|
+
it "should handle unary associations" do
|
208
|
+
@tm.create_association("assoc_type", "roletype" => "player")
|
209
|
+
@player.peers.should be_empty
|
210
|
+
@player.peers("1").should be_empty
|
211
|
+
end
|
212
|
+
end
|
213
|
+
describe "#associations_played" do
|
214
|
+
it "should handle unary associations" do
|
215
|
+
assoc = @tm.create_association("assoc_type", "roletype" => "player")
|
216
|
+
@player.associations_played.size.should == 1
|
217
|
+
@player.associations_played.should include(assoc)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
183
223
|
end
|
184
224
|
|
@@ -3,129 +3,193 @@
|
|
3
3
|
|
4
4
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
5
5
|
|
6
|
-
module Sugar
|
7
|
-
module
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
6
|
+
module RTM::Sugar::Topic
|
7
|
+
module Scoped
|
8
|
+
describe self do
|
9
|
+
before(:all) 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(:all) do
|
34
|
+
@tm.close
|
35
|
+
end
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
it "should give back an empty Array if there are no Constructs which have this Topic in their scope" do
|
59
|
-
@theme0.scoped.should be_empty
|
60
|
-
end
|
37
|
+
describe "#scoped" do
|
38
|
+
it "should give back all constructs which have this Topic in their scope" do
|
39
|
+
@theme1.scoped.size.should == 3
|
40
|
+
@theme1.scoped.should include(@name1)
|
41
|
+
@theme1.scoped.should include(@name3)
|
42
|
+
@theme1.scoped.should include(@variant)
|
43
|
+
@theme2.scoped.size.should == 3
|
44
|
+
@theme2.scoped.should include(@name1)
|
45
|
+
@theme2.scoped.should include(@name2)
|
46
|
+
@theme2.scoped.should include(@variant)
|
47
|
+
@theme3.scoped.size.should == 1
|
48
|
+
@theme3.scoped.should include(@occ1)
|
49
|
+
@theme4.scoped.size.should == 1
|
50
|
+
@theme4.scoped.should include(@name5)
|
51
|
+
@test_theme.scoped.size.should == 4
|
52
|
+
@test_theme.scoped.should include(@name2)
|
53
|
+
@test_theme.scoped.should include(@occ2)
|
54
|
+
@test_theme.scoped.should include(@assoc)
|
55
|
+
@test_theme.scoped.should include(@variant)
|
61
56
|
end
|
62
|
-
|
63
|
-
|
64
|
-
it "should give back all Associations which have this Topic in their scope" do
|
65
|
-
@theme1.scoped_associations.should be_empty
|
66
|
-
@theme2.scoped_associations.should be_empty
|
67
|
-
@theme3.scoped_associations.should be_empty
|
68
|
-
@theme4.scoped_associations.should be_empty
|
69
|
-
@test_theme.scoped_associations.size.should == 1
|
70
|
-
@test_theme.scoped_associations.should include(@assoc)
|
71
|
-
end
|
72
|
-
it "should give back an empty Array if there are no Associations which have this Topic in their scope" do
|
73
|
-
@theme0.scoped_associations.should be_empty
|
74
|
-
end
|
57
|
+
it "should give back an empty Array if there are no Constructs which have this Topic in their scope" do
|
58
|
+
@theme0.scoped.should be_empty
|
75
59
|
end
|
60
|
+
end
|
76
61
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
@test_theme.scoped_names.size.should == 1
|
89
|
-
@test_theme.scoped_names.should include(@name2)
|
90
|
-
end
|
91
|
-
it "should give back an empty Array if there are no Names which have this Topic in their scope" do
|
92
|
-
@theme0.scoped_names.should be_empty
|
93
|
-
end
|
62
|
+
describe "#scoped_associations" do
|
63
|
+
it "should give back all Associations which have this Topic in their scope" do
|
64
|
+
@theme1.scoped_associations.should be_empty
|
65
|
+
@theme2.scoped_associations.should be_empty
|
66
|
+
@theme3.scoped_associations.should be_empty
|
67
|
+
@theme4.scoped_associations.should be_empty
|
68
|
+
@test_theme.scoped_associations.size.should == 1
|
69
|
+
@test_theme.scoped_associations.should include(@assoc)
|
70
|
+
end
|
71
|
+
it "should give back an empty Array if there are no Associations which have this Topic in their scope" do
|
72
|
+
@theme0.scoped_associations.should be_empty
|
94
73
|
end
|
74
|
+
end
|
95
75
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
76
|
+
describe "#scoped_names" do
|
77
|
+
it "should give back all Names which have this Topic in their scope" do
|
78
|
+
@theme1.scoped_names.size.should == 2
|
79
|
+
@theme1.scoped_names.should include(@name1)
|
80
|
+
@theme1.scoped_names.should include(@name3)
|
81
|
+
@theme2.scoped_names.size.should == 2
|
82
|
+
@theme2.scoped_names.should include(@name1)
|
83
|
+
@theme2.scoped_names.should include(@name2)
|
84
|
+
@theme3.scoped_names.should be_empty
|
85
|
+
@theme4.scoped_names.size.should == 1
|
86
|
+
@theme4.scoped_names.should include(@name5)
|
87
|
+
@test_theme.scoped_names.size.should == 1
|
88
|
+
@test_theme.scoped_names.should include(@name2)
|
109
89
|
end
|
90
|
+
it "should give back an empty Array if there are no Names which have this Topic in their scope" do
|
91
|
+
@theme0.scoped_names.should be_empty
|
92
|
+
end
|
93
|
+
end
|
110
94
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
@theme0.scoped_variants.should be_empty
|
124
|
-
end
|
95
|
+
describe "#scoped_occurrences" do
|
96
|
+
it "should give back all Occurrences which have this Topic in their scope" do
|
97
|
+
@theme1.scoped_occurrences.should be_empty
|
98
|
+
@theme2.scoped_occurrences.should be_empty
|
99
|
+
@theme3.scoped_occurrences.size.should == 1
|
100
|
+
@theme3.scoped_occurrences.should include(@occ1)
|
101
|
+
@theme4.scoped_occurrences.should be_empty
|
102
|
+
@test_theme.scoped_occurrences.size.should == 1
|
103
|
+
@test_theme.scoped_occurrences.should include(@occ2)
|
104
|
+
end
|
105
|
+
it "should give back an empty Array if there are no Occurrences which have this Topic in their scope" do
|
106
|
+
@theme0.scoped_occurrences.should be_empty
|
125
107
|
end
|
108
|
+
end
|
126
109
|
|
127
|
-
|
128
|
-
|
129
|
-
|
110
|
+
describe "#scoped_variants" do
|
111
|
+
it "should give back all Variants which have this Topic in their scope" do
|
112
|
+
@theme1.scoped_variants.size.should == 1
|
113
|
+
@theme1.scoped_variants.should include(@variant)
|
114
|
+
@theme2.scoped_variants.size.should == 1
|
115
|
+
@theme2.scoped_variants.should include(@variant)
|
116
|
+
@theme3.scoped_variants.should be_empty
|
117
|
+
@theme4.scoped_variants.should be_empty
|
118
|
+
@test_theme.scoped_variants.size.should == 1
|
119
|
+
@test_theme.scoped_variants.should include(@variant)
|
120
|
+
end
|
121
|
+
it "should give back an empty Array if there are no Variants which have this Topic in their scope" do
|
122
|
+
@theme0.scoped_variants.should be_empty
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "#used_as_theme?" do
|
127
|
+
it "should give back true if this topic is used as theme in a scope" do
|
128
|
+
@theme1.used_as_theme?.should be_true
|
129
|
+
@theme2.used_as_theme?.should be_true
|
130
|
+
@theme3.used_as_theme?.should be_true
|
131
|
+
@theme4.used_as_theme?.should be_true
|
132
|
+
@test_theme.used_as_theme?.should be_true
|
133
|
+
end
|
134
|
+
it "should give back false if this topic is not used as theme in a scope" do
|
135
|
+
@theme0.used_as_theme?.should be_false
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "#used_as_association_theme?" do
|
140
|
+
it "should give back true if this topic is used as theme in a scope of an association" do
|
141
|
+
@test_theme.used_as_association_theme?.should be_true
|
142
|
+
end
|
143
|
+
it "should give back false if this topic is not used as theme in a scope of an association" do
|
144
|
+
@theme0.used_as_association_theme?.should be_false
|
145
|
+
@theme1.used_as_association_theme?.should be_false
|
146
|
+
@theme2.used_as_association_theme?.should be_false
|
147
|
+
@theme3.used_as_association_theme?.should be_false
|
148
|
+
@theme4.used_as_association_theme?.should be_false
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe "#used_as_name_theme?" do
|
153
|
+
it "should give back true if this topic is used as theme in a scope of a name" do
|
154
|
+
@test_theme.used_as_name_theme?.should be_true
|
155
|
+
@theme1.used_as_name_theme?.should be_true
|
156
|
+
@theme2.used_as_name_theme?.should be_true
|
157
|
+
@theme4.used_as_name_theme?.should be_true
|
158
|
+
end
|
159
|
+
it "should give back false if this topic is not used as theme in a scope of a name" do
|
160
|
+
@theme0.used_as_name_theme?.should be_false
|
161
|
+
@theme3.used_as_name_theme?.should be_false
|
162
|
+
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe "#used_as_occurrence_theme?" do
|
167
|
+
it "should give back true if this topic is used as theme in a scope of an occurrence" do
|
168
|
+
@test_theme.used_as_occurrence_theme?.should be_true
|
169
|
+
@theme3.used_as_occurrence_theme?.should be_true
|
170
|
+
end
|
171
|
+
it "should give back false if this topic is not used as theme in a scope of an occurrence" do
|
172
|
+
@theme0.used_as_occurrence_theme?.should be_false
|
173
|
+
@theme1.used_as_occurrence_theme?.should be_false
|
174
|
+
@theme2.used_as_occurrence_theme?.should be_false
|
175
|
+
@theme4.used_as_occurrence_theme?.should be_false
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe "#used_as_variant_theme?" do
|
180
|
+
it "should give back true if this topic is used as theme in a scope of a variant" do
|
181
|
+
@test_theme.used_as_variant_theme?.should be_true
|
182
|
+
@theme1.used_as_variant_theme?.should be_true
|
183
|
+
@theme2.used_as_variant_theme?.should be_true
|
184
|
+
end
|
185
|
+
it "should give back false if this topic is not used as theme in a scope of a variant" do
|
186
|
+
@theme0.used_as_variant_theme?.should be_false
|
187
|
+
@theme3.used_as_variant_theme?.should be_false
|
188
|
+
@theme4.used_as_variant_theme?.should be_false
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
end #of describe self
|
130
193
|
end
|
131
194
|
end
|
195
|
+
|
@@ -14,28 +14,28 @@ module Sugar
|
|
14
14
|
after(:each) do
|
15
15
|
@tm.close
|
16
16
|
end
|
17
|
-
describe "#
|
17
|
+
describe "#references" do
|
18
18
|
it "should not give back an empty Array" do
|
19
|
-
@topic.
|
19
|
+
@topic.references.should_not be_empty
|
20
20
|
end
|
21
21
|
it "should give back an item identifier that starts with a ^" do
|
22
22
|
pending if implementation_for_spec == :ontopia
|
23
|
-
@topic.
|
24
|
-
@topic.
|
23
|
+
@topic.references.first[0].should == ?^
|
24
|
+
@topic.references.should include("^http://www.topicmapslab.de/uni_leipzig")
|
25
25
|
end
|
26
26
|
it "should give back subject locators also" do
|
27
27
|
pending if implementation_for_spec == :ontopia
|
28
28
|
@topic.addSubjectLocator(@tm.create_locator("uni_leipzig"))
|
29
|
-
@topic.
|
30
|
-
@topic.
|
31
|
-
@topic.
|
29
|
+
@topic.references.size.should == 2
|
30
|
+
@topic.references.should include("^http://www.topicmapslab.de/uni_leipzig")
|
31
|
+
@topic.references.should include("=http://www.topicmapslab.de/uni_leipzig")
|
32
32
|
end
|
33
33
|
it "should give back subject identifiers also" do
|
34
34
|
pending if implementation_for_spec == :ontopia
|
35
35
|
@topic.add_subject_identifier(@tm.create_locator("uni_leipzig"))
|
36
|
-
@topic.
|
37
|
-
@topic.
|
38
|
-
@topic.
|
36
|
+
@topic.references.size.should == 2
|
37
|
+
@topic.references.should include("^http://www.topicmapslab.de/uni_leipzig")
|
38
|
+
@topic.references.should include("http://www.topicmapslab.de/uni_leipzig")
|
39
39
|
end
|
40
40
|
end #of describe "#identifiers"
|
41
41
|
end #of describe self
|
@@ -3,153 +3,215 @@
|
|
3
3
|
|
4
4
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
5
5
|
|
6
|
-
module Sugar
|
7
|
-
module
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
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
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
59
|
-
it "should give back an empty Array if there are no Constructs which have this Topic as type" do
|
60
|
-
@type0.typed.should be_empty
|
61
|
-
end
|
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)
|
62
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
|
63
62
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
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
|
77
75
|
end
|
76
|
+
end
|
78
77
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
92
|
-
it "should give back an empty Array if there are no Names which have this Topic as type" do
|
93
|
-
@type0.typed_names.should be_empty
|
94
|
-
end
|
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)
|
95
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
|
96
95
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
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
|
109
107
|
end
|
108
|
+
end
|
110
109
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
122
|
-
it "should give back an empty Array if there are no Roles which have this Topic as type" do
|
123
|
-
@type0.typed_roles.should be_empty
|
124
|
-
end
|
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)
|
125
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
|
+
|
126
150
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
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
|
149
211
|
end
|
212
|
+
end
|
150
213
|
|
151
|
-
|
214
|
+
end #of describe self
|
152
215
|
|
153
|
-
end
|
154
216
|
end
|
155
217
|
end
|