rtm 0.1.6 → 0.2.0

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 (146) hide show
  1. data/DISCLAIMER +10 -33
  2. data/LICENSE +201 -0
  3. data/README +3 -3
  4. data/lib/rtm.rb +148 -74
  5. data/lib/rtm/axes.rb +295 -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 +58 -0
  17. data/lib/rtm/extensions.rb +11 -1
  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 +18 -0
  22. data/lib/rtm/io/from_xtm2_libxml.rb +2 -1
  23. data/lib/rtm/io/ontopia_io.rb +25 -0
  24. data/lib/rtm/io/tmapix.rb +234 -0
  25. data/lib/rtm/io/to_hash.rb +116 -0
  26. data/lib/rtm/io/to_jtm.rb +53 -103
  27. data/lib/rtm/io/to_rdf.rb +30 -0
  28. data/lib/rtm/io/to_string.rb +8 -6
  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 +29 -98
  32. data/lib/rtm/navigation.rb +37 -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 +162 -0
  44. data/lib/rtm/navigation/topic/traverse.rb +51 -0
  45. data/lib/rtm/navigation/topic/types.rb +107 -0
  46. data/lib/rtm/psi.rb +33 -2
  47. data/lib/rtm/sugar.rb +34 -0
  48. data/lib/rtm/sugar/association/hash_access.rb +46 -0
  49. data/lib/rtm/sugar/occurrence/dynamic_value.rb +75 -0
  50. data/lib/rtm/{pimp_my_api.rb → sugar/occurrence/externalize.rb} +3 -0
  51. data/lib/rtm/sugar/role/counterparts.rb +133 -46
  52. data/lib/rtm/sugar/topic/characteristics.rb +126 -12
  53. data/lib/rtm/sugar/topic/counterparts.rb +130 -7
  54. data/lib/rtm/sugar/topic/hash_access.rb +140 -30
  55. data/lib/rtm/sugar/topic/scoped.rb +65 -0
  56. data/lib/rtm/sugar/topic/topic_ref.rb +35 -0
  57. data/lib/rtm/sugar/topic/typed.rb +159 -0
  58. data/lib/rtm/sugar/typed/types.rb +38 -0
  59. data/lib/rtm/validation.rb +8 -5
  60. data/lib/rtm/version.rb +18 -0
  61. data/spec/helpers/spec_exampleexamplegroup.rb +14 -0
  62. data/spec/rtm/axes/association_spec.rb +88 -0
  63. data/spec/rtm/axes/associations_spec.rb +60 -0
  64. data/spec/rtm/axes/assocs_names_occs_spec.rb +9 -0
  65. data/spec/rtm/axes/characteristic_spec.rb +90 -0
  66. data/spec/rtm/axes/characteristics_spec.rb +85 -0
  67. data/spec/rtm/axes/string_spec.rb +145 -0
  68. data/spec/rtm/axes/strings_spec.rb +168 -0
  69. data/spec/rtm/axes/topic_spec.rb +124 -0
  70. data/spec/rtm/axes/topics_spec.rb +103 -0
  71. data/spec/rtm/base_spec.rb +32 -0
  72. data/spec/rtm/io/tmapix_spec.rb +85 -0
  73. data/spec/rtm/navigation/association/players_spec.rb +58 -0
  74. data/spec/rtm/navigation/association_spec.rb +52 -0
  75. data/spec/rtm/navigation/name/atomify_spec.rb +27 -0
  76. data/spec/rtm/navigation/name/characteristics_spec.rb +34 -0
  77. data/spec/rtm/navigation/name_spec.rb +52 -0
  78. data/spec/rtm/navigation/occurrence/atomify_spec.rb +27 -0
  79. data/spec/rtm/navigation/occurrence/characteristics_spec.rb +34 -0
  80. data/spec/rtm/navigation/occurrence_spec.rb +52 -0
  81. data/spec/rtm/navigation/string_spec.rb +51 -0
  82. data/spec/rtm/navigation/topic/characteristics_spec.rb +55 -0
  83. data/spec/rtm/navigation/topic/indicators_spec.rb +43 -0
  84. data/spec/rtm/navigation/topic/items_spec.rb +44 -0
  85. data/spec/rtm/navigation/topic/locators_spec.rb +44 -0
  86. data/spec/rtm/navigation/topic/players_spec.rb +48 -0
  87. data/spec/rtm/navigation/topic/scope_spec.rb +41 -0
  88. data/spec/rtm/navigation/topic/supertypes_spec.rb +376 -0
  89. data/spec/rtm/navigation/topic/traverse_spec.rb +64 -0
  90. data/spec/rtm/navigation/topic/types_spec.rb +195 -0
  91. data/spec/rtm/navigation/topic_spec.rb +153 -0
  92. data/spec/rtm/sugar/association/hash_access_spec.rb +55 -0
  93. data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +16 -0
  94. data/spec/rtm/sugar/role/counterparts_spec.rb +191 -0
  95. data/spec/rtm/sugar/topic/characteristics_spec.rb +318 -0
  96. data/spec/rtm/sugar/topic/counterparts_spec.rb +184 -0
  97. data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
  98. data/spec/rtm/sugar/topic/scoped_spec.rb +131 -0
  99. data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
  100. data/spec/rtm/sugar/topic/typed_spec.rb +155 -0
  101. data/spec/rtm/sugar/typed/types_spec.rb +24 -0
  102. data/spec/rtm/tmapi/core/association_spec.rb +169 -0
  103. data/spec/rtm/tmapi/core/construct_spec.rb +25 -0
  104. data/spec/rtm/tmapi/core/name_spec.rb +85 -0
  105. data/spec/rtm/tmapi/core/occurrence_spec.rb +96 -0
  106. data/spec/rtm/tmapi/core/reifiable_spec.rb +168 -0
  107. data/spec/rtm/tmapi/core/role_spec.rb +73 -0
  108. data/spec/rtm/tmapi/core/scoped_spec.rb +403 -0
  109. data/spec/rtm/tmapi/core/topic_map_spec.rb +648 -0
  110. data/spec/rtm/tmapi/core/topic_spec.rb +992 -0
  111. data/spec/rtm/tmapi/core/typed_spec.rb +112 -0
  112. data/spec/rtm/tmapi/core/variant_spec.rb +52 -0
  113. data/spec/rtm/tmapi/ext/java_util_set_spec.rb +34 -0
  114. data/spec/rtm/tmapi_spec.rb +44 -0
  115. data/spec/rtm/utils/sparql_spec.rb +26 -0
  116. data/spec/rtm_spec.rb +94 -0
  117. data/spec/spec_helper.rb +23 -0
  118. data/test/base_unit_test.rb +161 -0
  119. data/test/{base_test.rb → base_unit_test_tmapi.rb} +46 -43
  120. metadata +122 -66
  121. data/COPYRIGHT +0 -4
  122. data/lib/Rakefile.rb +0 -42
  123. data/lib/activetopicmaps.rb +0 -278
  124. data/lib/rtm/backend/active_record.rb +0 -58
  125. data/lib/rtm/backend/active_record/001_initial_schema.rb +0 -116
  126. data/lib/rtm/backend/active_record/association_and_role.rb +0 -33
  127. data/lib/rtm/backend/active_record/locators.rb +0 -55
  128. data/lib/rtm/backend/active_record/name_variant_occurrence.rb +0 -45
  129. data/lib/rtm/backend/active_record/quaaxtm2rtm.rb +0 -113
  130. data/lib/rtm/backend/active_record/quaaxtm2rtmviews.rb +0 -134
  131. data/lib/rtm/backend/active_record/set_wrapper.rb +0 -98
  132. data/lib/rtm/backend/active_record/tm_construct.rb +0 -62
  133. data/lib/rtm/backend/active_record/tm_delegator.rb +0 -345
  134. data/lib/rtm/backend/active_record/tm_set_delegator.rb +0 -195
  135. data/lib/rtm/backend/active_record/tmdm.rb +0 -298
  136. data/lib/rtm/backend/active_record/topic.rb +0 -87
  137. data/lib/rtm/backend/active_record/topic_map.rb +0 -314
  138. data/lib/rtm/backend/active_record/traverse_associations.rb +0 -87
  139. data/lib/rtm/base.rb +0 -92
  140. data/lib/rtm/connect.rb +0 -92
  141. data/lib/rtm/core_ext.rb +0 -6
  142. data/lib/rtm/io/from_xtm2.rb +0 -263
  143. data/lib/rtm/merging/merging.rb +0 -307
  144. data/lib/rtm/sugar/topic/identifier_direct.rb +0 -11
  145. data/lib/rtm/sugar/topic/predefined_associations.rb +0 -42
  146. data/lib/run_main_project.rb +0 -16
