talia_core 0.5.4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/config/talia_core.yml.example +37 -35
- data/generators/talia_admin/templates/app/models/fake_source.rb +93 -0
- data/generators/talia_admin/templates/app/models/talia_collection.rb +13 -37
- data/generators/talia_base/talia_base_generator.rb +0 -1
- data/generators/talia_base/templates/app/controllers/custom_templates_controller.rb +2 -1
- data/generators/talia_base/templates/app/controllers/sources_controller.rb +1 -1
- data/generators/talia_base/templates/script/configure_talia +56 -73
- data/generators/talia_swicky/talia_swicky_generator.rb +18 -0
- data/generators/talia_swicky/templates/app/controllers/swicky_notebooks_controller.rb +111 -0
- data/generators/talia_swicky/templates/app/helpers/swicky_notebooks_helper.rb +29 -0
- data/generators/talia_swicky/templates/app/views/swicky_notebooks/index.builder +6 -0
- data/generators/talia_swicky/templates/app/views/swicky_notebooks/index.html.erb +10 -0
- data/generators/talia_swicky/templates/app/views/swicky_notebooks/show.html.erb +11 -0
- data/generators/talia_swicky/templates/test/fixtures/notebook.rdf +862 -0
- data/generators/talia_swicky/templates/test/functional/swicky_notebooks_controller_test.rb +44 -0
- data/lib/core_ext/boolean.rb +23 -0
- data/lib/core_ext/jdbc_rake_monkeypatch.rb +22 -0
- data/lib/core_ext/nil_class.rb +11 -0
- data/lib/core_ext/object.rb +34 -0
- data/lib/core_ext/string.rb +15 -0
- data/lib/custom_template.rb +3 -1
- data/lib/loader_helper.rb +16 -3
- data/lib/mysql.rb +7 -7
- data/lib/progressbar.rb +2 -2
- data/lib/swicky/exhibit_json/item.rb +129 -0
- data/lib/swicky/exhibit_json/item_collection.rb +129 -0
- data/lib/swicky/fragment.rb +0 -0
- data/lib/swicky/note.rb +7 -0
- data/lib/swicky/notebook.rb +78 -12
- data/lib/talia_core/active_source.rb +45 -13
- data/lib/talia_core/active_source_parts/class_methods.rb +154 -26
- data/lib/talia_core/active_source_parts/finders.rb +49 -26
- data/lib/talia_core/active_source_parts/predicate_handler.rb +71 -23
- data/lib/talia_core/active_source_parts/rdf/ntriples_reader.rb +13 -0
- data/lib/talia_core/active_source_parts/rdf/rdf_reader.rb +99 -0
- data/lib/talia_core/active_source_parts/rdf/rdfxml_reader.rb +12 -0
- data/lib/talia_core/active_source_parts/{rdf.rb → rdf_handler.rb} +52 -19
- data/lib/talia_core/active_source_parts/xml/generic_reader.rb +151 -260
- data/lib/talia_core/active_source_parts/xml/generic_reader_add_statements.rb +97 -0
- data/lib/talia_core/active_source_parts/xml/generic_reader_helpers.rb +88 -0
- data/lib/talia_core/active_source_parts/xml/generic_reader_import_statements.rb +239 -0
- data/lib/talia_core/active_source_parts/xml/rdf_builder.rb +14 -7
- data/lib/talia_core/active_source_parts/xml/source_builder.rb +7 -3
- data/lib/talia_core/active_source_parts/xml/source_reader.rb +17 -2
- data/lib/talia_core/collection.rb +192 -1
- data/lib/talia_core/data_types/data_loader.rb +88 -18
- data/lib/talia_core/data_types/data_record.rb +24 -2
- data/lib/talia_core/data_types/delayed_copier.rb +13 -3
- data/lib/talia_core/data_types/file_record.rb +24 -13
- data/lib/talia_core/data_types/file_store.rb +111 -94
- data/lib/talia_core/data_types/iip_data.rb +104 -23
- data/lib/talia_core/data_types/iip_loader.rb +102 -56
- data/lib/talia_core/data_types/image_data.rb +3 -1
- data/lib/talia_core/data_types/media_link.rb +4 -1
- data/lib/talia_core/data_types/mime_mapping.rb +65 -38
- data/lib/talia_core/data_types/path_helpers.rb +23 -17
- data/lib/talia_core/data_types/pdf_data.rb +9 -6
- data/lib/talia_core/data_types/simple_text.rb +5 -4
- data/lib/talia_core/data_types/xml_data.rb +53 -25
- data/lib/talia_core/dummy_handler.rb +3 -2
- data/lib/talia_core/errors.rb +13 -27
- data/lib/talia_core/initializer.rb +44 -4
- data/lib/talia_core/oai/active_source_model.rb +13 -6
- data/lib/talia_core/oai/active_source_oai_adapter.rb +13 -12
- data/lib/talia_core/rdf_import.rb +1 -1
- data/lib/talia_core/rdf_resource.rb +2 -1
- data/lib/talia_core/semantic_collection_wrapper.rb +143 -151
- data/lib/talia_core/semantic_property.rb +4 -0
- data/lib/talia_core/semantic_relation.rb +84 -33
- data/lib/talia_core/source.rb +45 -25
- data/lib/talia_core/source_fragment.rb +7 -0
- data/lib/talia_core/source_transfer_object.rb +3 -1
- data/lib/talia_core/source_types/agent.rb +16 -0
- data/lib/talia_core/source_types/dc_resource.rb +3 -3
- data/lib/talia_core/source_types/marcont_resource.rb +15 -0
- data/lib/talia_core/source_types/skos_concept.rb +17 -0
- data/lib/talia_dependencies.rb +1 -1
- data/lib/talia_util.rb +1 -1
- data/lib/talia_util/bar_progressor.rb +1 -1
- data/lib/talia_util/image_conversions.rb +8 -2
- data/lib/talia_util/import_job_helper.rb +40 -3
- data/lib/talia_util/io_helper.rb +15 -4
- data/lib/talia_util/progressable.rb +50 -1
- data/lib/talia_util/rake_tasks.rb +3 -21
- data/lib/talia_util/test_helpers.rb +6 -1
- data/lib/talia_util/util.rb +108 -27
- data/lib/talia_util/xml/base_builder.rb +28 -1
- data/lib/talia_util/xml/rdf_builder.rb +81 -5
- data/lib/tasks/talia_core_tasks.rake +2 -0
- data/test/core_ext/boolean_test.rb +26 -0
- data/test/core_ext/nil_class_test.rb +14 -0
- data/test/core_ext/object_test.rb +26 -0
- data/test/core_ext/string_test.rb +11 -0
- data/test/swicky/json_encoder_test.rb +51 -42
- data/test/swicky/notebook_test.rb +13 -6
- data/test/talia_core/active_source_finder_interface_test.rb +30 -0
- data/test/talia_core/active_source_test.rb +445 -34
- data/test/talia_core/collection_test.rb +332 -0
- data/test/talia_core/data_types/file_record_test.rb +2 -23
- data/test/talia_core/ntriples_reader_test.rb +49 -0
- data/test/talia_core/rdfxml_reader_test.rb +51 -0
- data/test/talia_core/source_test.rb +12 -0
- data/test/talia_util/import_job_helper_test.rb +19 -12
- metadata +190 -90
- data/config/database.yml +0 -19
- data/config/rdfstore.yml +0 -13
- data/config/talia_core.yml +0 -24
- data/generators/talia_base/templates/migrations/bj_migration.rb +0 -10
- data/lib/JXslt/jxslt.rb +0 -60
- data/lib/swicky/json_encoder.rb +0 -179
- data/lib/talia_core/agent.rb +0 -14
- data/lib/talia_core/background_jobs/job.rb +0 -82
- data/lib/talia_core/background_jobs/progress_job.rb +0 -68
- data/lib/talia_core/data_types/temp_file_handling.rb +0 -85
- data/lib/talia_core/ordered_source.rb +0 -228
- data/lib/talia_core/semantic_collection_item.rb +0 -94
- data/lib/talia_core/source_types/collection.rb +0 -15
- data/lib/talia_util/progressbar.rb +0 -236
- data/tasks/talia_core_tasks.rake +0 -2
- data/test/talia_core/ordered_source_test.rb +0 -394
- data/test/talia_core/semantic_collection_item_test.rb +0 -125
data/tasks/talia_core_tasks.rake
DELETED
@@ -1,394 +0,0 @@
|
|
1
|
-
# Load the helper class
|
2
|
-
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
3
|
-
|
4
|
-
module TaliaCore
|
5
|
-
|
6
|
-
# Test the ActiveSource
|
7
|
-
class OrderedSourceTest < Test::Unit::TestCase
|
8
|
-
|
9
|
-
# fixtures :active_sources, :semantic_properties, :semantic_relations
|
10
|
-
|
11
|
-
def setup
|
12
|
-
setup_once(:flush) { TestHelper::flush_store }
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_resource_type
|
16
|
-
ordered_source = OrderedSource.new('http://testvalue.org/ordered_set/type')
|
17
|
-
# check class
|
18
|
-
assert_kind_of OrderedSource, ordered_source
|
19
|
-
# check type
|
20
|
-
# assert_equal 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq', ordered_source.types.to_s
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_elements
|
24
|
-
# create new OrderedSource
|
25
|
-
ordered_source = OrderedSource.new('http://testvalue.org/ordered_set/elenments')
|
26
|
-
ordered_source.save!
|
27
|
-
|
28
|
-
# create 3 items
|
29
|
-
item_1 = ActiveSource.new('http://testvalue.org/item_1')
|
30
|
-
item_2 = ActiveSource.new('http://testvalue.org/item_2')
|
31
|
-
item_3 = ActiveSource.new('http://testvalue.org/item_3')
|
32
|
-
|
33
|
-
# add items to OrderedSource
|
34
|
-
ordered_source[(RDF::_000001).uri].add_with_order(item_1, 1)
|
35
|
-
ordered_source[(RDF::_000002).uri].add_with_order(item_2, 2)
|
36
|
-
ordered_source[(RDF::_000003).uri].add_with_order(item_3, 3)
|
37
|
-
ordered_source.save!
|
38
|
-
|
39
|
-
# check if all items are inserted
|
40
|
-
assert_equal 3, ordered_source.elements.size
|
41
|
-
assert_equal item_1.uri, ordered_source.elements[0].uri
|
42
|
-
assert_equal item_2.uri, ordered_source.elements[1].uri
|
43
|
-
assert_equal item_3.uri, ordered_source.elements[2].uri
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_add
|
47
|
-
# create new OrderedSource
|
48
|
-
ordered_source = OrderedSource.new('http://testvalue.org/ordered_set')
|
49
|
-
ordered_source.save!
|
50
|
-
assert ordered_source.elements.empty?
|
51
|
-
|
52
|
-
# create 3 items
|
53
|
-
item_1 = ActiveSource.new('http://testvalue.org/item_1')
|
54
|
-
item_2 = ActiveSource.new('http://testvalue.org/item_2')
|
55
|
-
|
56
|
-
# add item to ordered source
|
57
|
-
ordered_source.add item_1
|
58
|
-
ordered_source.save!
|
59
|
-
|
60
|
-
# check if all items are inserted
|
61
|
-
assert_equal 1, ordered_source.elements.size
|
62
|
-
assert_equal item_1.uri, ordered_source.elements[0].uri
|
63
|
-
|
64
|
-
ordered_source.add item_2
|
65
|
-
ordered_source.save!
|
66
|
-
|
67
|
-
# check if all items are inserted
|
68
|
-
assert_equal 2, ordered_source.elements.size
|
69
|
-
assert_equal item_1.uri, ordered_source.elements[0].uri
|
70
|
-
assert_equal item_2.uri, ordered_source.elements[1].uri
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_remove
|
74
|
-
# create new OrderedSource
|
75
|
-
ordered_source = OrderedSource.new('http://testvalue.org/ordered_set_remove')
|
76
|
-
ordered_source.save!
|
77
|
-
assert ordered_source.elements.empty?
|
78
|
-
|
79
|
-
# create 3 items
|
80
|
-
item_1 = ActiveSource.new('http://testvalue.org/item_1')
|
81
|
-
item_2 = ActiveSource.new('http://testvalue.org/item_2')
|
82
|
-
|
83
|
-
# add items to ordered source
|
84
|
-
ordered_source.add item_1
|
85
|
-
ordered_source.add item_2
|
86
|
-
|
87
|
-
# check if all items are inserted
|
88
|
-
assert_equal 2, ordered_source.elements.size
|
89
|
-
assert_equal item_1.uri, ordered_source.elements[0].uri
|
90
|
-
assert_equal item_2.uri, ordered_source.elements[1].uri
|
91
|
-
|
92
|
-
# test delete item 1
|
93
|
-
ordered_source.delete 1
|
94
|
-
|
95
|
-
# check if item1 is been deleted
|
96
|
-
assert_equal 1, ordered_source.elements.size
|
97
|
-
assert_equal item_2.uri, ordered_source.elements[0].uri
|
98
|
-
|
99
|
-
# test delete item 1
|
100
|
-
ordered_source.delete 1
|
101
|
-
ordered_source.save!
|
102
|
-
|
103
|
-
# check if item1 is been deleted
|
104
|
-
assert_equal 0, ordered_source.elements.size
|
105
|
-
|
106
|
-
# add items to ordered source
|
107
|
-
ordered_source.add item_1
|
108
|
-
ordered_source.add item_2
|
109
|
-
|
110
|
-
# delete all item
|
111
|
-
ordered_source.delete_all
|
112
|
-
|
113
|
-
# check if all items are been deleted
|
114
|
-
assert_equal 0, ordered_source.elements.size
|
115
|
-
assert ordered_source.elements.empty?
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
|
-
def test_replace
|
120
|
-
# create new OrderedSource
|
121
|
-
ordered_source = OrderedSource.new('http://testvalue.org/ordered_set/replace')
|
122
|
-
ordered_source.save!
|
123
|
-
assert ordered_source.elements.empty?
|
124
|
-
|
125
|
-
# create 3 items
|
126
|
-
item_1 = ActiveSource.new('http://testvalue.org/item_1')
|
127
|
-
item_2 = ActiveSource.new('http://testvalue.org/item_2')
|
128
|
-
item_3 = ActiveSource.new('http://testvalue.org/item_3')
|
129
|
-
|
130
|
-
# add items to ordered source
|
131
|
-
ordered_source.add item_1
|
132
|
-
ordered_source.add item_2
|
133
|
-
|
134
|
-
# check if all items are inserted
|
135
|
-
assert_equal 2, ordered_source.elements.size
|
136
|
-
assert_equal item_1.uri, ordered_source.elements[0].uri
|
137
|
-
assert_equal item_2.uri, ordered_source.elements[1].uri
|
138
|
-
|
139
|
-
# test delete item 1
|
140
|
-
ordered_source.replace 1,item_3
|
141
|
-
|
142
|
-
# check if item1 is been replaced
|
143
|
-
assert_equal 2, ordered_source.elements.size
|
144
|
-
assert_not_equal item_1.uri, ordered_source.elements[0].uri
|
145
|
-
assert_equal item_3.uri, ordered_source.elements[0].uri
|
146
|
-
assert_equal item_2.uri, ordered_source.elements[1].uri
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_size
|
150
|
-
# create new OrderedSource
|
151
|
-
ordered_source = OrderedSource.new('http://testvalue.org/ordered_set/size')
|
152
|
-
ordered_source.save!
|
153
|
-
assert ordered_source.elements.empty?
|
154
|
-
|
155
|
-
# the size must be 0
|
156
|
-
assert_equal 0, ordered_source.size
|
157
|
-
|
158
|
-
# create 3 items
|
159
|
-
item_1 = ActiveSource.new('http://testvalue.org/item_1')
|
160
|
-
item_2 = ActiveSource.new('http://testvalue.org/item_2')
|
161
|
-
item_3 = ActiveSource.new('http://testvalue.org/item_3')
|
162
|
-
|
163
|
-
# add items to OrderedSource
|
164
|
-
ordered_source.insert_at(101, item_1)
|
165
|
-
ordered_source.insert_at(103, item_3)
|
166
|
-
ordered_source.insert_at(102, item_2)
|
167
|
-
|
168
|
-
# the size must be 104 (counting the 0-element
|
169
|
-
assert_equal 104, ordered_source.size
|
170
|
-
end
|
171
|
-
|
172
|
-
def test_at
|
173
|
-
# create new OrderedSource
|
174
|
-
ordered_source = OrderedSource.new('http://testvalue.org/ordered_set/at')
|
175
|
-
ordered_source.save!
|
176
|
-
assert ordered_source.elements.empty?
|
177
|
-
|
178
|
-
# the size must be 0
|
179
|
-
assert_equal 0, ordered_source.size
|
180
|
-
|
181
|
-
# create 3 items
|
182
|
-
item_1 = ActiveSource.new('http://testvalue.org/item_1')
|
183
|
-
item_2 = ActiveSource.new('http://testvalue.org/item_2')
|
184
|
-
item_3 = ActiveSource.new('http://testvalue.org/item_3')
|
185
|
-
|
186
|
-
# add items to OrderedSource
|
187
|
-
ordered_source.add item_1
|
188
|
-
ordered_source.add item_2
|
189
|
-
ordered_source.add item_3
|
190
|
-
|
191
|
-
# check at method
|
192
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(1)
|
193
|
-
assert_equal item_1.uri, ordered_source.at(1).uri
|
194
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(2)
|
195
|
-
assert_equal item_2.uri, ordered_source.at(2).uri
|
196
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(3)
|
197
|
-
assert_equal item_3.uri, ordered_source.at(3).uri
|
198
|
-
end
|
199
|
-
|
200
|
-
def test_add_more_then_10_items
|
201
|
-
# create new OrderedSource
|
202
|
-
ordered_source = OrderedSource.new('http://testvalue.org/ordered_set/tenit')
|
203
|
-
ordered_source.save!
|
204
|
-
assert_equal 0, ordered_source.elements.size, "#{ordered_source.elements.collect { |el| el.uri }}"
|
205
|
-
|
206
|
-
# the size must be 0
|
207
|
-
assert_equal 0, ordered_source.size
|
208
|
-
|
209
|
-
# create 3 items
|
210
|
-
item_1 = ActiveSource.new('http://testvalue.org/item_1')
|
211
|
-
item_2 = ActiveSource.new('http://testvalue.org/item_2')
|
212
|
-
item_3 = ActiveSource.new('http://testvalue.org/item_3')
|
213
|
-
item_4 = ActiveSource.new('http://testvalue.org/item_4')
|
214
|
-
item_5 = ActiveSource.new('http://testvalue.org/item_5')
|
215
|
-
item_6 = ActiveSource.new('http://testvalue.org/item_6')
|
216
|
-
item_7 = ActiveSource.new('http://testvalue.org/item_7')
|
217
|
-
item_8 = ActiveSource.new('http://testvalue.org/item_8')
|
218
|
-
item_9 = ActiveSource.new('http://testvalue.org/item_9')
|
219
|
-
item_10 = ActiveSource.new('http://testvalue.org/item_10')
|
220
|
-
item_11 = ActiveSource.new('http://testvalue.org/item_11')
|
221
|
-
item_12 = ActiveSource.new('http://testvalue.org/item_12')
|
222
|
-
|
223
|
-
# add items to OrderedSource
|
224
|
-
ordered_source.add item_1
|
225
|
-
ordered_source.add item_2
|
226
|
-
ordered_source.add item_3
|
227
|
-
ordered_source.add item_4
|
228
|
-
ordered_source.add item_5
|
229
|
-
ordered_source.add item_6
|
230
|
-
ordered_source.add item_7
|
231
|
-
ordered_source.add item_8
|
232
|
-
ordered_source.add item_9
|
233
|
-
ordered_source.add item_10
|
234
|
-
ordered_source.add item_11
|
235
|
-
ordered_source.add item_12
|
236
|
-
|
237
|
-
# check at method
|
238
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(1)
|
239
|
-
assert_equal item_1.uri, ordered_source.at(1).uri
|
240
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(2)
|
241
|
-
assert_equal item_2.uri, ordered_source.at(2).uri
|
242
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(3)
|
243
|
-
assert_equal item_3.uri, ordered_source.at(3).uri
|
244
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(4)
|
245
|
-
assert_equal item_4.uri, ordered_source.at(4).uri
|
246
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(5)
|
247
|
-
assert_equal item_5.uri, ordered_source.at(5).uri
|
248
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(6)
|
249
|
-
assert_equal item_6.uri, ordered_source.at(6).uri
|
250
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(7)
|
251
|
-
assert_equal item_7.uri, ordered_source.at(7).uri
|
252
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(8)
|
253
|
-
assert_equal item_8.uri, ordered_source.at(8).uri
|
254
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(9)
|
255
|
-
assert_equal item_9.uri, ordered_source.at(9).uri
|
256
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(10)
|
257
|
-
assert_equal item_10.uri, ordered_source.at(10).uri
|
258
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(11)
|
259
|
-
assert_equal item_11.uri, ordered_source.at(11).uri
|
260
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(12)
|
261
|
-
assert_equal item_12.uri, ordered_source.at(12).uri
|
262
|
-
|
263
|
-
# test order
|
264
|
-
elements = ordered_source.elements.collect { |el| el.uri }
|
265
|
-
elements_array = []
|
266
|
-
elements_array << 'http://testvalue.org/item_1'
|
267
|
-
elements_array << 'http://testvalue.org/item_2'
|
268
|
-
elements_array << 'http://testvalue.org/item_3'
|
269
|
-
elements_array << 'http://testvalue.org/item_4'
|
270
|
-
elements_array << 'http://testvalue.org/item_5'
|
271
|
-
elements_array << 'http://testvalue.org/item_6'
|
272
|
-
elements_array << 'http://testvalue.org/item_7'
|
273
|
-
elements_array << 'http://testvalue.org/item_8'
|
274
|
-
elements_array << 'http://testvalue.org/item_9'
|
275
|
-
elements_array << 'http://testvalue.org/item_10'
|
276
|
-
elements_array << 'http://testvalue.org/item_11'
|
277
|
-
elements_array << 'http://testvalue.org/item_12'
|
278
|
-
assert_equal elements_array, elements
|
279
|
-
end
|
280
|
-
|
281
|
-
def test_next_and_previous
|
282
|
-
# create new OrderedSource
|
283
|
-
ordered_source = OrderedSource.new('http://testvalue.org/ordered_set/nextprev')
|
284
|
-
ordered_source.save!
|
285
|
-
assert ordered_source.elements.empty?
|
286
|
-
|
287
|
-
# the size must be 0
|
288
|
-
assert_equal 0, ordered_source.size
|
289
|
-
|
290
|
-
# create 3 items
|
291
|
-
item_1 = ActiveSource.new('http://testvalue.org/item_1')
|
292
|
-
item_2 = ActiveSource.new('http://testvalue.org/item_2')
|
293
|
-
item_3 = ActiveSource.new('http://testvalue.org/item_3')
|
294
|
-
|
295
|
-
# add items to OrderedSource
|
296
|
-
ordered_source.add item_1
|
297
|
-
ordered_source.add item_2
|
298
|
-
ordered_source.add item_3
|
299
|
-
|
300
|
-
# test next method
|
301
|
-
item = ordered_source.at(2)
|
302
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(2)
|
303
|
-
assert_equal item_2.uri, ordered_source.at(2).uri
|
304
|
-
assert_equal 2, ordered_source.current_index
|
305
|
-
|
306
|
-
@next = ordered_source.next
|
307
|
-
assert_kind_of TaliaCore::ActiveSource, @next
|
308
|
-
assert_equal item_3.uri, @next.uri
|
309
|
-
assert_equal 3, ordered_source.current_index
|
310
|
-
|
311
|
-
assert_raise(RuntimeError) {ordered_source.next}
|
312
|
-
assert_equal 3, ordered_source.current_index
|
313
|
-
|
314
|
-
# test previous method
|
315
|
-
item = ordered_source.at(2)
|
316
|
-
assert_kind_of TaliaCore::ActiveSource, ordered_source.at(2)
|
317
|
-
assert_equal item_2.uri, ordered_source.at(2).uri
|
318
|
-
assert_equal 2, ordered_source.current_index
|
319
|
-
|
320
|
-
@previous = ordered_source.previous
|
321
|
-
assert_kind_of TaliaCore::ActiveSource, @previous
|
322
|
-
assert_equal item_1.uri, @previous.uri
|
323
|
-
assert_equal 1, ordered_source.current_index
|
324
|
-
|
325
|
-
assert_raise(RuntimeError) {ordered_source.previous}
|
326
|
-
assert_equal 1, ordered_source.current_index
|
327
|
-
|
328
|
-
# test next with index
|
329
|
-
@next = ordered_source.next(2)
|
330
|
-
assert_kind_of TaliaCore::ActiveSource, @next
|
331
|
-
assert_equal item_3.uri, @next.uri
|
332
|
-
assert_equal 3, ordered_source.current_index
|
333
|
-
|
334
|
-
assert_raise(RuntimeError) {ordered_source.next(3)}
|
335
|
-
assert_equal 3, ordered_source.current_index
|
336
|
-
|
337
|
-
# test next with element
|
338
|
-
@next = ordered_source.next(item_2)
|
339
|
-
assert_kind_of TaliaCore::ActiveSource, @next
|
340
|
-
assert_equal item_3.uri, @next.uri
|
341
|
-
assert_equal 3, ordered_source.current_index
|
342
|
-
|
343
|
-
# test previous with index
|
344
|
-
@previous = ordered_source.previous(2)
|
345
|
-
assert_kind_of TaliaCore::ActiveSource, @previous
|
346
|
-
assert_equal item_1.uri, @previous.uri
|
347
|
-
assert_equal 1, ordered_source.current_index
|
348
|
-
|
349
|
-
assert_raise(RuntimeError) {ordered_source.previous(1)}
|
350
|
-
assert_equal 1, ordered_source.current_index
|
351
|
-
|
352
|
-
# test previous with element
|
353
|
-
@previous = ordered_source.previous(item_2)
|
354
|
-
assert_kind_of TaliaCore::ActiveSource, @previous
|
355
|
-
assert_equal item_1.uri, @previous.uri
|
356
|
-
assert_equal 1, ordered_source.current_index
|
357
|
-
|
358
|
-
end
|
359
|
-
|
360
|
-
def test_find_ordered_source
|
361
|
-
# create new OrderedSource
|
362
|
-
ordered_source = OrderedSource.new('http://testvalue.org/ordered_set/find')
|
363
|
-
ordered_source.save!
|
364
|
-
assert ordered_source.elements.empty?
|
365
|
-
|
366
|
-
# the size must be 0
|
367
|
-
assert_equal 0, ordered_source.size
|
368
|
-
|
369
|
-
# create 3 items
|
370
|
-
item_1 = ActiveSource.new('http://testvalue.org/item_1')
|
371
|
-
item_2 = ActiveSource.new('http://testvalue.org/item_2')
|
372
|
-
item_3 = ActiveSource.new('http://testvalue.org/item_3')
|
373
|
-
|
374
|
-
# add items to OrderedSource
|
375
|
-
ordered_source.add item_1
|
376
|
-
ordered_source.add item_2
|
377
|
-
ordered_source.add item_3
|
378
|
-
|
379
|
-
# test find method
|
380
|
-
assert_equal 2, ordered_source.find_position_by_object(item_2)
|
381
|
-
end
|
382
|
-
|
383
|
-
def test_save_reload
|
384
|
-
ordered = OrderedSource.new('http://orderedsource_save_and_load')
|
385
|
-
item_1 = ActiveSource.new('http://orderedsource_save_and_load/item')
|
386
|
-
ordered.insert_at(15, item_1)
|
387
|
-
assert_equal(item_1, ordered.at(15))
|
388
|
-
ordered.save!
|
389
|
-
reload = OrderedSource.find(ordered.id)
|
390
|
-
assert_equal(item_1, reload.at(15))
|
391
|
-
end
|
392
|
-
|
393
|
-
end
|
394
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
# Load the helper class
|
2
|
-
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
3
|
-
|
4
|
-
module TaliaCore
|
5
|
-
|
6
|
-
# Test the ActiveSource
|
7
|
-
class SemanticCollectionItemTest < Test::Unit::TestCase
|
8
|
-
|
9
|
-
# fixtures :active_sources, :semantic_properties, :semantic_relations
|
10
|
-
|
11
|
-
def setup
|
12
|
-
setup_once(:flush) { TestHelper::flush_store }
|
13
|
-
|
14
|
-
setup_once(:fat_object_item) do
|
15
|
-
attributes = {
|
16
|
-
'id' => 1,
|
17
|
-
'created_at' => '2009-02-27 00:00:01',
|
18
|
-
'updated_at' => '2009-02-27 00:00:02',
|
19
|
-
'object_id' => 23,
|
20
|
-
'object_type' => 'TaliaCore::ActiveSource',
|
21
|
-
'subject_id' => 17,
|
22
|
-
'predicate_uri' => 'http://testpred.org/test',
|
23
|
-
'property_created_at' => nil,
|
24
|
-
'property_updated_at' => nil,
|
25
|
-
'property_value' => nil,
|
26
|
-
'object_created_at' => '2009-02-27 00:00:03',
|
27
|
-
'object_updated_at' => '2009-02-27 00:00:04',
|
28
|
-
'object_realtype' => 'TaliaCore::Source',
|
29
|
-
'object_uri' => 'http://myobject/uri',
|
30
|
-
}
|
31
|
-
fat_rel = SemanticRelation.send(:instantiate, attributes)
|
32
|
-
item = SemanticCollectionItem.new(fat_rel, :fat)
|
33
|
-
item
|
34
|
-
end
|
35
|
-
|
36
|
-
setup_once(:fat_property_item) do
|
37
|
-
attributes = {
|
38
|
-
'id' => 1,
|
39
|
-
'created_at' => '2009-02-27 00:00:01',
|
40
|
-
'updated_at' => '2009-02-27 00:00:02',
|
41
|
-
'object_id' => 24,
|
42
|
-
'object_type' => 'TaliaCore::SemanticProperty',
|
43
|
-
'subject_id' => 17,
|
44
|
-
'predicate_uri' => 'http://testpred.org/test',
|
45
|
-
'property_created_at' => '2009-02-27 00:00:05',
|
46
|
-
'property_updated_at' => '2009-02-27 00:00:06',
|
47
|
-
'property_value' => 'test value',
|
48
|
-
'object_created_at' => nil,
|
49
|
-
'object_updated_at' => nil,
|
50
|
-
'object_realtype' => nil,
|
51
|
-
'object_uri' => nil,
|
52
|
-
}
|
53
|
-
fat_rel = SemanticRelation.send(:instantiate, attributes)
|
54
|
-
item = SemanticCollectionItem.new(fat_rel, :fat)
|
55
|
-
item
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_object_id
|
60
|
-
assert_equal(23, @fat_object_item.object.id)
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_object_created
|
64
|
-
assert_equal(Time.parse('2009-02-27 00:00:03'), @fat_object_item.object.created_at)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_object_updated
|
68
|
-
assert_equal(Time.parse('2009-02-27 00:00:04'), @fat_object_item.object.updated_at)
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_object_type
|
72
|
-
assert_kind_of(Source, @fat_object_item.object)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_object_uri
|
76
|
-
assert_equal(N::URI.new('http://myobject/uri'), @fat_object_item.object.uri)
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_property_id
|
80
|
-
assert_equal(24, @fat_property_item.object.id)
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_property_created
|
84
|
-
assert_equal(Time.parse('2009-02-27 00:00:05'), @fat_property_item.object.created_at)
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_property_updated
|
88
|
-
assert_equal(Time.parse('2009-02-27 00:00:06'), @fat_property_item.object.updated_at)
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_property_class
|
92
|
-
assert_kind_of(SemanticProperty, @fat_property_item.object)
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_property_value
|
96
|
-
assert_equal('test value', @fat_property_item.object.value)
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_value
|
100
|
-
assert_equal(@fat_property_item.object.value, @fat_property_item.value)
|
101
|
-
assert_equal(@fat_object_item.object, @fat_object_item.value)
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_value_typed
|
105
|
-
@fat_object_item.instance_variable_set(:@object_type, N::URI)
|
106
|
-
assert_kind_of(N::URI, @fat_object_item.value)
|
107
|
-
@fat_object_item.instance_variable_set(:@object_type, nil)
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_prop_type_err
|
111
|
-
@fat_property_item.instance_variable_set(:@object_type, N::URI)
|
112
|
-
assert_raise(ArgumentError) { @fat_property_item.value }
|
113
|
-
@fat_property_item.instance_variable_set(:@object_type, nil)
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_equality_value
|
117
|
-
assert_equal(@fat_property_item, 'test value')
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_equality_object
|
121
|
-
assert_equal(@fat_object_item, Source.new(@fat_object_item.object.uri.to_s))
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
125
|
-
end
|