rtm 0.1.6 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/DISCLAIMER +10 -33
- data/LICENSE +201 -0
- data/README +32 -3
- data/lib/rtm.rb +126 -74
- data/lib/rtm/axes.rb +298 -0
- data/lib/rtm/axes/association.rb +76 -0
- data/lib/rtm/axes/associations.rb +96 -0
- data/lib/rtm/axes/assocs_names_occs.rb +56 -0
- data/lib/rtm/axes/characteristic.rb +68 -0
- data/lib/rtm/axes/characteristics.rb +93 -0
- data/lib/rtm/axes/string.rb +76 -0
- data/lib/rtm/axes/strings.rb +87 -0
- data/lib/rtm/axes/topic.rb +233 -0
- data/lib/rtm/axes/topics.rb +280 -0
- data/lib/rtm/{backward_compatibility.rb → deprecated/index_property_set.rb} +3 -0
- data/lib/rtm/engine.rb +101 -0
- data/lib/rtm/extensions.rb +65 -5
- data/lib/rtm/{locator_helpers.rb → helpers/locator.rb} +15 -4
- data/lib/rtm/{helpers.rb → helpers/no_output.rb} +3 -0
- data/lib/rtm/helpers/uri.rb +13 -0
- data/lib/rtm/io.rb +19 -0
- data/lib/rtm/io/from_xtm2_libxml.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 +154 -0
- data/lib/rtm/io/to_jtm.rb +53 -103
- data/lib/rtm/io/to_rdf.rb +45 -0
- data/lib/rtm/io/to_string.rb +21 -8
- data/lib/rtm/io/to_xtm1.rb +6 -4
- data/lib/rtm/io/to_xtm2.rb +10 -8
- data/lib/rtm/io/to_yaml.rb +59 -100
- data/lib/rtm/navigation.rb +23 -0
- data/lib/rtm/navigation/association/players.rb +25 -0
- data/lib/rtm/navigation/name/atomify.rb +19 -0
- data/lib/rtm/navigation/name/characteristics.rb +33 -0
- data/lib/rtm/navigation/occurrence/atomify.rb +19 -0
- data/lib/rtm/navigation/occurrence/characteristics.rb +33 -0
- data/lib/rtm/navigation/topic/characteristics.rb +33 -0
- data/lib/rtm/navigation/topic/indicators.rb +31 -0
- data/lib/rtm/navigation/topic/items.rb +31 -0
- data/lib/rtm/navigation/topic/locators.rb +31 -0
- data/lib/rtm/navigation/topic/players.rb +27 -0
- data/lib/rtm/navigation/topic/supertypes.rb +166 -0
- data/lib/rtm/navigation/topic/traverse.rb +51 -0
- data/lib/rtm/navigation/topic/types.rb +109 -0
- data/lib/rtm/psi.rb +39 -2
- data/lib/rtm/sugar.rb +47 -0
- data/lib/rtm/sugar/association/hash_access.rb +46 -0
- data/lib/rtm/sugar/occurrence/dynamic_value.rb +58 -0
- 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 +139 -46
- data/lib/rtm/sugar/topic/best_name.rb +74 -0
- data/lib/rtm/sugar/topic/characteristics.rb +126 -12
- data/lib/rtm/sugar/topic/counterparts.rb +145 -10
- data/lib/rtm/sugar/topic/hash_access.rb +140 -30
- data/lib/rtm/sugar/topic/scoped.rb +114 -0
- data/lib/rtm/sugar/topic/topic_ref.rb +86 -0
- data/lib/rtm/sugar/topic/typed.rb +207 -0
- 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 +38 -0
- data/lib/rtm/validation.rb +7 -4
- data/lib/rtm/version.rb +30 -0
- data/spec/helpers/spec_exampleexamplegroup.rb +14 -0
- data/spec/rtm/axes/association_spec.rb +88 -0
- data/spec/rtm/axes/associations_spec.rb +60 -0
- data/spec/rtm/axes/assocs_names_occs_spec.rb +9 -0
- data/spec/rtm/axes/characteristic_spec.rb +90 -0
- data/spec/rtm/axes/characteristics_spec.rb +85 -0
- data/spec/rtm/axes/string_spec.rb +145 -0
- data/spec/rtm/axes/strings_spec.rb +168 -0
- data/spec/rtm/axes/topic_spec.rb +124 -0
- data/spec/rtm/axes/topics_spec.rb +103 -0
- data/spec/rtm/base_spec.rb +32 -0
- 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/navigation/association/players_spec.rb +58 -0
- data/spec/rtm/navigation/association_spec.rb +52 -0
- data/spec/rtm/navigation/name/atomify_spec.rb +27 -0
- data/spec/rtm/navigation/name/characteristics_spec.rb +34 -0
- data/spec/rtm/navigation/name_spec.rb +52 -0
- data/spec/rtm/navigation/occurrence/atomify_spec.rb +27 -0
- data/spec/rtm/navigation/occurrence/characteristics_spec.rb +34 -0
- data/spec/rtm/navigation/occurrence_spec.rb +52 -0
- data/spec/rtm/navigation/string_spec.rb +51 -0
- data/spec/rtm/navigation/topic/characteristics_spec.rb +55 -0
- data/spec/rtm/navigation/topic/indicators_spec.rb +43 -0
- data/spec/rtm/navigation/topic/items_spec.rb +44 -0
- data/spec/rtm/navigation/topic/locators_spec.rb +44 -0
- data/spec/rtm/navigation/topic/players_spec.rb +48 -0
- data/spec/rtm/navigation/topic/scope_spec.rb +41 -0
- data/spec/rtm/navigation/topic/supertypes_spec.rb +376 -0
- data/spec/rtm/navigation/topic/traverse_spec.rb +64 -0
- data/spec/rtm/navigation/topic/types_spec.rb +195 -0
- data/spec/rtm/navigation/topic_spec.rb +153 -0
- data/spec/rtm/sugar/association/hash_access_spec.rb +55 -0
- data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +171 -0
- 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 +193 -0
- data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
- data/spec/rtm/sugar/topic/characteristics_spec.rb +333 -0
- data/spec/rtm/sugar/topic/counterparts_spec.rb +224 -0
- data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
- data/spec/rtm/sugar/topic/scoped_spec.rb +195 -0
- data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
- data/spec/rtm/sugar/topic/typed_spec.rb +217 -0
- data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
- data/spec/rtm/sugar/typed/types_spec.rb +24 -0
- data/spec/rtm/tmapi/core/association_spec.rb +169 -0
- data/spec/rtm/tmapi/core/construct_spec.rb +25 -0
- data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
- data/spec/rtm/tmapi/core/name_spec.rb +270 -0
- data/spec/rtm/tmapi/core/occurrence_spec.rb +53 -0
- data/spec/rtm/tmapi/core/reifiable_spec.rb +168 -0
- data/spec/rtm/tmapi/core/role_spec.rb +73 -0
- data/spec/rtm/tmapi/core/scoped_spec.rb +441 -0
- data/spec/rtm/tmapi/core/topic_map_spec.rb +716 -0
- data/spec/rtm/tmapi/core/topic_spec.rb +1468 -0
- data/spec/rtm/tmapi/core/typed_spec.rb +112 -0
- data/spec/rtm/tmapi/core/variant_spec.rb +52 -0
- data/spec/rtm/tmapi/ext/java_util_set_spec.rb +34 -0
- data/spec/rtm/tmapi_spec.rb +44 -0
- data/spec/rtm/utils/sparql_spec.rb +26 -0
- data/spec/rtm_spec.rb +93 -0
- data/spec/spec_helper.rb +28 -0
- 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 +169 -65
- data/COPYRIGHT +0 -4
- data/lib/Rakefile.rb +0 -42
- data/lib/activetopicmaps.rb +0 -278
- data/lib/rtm/backend/active_record.rb +0 -58
- data/lib/rtm/backend/active_record/001_initial_schema.rb +0 -116
- data/lib/rtm/backend/active_record/association_and_role.rb +0 -33
- data/lib/rtm/backend/active_record/locators.rb +0 -55
- data/lib/rtm/backend/active_record/name_variant_occurrence.rb +0 -45
- data/lib/rtm/backend/active_record/quaaxtm2rtm.rb +0 -113
- data/lib/rtm/backend/active_record/quaaxtm2rtmviews.rb +0 -134
- data/lib/rtm/backend/active_record/set_wrapper.rb +0 -98
- data/lib/rtm/backend/active_record/tm_construct.rb +0 -62
- data/lib/rtm/backend/active_record/tm_delegator.rb +0 -345
- data/lib/rtm/backend/active_record/tm_set_delegator.rb +0 -195
- data/lib/rtm/backend/active_record/tmdm.rb +0 -298
- data/lib/rtm/backend/active_record/topic.rb +0 -87
- data/lib/rtm/backend/active_record/topic_map.rb +0 -314
- data/lib/rtm/backend/active_record/traverse_associations.rb +0 -87
- data/lib/rtm/base.rb +0 -92
- data/lib/rtm/connect.rb +0 -92
- data/lib/rtm/core_ext.rb +0 -6
- data/lib/rtm/io/from_xtm2.rb +0 -263
- data/lib/rtm/merging/merging.rb +0 -307
- data/lib/rtm/pimp_my_api.rb +0 -28
- data/lib/rtm/sugar/topic/identifier_direct.rb +0 -11
- data/lib/rtm/sugar/topic/predefined_associations.rb +0 -42
- data/lib/run_main_project.rb +0 -16
- data/test/base_test.rb +0 -162
@@ -0,0 +1,145 @@
|
|
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::Axes
|
7
|
+
class String < ItemProxy
|
8
|
+
describe self do
|
9
|
+
before(:all) do
|
10
|
+
@tm = get_used_tm_sys_tm
|
11
|
+
@proxy = "string".axes(@tm)
|
12
|
+
|
13
|
+
end
|
14
|
+
after(:all) do
|
15
|
+
@tm.close
|
16
|
+
end
|
17
|
+
it "should be allowed to call #tmapi and #result on a RTM::TQML::String" do
|
18
|
+
@proxy.methods.should include("tmapi")
|
19
|
+
@proxy.methods.should include("result")
|
20
|
+
end
|
21
|
+
it "should be allowed to call #reverse_atomify on a RTM::TQML::String" do
|
22
|
+
@proxy.methods.should include("reverse_atomify")
|
23
|
+
end
|
24
|
+
it "should be allowed to call #reverse_indicators on a RTM::TQML::String" do
|
25
|
+
@proxy.methods.should include("reverse_indicators")
|
26
|
+
end
|
27
|
+
it "should be allowed to call #reverse_item on a RTM::TQML::String" do
|
28
|
+
@proxy.methods.should include("reverse_item")
|
29
|
+
end
|
30
|
+
it "should be allowed to call #reverse_locators on a RTM::TQML::String" do
|
31
|
+
@proxy.methods.should include("reverse_locators")
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#new" do
|
35
|
+
it "should raise an error if the underlying construct is not a String" do
|
36
|
+
lambda{RTM::Axes::String.new(1,@tm)}.should raise_error
|
37
|
+
end
|
38
|
+
it "should not raise an error if the underlying construct is a String" do
|
39
|
+
lambda{RTM::Axes::String.new("string",@tm)}.should_not raise_error
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#reverse_atomify" do
|
44
|
+
before(:all) do
|
45
|
+
@topic1 = @tm.get!("Hans")
|
46
|
+
@topic2 = @tm.get!("Peter")
|
47
|
+
@topic3 = @tm.get!("Hans2")
|
48
|
+
@name1 = @topic1.create_name("Hans")
|
49
|
+
@name2 = @topic2.create_name("Peter")
|
50
|
+
@name3 = @topic3.create_name("Hans")
|
51
|
+
@occ1 = @topic1.create_occurrence("Number","18")
|
52
|
+
@occ2 = @topic2.create_occurrence("Age", "18")
|
53
|
+
@occ3 = @topic3.create_occurrence("Friend", "Hans")
|
54
|
+
@variant1 = @name2.create_variant("Hans",[@tm.get!("Alias")])
|
55
|
+
end
|
56
|
+
it "should give back an Array" do
|
57
|
+
"Hans".axes(@tm).reverse_atomify.should be_a_kind_of Array
|
58
|
+
"nothing".axes(@tm).reverse_atomify.should be_a_kind_of Array
|
59
|
+
end
|
60
|
+
it "should give back an Array consisting of RTM::Axes::Characteristic" do
|
61
|
+
"Hans".axes(@tm).reverse_atomify.first.should be_a_kind_of RTM::Axes::Characteristic
|
62
|
+
end
|
63
|
+
it "should give back a RTM::Axes::Characteristics" do
|
64
|
+
"Hans".axes(@tm).reverse_atomify.should be_a_kind_of RTM::Axes::Characteristics
|
65
|
+
end
|
66
|
+
it "should give back all Names and Occurrences which have this String as value (including Variant values)" do
|
67
|
+
value1 = "Hans"
|
68
|
+
value2 = "18"
|
69
|
+
value1.axes(@tm).reverse_atomify.size.should == 4
|
70
|
+
value2.axes(@tm).reverse_atomify.size.should == 2
|
71
|
+
value1.axes(@tm).reverse_atomify.map{|res| res.construct}.should include(@name1)
|
72
|
+
value1.axes(@tm).reverse_atomify.map{|res| res.construct}.should include(@name3)
|
73
|
+
value1.axes(@tm).reverse_atomify.map{|res| res.construct}.should include(@occ3)
|
74
|
+
value1.axes(@tm).reverse_atomify.map{|res| res.construct}.should include(@name2)
|
75
|
+
value2.axes(@tm).reverse_atomify.map{|res| res.construct}.should include(@occ1)
|
76
|
+
value2.axes(@tm).reverse_atomify.map{|res| res.construct}.should include(@occ2)
|
77
|
+
end
|
78
|
+
it "should give back nil if String does not occur in a Name or Occurrence" do
|
79
|
+
"nothing".axes(@tm).reverse_atomify.should be_empty
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "reverse identifier methods" do
|
84
|
+
before(:all) do
|
85
|
+
@value = "http://www.example.org/anything"
|
86
|
+
@si_value = "http://www.example.org/test_si"
|
87
|
+
@ii_value = "http://www.example.org/test_ii"
|
88
|
+
@sl_value = "http://www.example.org/test_sl"
|
89
|
+
@si_topic = @tm.get!("si:" + @si_value)
|
90
|
+
@ii_topic = @tm.get!("ii:" + @ii_value)
|
91
|
+
@sl_topic = @tm.get!("=" + @sl_value)
|
92
|
+
@all_topic = @tm.create_topic
|
93
|
+
@all_si_value = "http://www.example.org/all_si"
|
94
|
+
@all_ii_value = "http://www.example.org/all_ii"
|
95
|
+
@all_sl_value = "http://www.example.org/all_sl"
|
96
|
+
@all_topic.add_subject_identifier(@all_si_value)
|
97
|
+
@all_topic.add_item_identifier(@all_ii_value)
|
98
|
+
@all_topic.add_subject_locator(@all_sl_value)
|
99
|
+
end
|
100
|
+
describe "#reverse_indicators" do
|
101
|
+
it "should give back a RTM::Axes::Topic if a Topic is found" do
|
102
|
+
@si_value.axes(@tm).reverse_indicators.should be_a_kind_of(RTM::Axes::Topic)
|
103
|
+
@all_si_value.axes(@tm).reverse_indicators.should be_a_kind_of(RTM::Axes::Topic)
|
104
|
+
end
|
105
|
+
it "should give back nil if no Topic is found" do
|
106
|
+
@value.axes(@tm).reverse_indicators.should be_nil
|
107
|
+
end
|
108
|
+
it "should give back the right Topic" do
|
109
|
+
@si_value.axes(@tm).reverse_indicators.construct.should == @si_topic
|
110
|
+
@all_si_value.axes(@tm).reverse_indicators.construct.should == @all_topic
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "#reverse_item" do
|
115
|
+
it "should give back a RTM::Axes::Topic if a Topic is found" do
|
116
|
+
@ii_value.axes(@tm).reverse_item.should be_a_kind_of(RTM::Axes::Topic)
|
117
|
+
@all_ii_value.axes(@tm).reverse_item.should be_a_kind_of(RTM::Axes::Topic)
|
118
|
+
end
|
119
|
+
it "should give back nil if no Topic is found" do
|
120
|
+
@value.axes(@tm).reverse_item.should be_nil
|
121
|
+
end
|
122
|
+
it "should give back the right Topic" do
|
123
|
+
@ii_value.axes(@tm).reverse_item.construct.should == @ii_topic
|
124
|
+
@all_ii_value.axes(@tm).reverse_item.construct.should == @all_topic
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "#reverse_locators" do
|
129
|
+
it "should give back a RTM::Axes::Topic if a Topic is found" do
|
130
|
+
@sl_value.axes(@tm).reverse_locators.should be_a_kind_of(RTM::Axes::Topic)
|
131
|
+
@all_sl_value.axes(@tm).reverse_locators.should be_a_kind_of(RTM::Axes::Topic)
|
132
|
+
end
|
133
|
+
it "should give back nil if no Topic is found" do
|
134
|
+
@value.axes(@tm).reverse_locators.should be_nil
|
135
|
+
end
|
136
|
+
it "should give back the right Topic" do
|
137
|
+
@sl_value.axes(@tm).reverse_locators.construct.should == @sl_topic
|
138
|
+
@all_sl_value.axes(@tm).reverse_locators.construct.should == @all_topic
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
end #of describe self
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,168 @@
|
|
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::Axes
|
7
|
+
module Strings
|
8
|
+
describe self do
|
9
|
+
before(:all) do
|
10
|
+
@tm = get_used_tm_sys_tm
|
11
|
+
@proxy = ["string1".axes(@tm),"string2".axes(@tm)].extend(Strings)
|
12
|
+
end
|
13
|
+
after(:all) do
|
14
|
+
@tm.close
|
15
|
+
end
|
16
|
+
it "should be allowed to call #tmapi and #result on a Strings-Array" do
|
17
|
+
@proxy.methods.should include("tmapi")
|
18
|
+
@proxy.methods.should include("result")
|
19
|
+
end
|
20
|
+
it "should be allowed to call #reverse_atomify on a Strings-Array" do
|
21
|
+
@proxy.methods.should include("reverse_atomify")
|
22
|
+
end
|
23
|
+
it "should not be allowed to call #reverse_indicators on a Strings-Array" do
|
24
|
+
@proxy.methods.should include("reverse_indicators")
|
25
|
+
end
|
26
|
+
it "should not be allowed to call #reverse_item on a Strings-Array" do
|
27
|
+
@proxy.methods.should include("reverse_item")
|
28
|
+
end
|
29
|
+
it "should not be allowed to call #reverse_locators on a Strings-Array" do
|
30
|
+
@proxy.methods.should include("reverse_locators")
|
31
|
+
end
|
32
|
+
describe "#reverse_atomify" do
|
33
|
+
before(:all) do
|
34
|
+
@topic1 = @tm.get!("Hans")
|
35
|
+
@topic2 = @tm.get!("Peter")
|
36
|
+
@topic3 = @tm.get!("Hans2")
|
37
|
+
@name1 = @topic1.create_name("Hans")
|
38
|
+
@name2 = @topic2.create_name("Peter")
|
39
|
+
@name3 = @topic3.create_name("Hans")
|
40
|
+
@occ1 = @topic1.create_occurrence("Number","18")
|
41
|
+
@occ2 = @topic2.create_occurrence("Age", "18")
|
42
|
+
@occ3 = @topic3.create_occurrence("Frien", "Hans")
|
43
|
+
@variant1 = @name2.create_variant("Hans",[@tm.get!("Alias")])
|
44
|
+
@proxies = ["Hans".axes(@tm),"18".axes(@tm)].extend(Strings)
|
45
|
+
end
|
46
|
+
it "should give back an Array" do
|
47
|
+
@proxies.reverse_atomify.should be_a_kind_of Array
|
48
|
+
end
|
49
|
+
it "should give back an Array consisting of RTM::Axes::Characteristic" do
|
50
|
+
@proxies.reverse_atomify.first.should be_a_kind_of RTM::Axes::Characteristic
|
51
|
+
end
|
52
|
+
it "should give back a Characteristics" do
|
53
|
+
@proxies.reverse_atomify.should be_a_kind_of RTM::Axes::Characteristics
|
54
|
+
end
|
55
|
+
it "should give back all Names and Occurrences which have these Strings as value (including Variant values)" do
|
56
|
+
@proxies.reverse_atomify.size.should == 6
|
57
|
+
@proxies.reverse_atomify.map{|res| res.construct}.should include(@name1)
|
58
|
+
@proxies.reverse_atomify.map{|res| res.construct}.should include(@name3)
|
59
|
+
@proxies.reverse_atomify.map{|res| res.construct}.should include(@occ3)
|
60
|
+
@proxies.reverse_atomify.map{|res| res.construct}.should include(@name2)
|
61
|
+
@proxies.reverse_atomify.map{|res| res.construct}.should include(@occ1)
|
62
|
+
@proxies.reverse_atomify.map{|res| res.construct}.should include(@occ2)
|
63
|
+
end
|
64
|
+
it "should give back nothing if String in Array does not occur in a Name or Occurrence" do
|
65
|
+
["nothing".axes(@tm)].extend(Strings).reverse_atomify.should be_empty
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "reverse identifier methods" do
|
70
|
+
before(:all) do
|
71
|
+
@value = "http://www.example.org/anything"
|
72
|
+
@si_value1 = "http://www.example.org/test_si_1"
|
73
|
+
@ii_value1 = "http://www.example.org/test_ii_1"
|
74
|
+
@sl_value1 = "http://www.example.org/test_sl_1"
|
75
|
+
@si_value2 = "http://www.example.org/test_si_2"
|
76
|
+
@ii_value2 = "http://www.example.org/test_ii_2"
|
77
|
+
@sl_value2 = "http://www.example.org/test_sl_2"
|
78
|
+
@si_topic1 = @tm.get!("si:" + @si_value1)
|
79
|
+
@ii_topic1 = @tm.get!("ii:" + @ii_value1)
|
80
|
+
@sl_topic1 = @tm.get!("=" + @sl_value1)
|
81
|
+
@si_topic2 = @tm.get!("si:" + @si_value2)
|
82
|
+
@ii_topic2 = @tm.get!("ii:" + @ii_value2)
|
83
|
+
@sl_topic2 = @tm.get!("=" + @sl_value2)
|
84
|
+
@all_topic = @tm.create_topic
|
85
|
+
@all_si_value = "http://www.example.org/all_si"
|
86
|
+
@all_ii_value = "http://www.example.org/all_ii"
|
87
|
+
@all_sl_value = "http://www.example.org/all_sl"
|
88
|
+
@all_topic.add_subject_identifier(@all_si_value)
|
89
|
+
@all_topic.add_item_identifier(@all_ii_value)
|
90
|
+
@all_topic.add_subject_locator(@all_sl_value)
|
91
|
+
@proxies = [@si_value1.axes(@tm),@ii_value1.axes(@tm),@sl_value1.axes(@tm),@si_value2.axes(@tm),@ii_value2.axes(@tm),@sl_value2.axes(@tm),@all_si_value.axes(@tm),@all_ii_value.axes(@tm),@all_sl_value.axes(@tm)].extend(Strings)
|
92
|
+
end
|
93
|
+
describe "#reverse_indicators" do
|
94
|
+
it "should give back an Array" do
|
95
|
+
@proxies.reverse_indicators.should be_a_kind_of Array
|
96
|
+
end
|
97
|
+
it "should give back an Array consisting of RTM::Axes::Topic" do
|
98
|
+
@proxies.reverse_indicators.first.should be_a_kind_of(RTM::Axes::Topic)
|
99
|
+
end
|
100
|
+
it "should give back a Topics" do
|
101
|
+
@proxies.reverse_indicators.should be_a_kind_of RTM::Axes::Topics
|
102
|
+
end
|
103
|
+
it "should give back all Topics which have these Strings as indicators" do
|
104
|
+
@proxies.reverse_indicators.size.should == 3
|
105
|
+
@proxies.reverse_indicators.map{|res| res.construct}.should include(@si_topic1)
|
106
|
+
@proxies.reverse_indicators.map{|res| res.construct}.should include(@si_topic2)
|
107
|
+
@proxies.reverse_indicators.map{|res| res.construct}.should include(@all_topic)
|
108
|
+
end
|
109
|
+
it "should give back nothing if no Topic has one of these Strings as indicator" do
|
110
|
+
[@value.axes(@tm)].extend(Strings).reverse_indicators.should be_empty
|
111
|
+
end
|
112
|
+
it "should give back the same Topics several times" do
|
113
|
+
[@si_value1.axes(@tm),@si_value1.axes(@tm)].extend(Strings).reverse_indicators.size.should == 2
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "#reverse_item" do
|
118
|
+
it "should give back an Array" do
|
119
|
+
@proxies.reverse_item.should be_a_kind_of Array
|
120
|
+
end
|
121
|
+
it "should give back an Array consisting of RTM::Axes::Topic" do
|
122
|
+
@proxies.reverse_item.first.should be_a_kind_of(RTM::Axes::Topic)
|
123
|
+
end
|
124
|
+
it "should give back a Topics" do
|
125
|
+
@proxies.reverse_item.should be_a_kind_of RTM::Axes::Topics
|
126
|
+
end
|
127
|
+
it "should give back all Topics which have these Strings as item identifier" do
|
128
|
+
@proxies.reverse_item.size.should == 3
|
129
|
+
@proxies.reverse_item.map{|res| res.construct}.should include(@ii_topic1)
|
130
|
+
@proxies.reverse_item.map{|res| res.construct}.should include(@ii_topic2)
|
131
|
+
@proxies.reverse_item.map{|res| res.construct}.should include(@all_topic)
|
132
|
+
end
|
133
|
+
it "should give back nothing if no Topic has one of these Strings as item identifier" do
|
134
|
+
[@value.axes(@tm)].extend(Strings).reverse_item.should be_empty
|
135
|
+
end
|
136
|
+
it "should give back the same Topics several times" do
|
137
|
+
[@ii_value1.axes(@tm),@ii_value1.axes(@tm)].extend(Strings).reverse_item.size.should == 2
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe "#reverse_locators" do
|
142
|
+
it "should give back an Array" do
|
143
|
+
@proxies.reverse_locators.should be_a_kind_of Array
|
144
|
+
end
|
145
|
+
it "should give back an Array consisting of RTM::Axes::Topic" do
|
146
|
+
@proxies.reverse_locators.first.should be_a_kind_of(RTM::Axes::Topic)
|
147
|
+
end
|
148
|
+
it "should give back a Topics" do
|
149
|
+
@proxies.reverse_locators.should be_a_kind_of RTM::Axes::Topics
|
150
|
+
end
|
151
|
+
it "should give back all Topics which have these Strings as subject locator" do
|
152
|
+
@proxies.reverse_locators.size.should == 3
|
153
|
+
@proxies.reverse_locators.map{|res| res.construct}.should include(@sl_topic1)
|
154
|
+
@proxies.reverse_locators.map{|res| res.construct}.should include(@sl_topic2)
|
155
|
+
@proxies.reverse_locators.map{|res| res.construct}.should include(@all_topic)
|
156
|
+
end
|
157
|
+
it "should give back nothing if no Topic has one of these Strings as subject locator" do
|
158
|
+
[@value.axes(@tm)].extend(Strings).reverse_locators.should be_empty
|
159
|
+
end
|
160
|
+
it "should give back the same Topics several times" do
|
161
|
+
[@sl_value1.axes(@tm),@sl_value1.axes(@tm)].extend(Strings).reverse_locators.size.should == 2
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,124 @@
|
|
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::Axes
|
7
|
+
class Topic < ItemProxy
|
8
|
+
describe self do
|
9
|
+
before(:all) do
|
10
|
+
@tm = get_used_tm_sys_tm
|
11
|
+
@topic = @tm.get!("person")
|
12
|
+
@name = @topic.create_name("Hans")
|
13
|
+
@occ = @topic.create_occurrence("Age", "18")
|
14
|
+
@proxy = @topic.axes
|
15
|
+
end
|
16
|
+
after(:all) do
|
17
|
+
@tm.close
|
18
|
+
end
|
19
|
+
it "should be allowed to call #tmapi and #result on a RTM::Axes::Topic" do
|
20
|
+
@proxy.methods.should include("tmapi")
|
21
|
+
@proxy.methods.should include("result")
|
22
|
+
end
|
23
|
+
it "should be allowed to call #characteristics on a RTM::Axes::Topic" do
|
24
|
+
@proxy.methods.should include("characteristics")
|
25
|
+
end
|
26
|
+
it "should be allowed to call #indicators on a RTM::Axes::Topic" do
|
27
|
+
@proxy.methods.should include("indicators")
|
28
|
+
end
|
29
|
+
it "should be allowed to call #item on a RTM::Axes::Topic" do
|
30
|
+
@proxy.methods.should include("item")
|
31
|
+
end
|
32
|
+
it "should be allowed to call #locators on a RTM::Axes::Topic" do
|
33
|
+
@proxy.methods.should include("locators")
|
34
|
+
end
|
35
|
+
it "should be allowed to call #reverse_players on a RTM::Axes::Topic" do
|
36
|
+
@proxy.methods.should include("reverse_players")
|
37
|
+
end
|
38
|
+
it "should be allowed to call #reifier on a RTM::Axes::Topic" do
|
39
|
+
@proxy.methods.should include("reifier")
|
40
|
+
end
|
41
|
+
it "should be allowed to call #reverse_roles on a RTM::Axes::Topic" do
|
42
|
+
@proxy.methods.should include("reverse_roles")
|
43
|
+
end
|
44
|
+
it "should be allowed to call #reverse_scope on a RTM::Axes::Topic" do
|
45
|
+
@proxy.methods.should include("reverse_scope")
|
46
|
+
end
|
47
|
+
it "should be allowed to call #supertypes on a RTM::Axes::Topic" do
|
48
|
+
@proxy.methods.should include("supertypes")
|
49
|
+
end
|
50
|
+
it "should be allowed to call #subtypes on a RTM::Axes::Topic" do
|
51
|
+
@proxy.methods.should include("subtypes")
|
52
|
+
end
|
53
|
+
it "should be allowed to call #reverse_subtypes on a RTM::Axes::Topic" do
|
54
|
+
@proxy.methods.should include("reverse_subtypes")
|
55
|
+
end
|
56
|
+
it "should be allowed to call #reverse_supertypes on a RTM::Axes::Topic" do
|
57
|
+
@proxy.methods.should include("reverse_supertypes")
|
58
|
+
end
|
59
|
+
it "should be allowed to call #traverse on a RTM::Axes::Topic" do
|
60
|
+
@proxy.methods.should include("traverse")
|
61
|
+
end
|
62
|
+
it "should be allowed to call #reverse_traverse on a RTM::Axes::Topic" do
|
63
|
+
@proxy.methods.should include("reverse_traverse")
|
64
|
+
end
|
65
|
+
it "should be allowed to call #types on a RTM::Axes::Topic" do
|
66
|
+
@proxy.methods.should include("types")
|
67
|
+
end
|
68
|
+
it "should be allowed to call #instances on a RTM::Axes::Topic" do
|
69
|
+
@proxy.methods.should include("instances")
|
70
|
+
end
|
71
|
+
it "should be allowed to call #reverse_types on a RTM::Axes::Topic" do
|
72
|
+
@proxy.methods.should include("reverse_types")
|
73
|
+
end
|
74
|
+
it "should be allowed to call #reverse_instances on a RTM::Axes::Topic" do
|
75
|
+
@proxy.methods.should include("reverse_instances")
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#new" do
|
79
|
+
it "should raise an error if the underlying construct is not a Topic" do
|
80
|
+
lambda{RTM::Axes::Topic.new(1,@tm)}.should raise_error
|
81
|
+
end
|
82
|
+
it "should not raise an error if the underlying construct is a Topic" do
|
83
|
+
lambda{RTM::Axes::Topic.new(@topic,@tm)}.should_not raise_error
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "#characteristics" do
|
88
|
+
it "should give back an Array" do
|
89
|
+
@proxy.characteristics.should be_a_kind_of Array
|
90
|
+
end
|
91
|
+
it "should give back an Array consisting of RTM::Axes::Characteristic" do
|
92
|
+
@proxy.characteristics.first.should be_a_kind_of RTM::Axes::Characteristic
|
93
|
+
end
|
94
|
+
it "should give back a RTM::Axes::Characteristics" do
|
95
|
+
@proxy.characteristics.should be_a_kind_of RTM::Axes::Characteristics
|
96
|
+
end
|
97
|
+
it "should give back all Names and Occurrences of this Topic" do
|
98
|
+
@proxy.characteristics.size.should == 2
|
99
|
+
@proxy.characteristics.map{|c| c.construct}.should include(@name)
|
100
|
+
@proxy.characteristics.map{|c| c.construct}.should include(@occ)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
# it "should give back an empty set it the topic types no role" do
|
106
|
+
# @topic.reverse_roles.should be_empty
|
107
|
+
# end
|
108
|
+
# it "should give back a set of associations where that topic is the role type" do
|
109
|
+
# a_asso = @tm.create_association("asso_type")
|
110
|
+
# a_asso[@topic] = "to_a_noter_topic"
|
111
|
+
# @topic.reverse_roles.length.should == 1
|
112
|
+
# @topic.reverse_roles.include?(a_asso).should be_true
|
113
|
+
# end
|
114
|
+
# it "shuld give back multiple associations if the topic is used multipe times as roll tpye in one association" do
|
115
|
+
# a_asso = @tm.create_association("asso_type")
|
116
|
+
# a_asso[@topic] = "to_a_noter_topic"
|
117
|
+
# a_asso[@topic] = "to_a_noter_topic_2"
|
118
|
+
# @topic.reverse_roles.length.should == 2
|
119
|
+
# @topic.reverse_roles.select {|a| a == a_asso }.size.should == 2
|
120
|
+
# end
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,103 @@
|
|
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::Axes
|
7
|
+
module Topics
|
8
|
+
describe self do
|
9
|
+
before(:all) do
|
10
|
+
@tm = get_used_tm_sys_tm
|
11
|
+
@topic1 = @tm.get!("person1")
|
12
|
+
@name1 = @topic1.create_name("Hans")
|
13
|
+
@occ1 = @topic1.create_occurrence("Age", "18")
|
14
|
+
@topic2 = @tm.get!("person2")
|
15
|
+
@name2 = @topic2.create_name("Peter")
|
16
|
+
@occ2 = @topic2.create_occurrence("Age", "17")
|
17
|
+
@proxy = [@topic1.axes,@topic2.axes].extend(Topics)
|
18
|
+
end
|
19
|
+
after(:all) do
|
20
|
+
@tm.close
|
21
|
+
end
|
22
|
+
it "should be allowed to call #tmapi and #result on a RTM::TQML::Topics" do
|
23
|
+
@proxy.methods.should include("tmapi")
|
24
|
+
@proxy.methods.should include("result")
|
25
|
+
end
|
26
|
+
it "should be allowed to call #characteristics on a RTM::TQML::Topics" do
|
27
|
+
@proxy.methods.should include("characteristics")
|
28
|
+
end
|
29
|
+
it "should be allowed to call #indicators on a RTM::TQML::Topics" do
|
30
|
+
@proxy.methods.should include("indicators")
|
31
|
+
end
|
32
|
+
it "should be allowed to call #item on a RTM::TQML::Topics" do
|
33
|
+
@proxy.methods.should include("item")
|
34
|
+
end
|
35
|
+
it "should be allowed to call #locators on a RTM::TQML::Topics" do
|
36
|
+
@proxy.methods.should include("locators")
|
37
|
+
end
|
38
|
+
it "should be allowed to call #reverse_players on a RTM::TQML::Topics" do
|
39
|
+
@proxy.methods.should include("reverse_players")
|
40
|
+
end
|
41
|
+
it "should be allowed to call #reifier on a RTM::TQML::Topics" do
|
42
|
+
@proxy.methods.should include("reifier")
|
43
|
+
end
|
44
|
+
it "should be allowed to call #reverse_roles on a RTM::TQML::Topics" do
|
45
|
+
@proxy.methods.should include("reverse_roles")
|
46
|
+
end
|
47
|
+
it "should be allowed to call #reverse_scope on a RTM::TQML::Topics" do
|
48
|
+
@proxy.methods.should include("reverse_scope")
|
49
|
+
end
|
50
|
+
it "should be allowed to call #supertypes on a RTM::TQML::Topicsy" do
|
51
|
+
@proxy.methods.should include("supertypes")
|
52
|
+
end
|
53
|
+
it "should be allowed to call #subtypes on a RTM::TQML::Topics" do
|
54
|
+
@proxy.methods.should include("subtypes")
|
55
|
+
end
|
56
|
+
it "should be allowed to call #reverse_subtypes on a RTM::TQML::Topics" do
|
57
|
+
@proxy.methods.should include("reverse_subtypes")
|
58
|
+
end
|
59
|
+
it "should be allowed to call #reverse_supertypes on a RTM::TQML::Topics" do
|
60
|
+
@proxy.methods.should include("reverse_supertypes")
|
61
|
+
end
|
62
|
+
it "should be allowed to call #traverse on a RTM::TQML::Topics" do
|
63
|
+
@proxy.methods.should include("traverse")
|
64
|
+
end
|
65
|
+
it "should be allowed to call #reverse_traverse on a RTM::TQML::Topics" do
|
66
|
+
@proxy.methods.should include("reverse_traverse")
|
67
|
+
end
|
68
|
+
it "should be allowed to call #types on a RTM::TQML::Topics" do
|
69
|
+
@proxy.methods.should include("types")
|
70
|
+
end
|
71
|
+
it "should be allowed to call #instances on a RTM::TQML::Topics" do
|
72
|
+
@proxy.methods.should include("instances")
|
73
|
+
end
|
74
|
+
it "should be allowed to call #reverse_types on a RTM::TQML::Topics" do
|
75
|
+
@proxy.methods.should include("reverse_types")
|
76
|
+
end
|
77
|
+
it "should be allowed to call #reverse_instances on a RTM::TQML::Topics" do
|
78
|
+
@proxy.methods.should include("reverse_instances")
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#characteristics" do
|
82
|
+
it "should give back an Array" do
|
83
|
+
@proxy.characteristics.should be_a_kind_of Array
|
84
|
+
end
|
85
|
+
it "should give back an Array consisting of RTM::Axes::Characteristic" do
|
86
|
+
@proxy.characteristics.first.should be_a_kind_of RTM::Axes::Characteristic
|
87
|
+
end
|
88
|
+
it "should give back a RTM::Axes::Characteristics" do
|
89
|
+
@proxy.characteristics.should be_a_kind_of RTM::Axes::Characteristics
|
90
|
+
end
|
91
|
+
it "should give back all Names and Occurrences of this Topic" do
|
92
|
+
@proxy.characteristics.size.should == 4
|
93
|
+
@proxy.characteristics.map{|c| c.construct}.should include(@name1)
|
94
|
+
@proxy.characteristics.map{|c| c.construct}.should include(@occ1)
|
95
|
+
@proxy.characteristics.map{|c| c.construct}.should include(@name2)
|
96
|
+
@proxy.characteristics.map{|c| c.construct}.should include(@occ2)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|