@@ -0,0 +1,44 @@
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 Topic
8
+ module TopicRef
9
+ describe self do
10
+ before(:each) do
11
+ @tm = get_used_tm_sys_tm
12
+ @topic = @tm.get!("ii:uni_leipzig")
13
+ end
14
+ after(:each) do
15
+ @tm.close
16
+ end
17
+ describe "#topic_references" do
18
+ it "should not give back an empty Array" do
19
+ @topic.topic_references.should_not be_empty
20
+ end
21
+ it "should give back an item identifier that starts with a ^" do
22
+ pending if implementation_for_spec == :ontopia
23
+ @topic.topic_references.first[0].should == ?^
24
+ @topic.topic_references.should include("^http://www.topicmapslab.de/uni_leipzig")
25
+ end
26
+ it "should give back subject locators also" do
27
+ pending if implementation_for_spec == :ontopia
28
+ @topic.addSubjectLocator(@tm.create_locator("uni_leipzig"))
29
+ @topic.topic_references.size.should == 2
30
+ @topic.topic_references.should include("^http://www.topicmapslab.de/uni_leipzig")
31
+ @topic.topic_references.should include("=http://www.topicmapslab.de/uni_leipzig")
32
+ end
33
+ it "should give back subject identifiers also" do
34
+ pending if implementation_for_spec == :ontopia
35
+ @topic.add_subject_identifier(@tm.create_locator("uni_leipzig"))
36
+ @topic.topic_references.size.should == 2
37
+ @topic.topic_references.should include("^http://www.topicmapslab.de/uni_leipzig")
38
+ @topic.topic_references.should include("http://www.topicmapslab.de/uni_leipzig")
39
+ end
40
+ end #of describe "#identifiers"
41
+ end #of describe self
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,155 @@
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 Topic
8
+ module Typed
9
+ describe self do
10
+ before(:each) do
11
+ @tm = get_used_tm_sys_tm
12
+ @type0 = @tm.get!("negative")
13
+ @default_name_type = @tm.get!(RTM::PSI[:name_type])
14
+ @dummy_type = @tm.get!("dummy_type")
15
+ @container = @tm.get!("container")
16
+ @containee = @tm.get!("containee")
17
+ @contained = @tm.get!("contained")
18
+ @leipzig = @tm.get!("leipzig")
19
+ @germany = @tm.get!("germany")
20
+ @dummy = @tm.get!("dummy")
21
+ @name1 = @leipzig.create_name(@dummy_type, "Leipzig")
22
+ @name2 = @germany.create_name("Germany")
23
+ @name3 = @germany.create_name("Deutschland")
24
+ @name4 = @leipzig.create_name("Leipzisch")
25
+ @name5 = @leipzig.create_name("Lipsk")
26
+ @occ1 = @leipzig.create_occurrence("inhabitants","500000")
27
+ @occ2 = @germany.create_occurrence("states","16")
28
+ @occ3 = @leipzig.create_occurrence("state","Sachsen")
29
+ @occ2 = @germany.create_occurrence(@dummy_type,"0")
30
+ @assoc1 = @tm.create_association(@dummy_type,["assoc_dummy"])
31
+ @assoc2 = @tm.create_association(@contained)
32
+ @role1 = @assoc2.create_role(@containee,@leipzig)
33
+ @role2 = @assoc2.create_role(@container,@germany)
34
+ @dummy_role = @assoc1.create_role(@dummy_type,@dummy)
35
+ end
36
+ after(:each) do
37
+ @tm.close
38
+ end
39
+
40
+ describe "#typed" do
41
+ it "should give back all constructs which have this Topic as type" do
42
+ @default_name_type.typed.size.should == 4
43
+ @default_name_type.typed.should include(@name2)
44
+ @default_name_type.typed.should include(@name3)
45
+ @default_name_type.typed.should include(@name4)
46
+ @default_name_type.typed.should include(@name5)
47
+ @container.typed.size.should == 1
48
+ @container.typed.should include(@role2)
49
+ @containee.typed.size.should == 1
50
+ @containee.typed.should include(@role1)
51
+ @contained.typed.size.should == 1
52
+ @contained.typed.should include(@assoc2)
53
+ @dummy_type.typed.size.should == 4
54
+ @dummy_type.typed.should include(@name1)
55
+ @dummy_type.typed.should include(@occ2)
56
+ @dummy_type.typed.should include(@assoc1)
57
+ @dummy_type.typed.should include(@dummy_role)
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
62
+ end
63
+
64
+ describe "#typed_associations" do
65
+ it "should give back all Associations which have this Topic as type" do
66
+ @default_name_type.typed_associations.should be_empty
67
+ @container.typed_associations.should be_empty
68
+ @containee.typed_associations.should be_empty
69
+ @contained.typed_associations.size.should == 1
70
+ @contained.typed_associations.should include(@assoc2)
71
+ @dummy_type.typed_associations.size.should == 1
72
+ @dummy_type.typed_associations.should include(@assoc1)
73
+ end
74
+ it "should give back an empty Array if there are no Associations which have this Topic as type" do
75
+ @type0.typed_associations.should be_empty
76
+ end
77
+ end
78
+
79
+ describe "#typed_names" do
80
+ it "should give back all Names which have this Topic as type" do
81
+ @default_name_type.typed_names.size.should == 4
82
+ @default_name_type.typed_names.should include(@name2)
83
+ @default_name_type.typed_names.should include(@name3)
84
+ @default_name_type.typed_names.should include(@name4)
85
+ @default_name_type.typed_names.should include(@name5)
86
+ @container.typed_names.should be_empty
87
+ @containee.typed_names.should be_empty
88
+ @contained.typed_names.should be_empty
89
+ @dummy_type.typed_names.size.should == 1
90
+ @dummy_type.typed_names.should include(@name1)
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
95
+ end
96
+
97
+ describe "#typed_occurrences" do
98
+ it "should give back all Occurrences which have this Topic as type" do
99
+ @default_name_type.typed_occurrences.should be_empty
100
+ @container.typed_occurrences.should be_empty
101
+ @containee.typed_occurrences.should be_empty
102
+ @contained.typed_occurrences.should be_empty
103
+ @dummy_type.typed_occurrences.size.should == 1
104
+ @dummy_type.typed_occurrences.should include(@occ2)
105
+ end
106
+ it "should give back an empty Array if there are no Occurrences which have this Topic as type" do
107
+ @type0.typed_occurrences.should be_empty
108
+ end
109
+ end
110
+
111
+ describe "#typed_roles" do
112
+ it "should give back all Roles which have this Topic as type" do
113
+ @default_name_type.typed_roles.should be_empty
114
+ @container.typed_roles.size.should == 1
115
+ @container.typed_roles.should include(@role2)
116
+ @containee.typed_roles.size.should == 1
117
+ @containee.typed_roles.should include(@role1)
118
+ @contained.typed_roles.should be_empty
119
+ @dummy_type.typed_roles.size.should == 1
120
+ @dummy_type.typed_roles.should include(@dummy_role)
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
125
+ end
126
+
127
+ describe "#topic_is_a?" do
128
+ before(:each) do
129
+ @t1, @t2, @t3, @t4, @t5 = @tm.get!(["t1", "t2", "t3", "t4", "t5"])
130
+ @t1.add_types(@t1, @t2)
131
+ @t1.add_instance(@t3)
132
+ @t2.add_supertype(@t4)
133
+ @t4.add_supertype(@t5)
134
+ end
135
+ it "give back true, if the argument is a type of this topic" do
136
+ @t1.topic_is_a?(@t1).should be_true
137
+ @t1.topic_is_a?("t2").should be_true
138
+ end
139
+ it "should give back false, if the argument is no type of this topic" do
140
+ @t1.topic_is_a?(@t3).should be_false
141
+ end
142
+ it "should give back false, if the argument is not a topic in the topic map" do
143
+ @t1.topic_is_a?("t6").should be_false
144
+ end
145
+ it "should give back true, if the argument is a supertype of the type of this topic" do
146
+ @t1.topic_is_a?(@t4).should be_true
147
+ @t1.topic_is_a?("t5").should be_true
148
+ end
149
+ end
150
+
151
+ end #of describe self
152
+
153
+ end
154
+ end
155
+ end
@@ -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 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.topic_references_as_locators.first).size.should == 1
136
+ other_asso.roles(t_type3.topic_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
@@ -0,0 +1,25 @@
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::Construct
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 "#id" do
16
+ it "should return the id of the construct as String" do
17
+ @tm.id.should be_a_kind_of String
18
+ topic = @tm.get!("x")
19
+ topic.id.should be_a_kind_of String
20
+ end
21
+ it "should be tested further"
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,85 @@
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::Name
7
+
8
+ describe self do
9
+ before(:each) do
10
+ @tm = get_used_tm_sys_tm
11
+ @topic = @tm.create_topic_by("Uni_Leipzig")
12
+ @testname = @topic.create_name("Universitaet Leipzig")
13
+ end
14
+ after(:each) do
15
+ @tm.close
16
+ end
17
+
18
+ describe "#parent" do
19
+ it "should give back the Topic the Name belongs to" do
20
+ #puts "ancestors:"
21
+ #puts @testname.java_class
22
+ #puts @testname.class.ancestors
23
+ @testname.should be_a_kind_of RTM::Name
24
+ @testname.parent.should == @topic
25
+ end
26
+ end
27
+
28
+ describe "#atomify" do
29
+ it "should give back the value of the Name" do
30
+ @testname.should be_a_kind_of RTM::Name
31
+ @testname.atomify.should == "Universitaet Leipzig"
32
+ end
33
+ end
34
+
35
+ describe "#children" do
36
+ it "should return all Variants defined for this Name" do
37
+ topic = @tm.create_topic_by("Uni_Leipzig")
38
+ name = topic.create_name("Universitaet Leipzig")
39
+ scope1 = @tm.create_topic_by("englisch")
40
+ scope2 = @tm.create_topic_by("umgangssprachlich")
41
+ variant1 = name.create_variant("University of Leipzig", [scope1])
42
+ variant2 = name.create_variant("Universiaet Leipzsch", [scope2])
43
+ #puts "ancestors:"
44
+ #puts variant1.java_class
45
+ #puts variant1.class.ancestors.inspect
46
+ variant1.should be_a_kind_of RTM::Variant
47
+ variant2.should be_a_kind_of RTM::Variant
48
+ name.children.size.should == 2
49
+ name.children.should include(variant1)
50
+ name.children.should include(variant2)
51
+ end
52
+ end
53
+
54
+ describe "#create_variant" do
55
+ it "should be tested"
56
+ end
57
+
58
+ end # of describe self
59
+
60
+ describe self do
61
+ describe "#remove" do
62
+ before(:each) do
63
+ @tm = get_used_tm_sys_tm
64
+ @topic1 = @tm.get!("topic1")
65
+ @topic2 = @tm.get!("topic2")
66
+ @name = @topic1.create_name("firstname","Hans")
67
+ @name.create_variant("Hansi",["Spitzname"])
68
+ @topic2.create_name("firstname","Peter")
69
+ @topic1.should have(1).names
70
+ @topic1.names.should include @name
71
+ end
72
+ after(:each) do
73
+ @tm.close
74
+ end
75
+ it "should remove this name from the container (topic)" do
76
+ @tm.literal_index.getNames("Hans").size.should == 1
77
+ @name.remove
78
+ @tm.literal_index.getNames("Hans").size.should == 0
79
+ @tm.literal_index.getNames("Peter").size.should == 1
80
+ @topic1.should have(0).names
81
+ end
82
+ end
83
+ end # of describe self
84
+
85
+ end # of module