1 | ;;+----------------------------------------------------------------------------- |
---|
2 | ;;+ Isidorus |
---|
3 | ;;+ (c) 2008-2009 Marc Kuester, Christoph Ludwig, Lukas Giessmann |
---|
4 | ;;+ |
---|
5 | ;;+ Isidorus is freely distributable under the LGPL license. |
---|
6 | ;;+ You can find a detailed description in trunk/docs/LGPL-LICENSE.txt. |
---|
7 | ;;+----------------------------------------------------------------------------- |
---|
8 | |
---|
9 | |
---|
10 | (defpackage :rdf-importer-test |
---|
11 | (:use |
---|
12 | :common-lisp |
---|
13 | :xml-importer |
---|
14 | :datamodel |
---|
15 | :it.bese.FiveAM |
---|
16 | :fixtures) |
---|
17 | (:import-from :constants |
---|
18 | *rdf-ns* |
---|
19 | *rdfs-ns* |
---|
20 | *rdf2tm-ns* |
---|
21 | *tm2rdf-ns* |
---|
22 | *xml-ns* |
---|
23 | *xml-string* |
---|
24 | *instance-psi* |
---|
25 | *type-psi* |
---|
26 | *type-instance-psi* |
---|
27 | *subtype-psi* |
---|
28 | *supertype-psi* |
---|
29 | *supertype-subtype-psi* |
---|
30 | *xml-string* |
---|
31 | *rdf2tm-object* |
---|
32 | *rdf2tm-subject* |
---|
33 | *rdf-subject* |
---|
34 | *rdf-object* |
---|
35 | *rdf-predicate* |
---|
36 | *rdf-statement* |
---|
37 | *tm2rdf-topic-type-uri* |
---|
38 | *tm2rdf-name-type-uri* |
---|
39 | *tm2rdf-variant-type-uri* |
---|
40 | *tm2rdf-occurrence-type-uri* |
---|
41 | *tm2rdf-role-type-uri* |
---|
42 | *tm2rdf-association-type-uri*) |
---|
43 | (:import-from :xml-tools |
---|
44 | xpath-child-elems-by-qname |
---|
45 | xpath-single-child-elem-by-qname |
---|
46 | xpath-select-location-path |
---|
47 | get-ns-attribute |
---|
48 | absolute-uri-p) |
---|
49 | (:export :rdf-importer-test |
---|
50 | :test-get-literals-of-node |
---|
51 | :test-parse-node |
---|
52 | :run-rdf-importer-tests |
---|
53 | :test-get-literals-of-property |
---|
54 | :test-parse-property |
---|
55 | :test-get-types |
---|
56 | :test-get-literals-of-content |
---|
57 | :test-get-super-classes-of-node-content |
---|
58 | :test-get-associations-of-node-content |
---|
59 | :test-parse-properties-of-node |
---|
60 | :test-import-node-1 |
---|
61 | :test-import-dom |
---|
62 | :test-poems-rdf-occurrences |
---|
63 | :test-poems-rdf-associations |
---|
64 | :test-poems-rdf-typing |
---|
65 | :test-poems-rdf-topics |
---|
66 | :test-empty-collection |
---|
67 | :test-collection |
---|
68 | :test-xml-base |
---|
69 | :test-full-mapping-marge |
---|
70 | :test-full-mapping-homer |
---|
71 | :test-full-mapping-association)) |
---|
72 | |
---|
73 | (declaim (optimize (debug 3) (speed 0) (safety 3) (space 0) (compilation-speed 0))) |
---|
74 | |
---|
75 | (in-package :rdf-importer-test) |
---|
76 | |
---|
77 | |
---|
78 | (def-suite rdf-importer-test |
---|
79 | :description "tests various key functions of the importer") |
---|
80 | |
---|
81 | (in-suite rdf-importer-test) |
---|
82 | |
---|
83 | |
---|
84 | (defun empty-p (top) |
---|
85 | (declare (TopicC top)) |
---|
86 | (and (not (d:item-identifiers top)) |
---|
87 | (not (d:locators top)) |
---|
88 | (not (d:names top)) |
---|
89 | (not (d:occurrences top)))) |
---|
90 | |
---|
91 | |
---|
92 | (test test-get-literals-of-node |
---|
93 | "Tests the helper function get-literals-of-node." |
---|
94 | (let ((doc-1 |
---|
95 | (concatenate 'string "<rdf:Description xmlns:rdf=\"" *rdf-ns* "\" " |
---|
96 | "xmlns:isi=\"http://isidorus/test#\" " |
---|
97 | "rdf:type=\"rdfType\" rdf:ID=\"rdfID\" rdf:nodeID=\"" |
---|
98 | "rdfNodeID\" rdf:unknown=\"rdfUnknown\" " |
---|
99 | "isi:ID=\"isiID\" isi:arc=\"isiArc\" " |
---|
100 | "isi:empty=\"\"/>"))) |
---|
101 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder)))) |
---|
102 | (is (= (length (dom:child-nodes dom-1)) 1)) |
---|
103 | (let ((literals (rdf-importer::get-literals-of-node |
---|
104 | (elt (dom:child-nodes dom-1) 0) nil))) |
---|
105 | (is-true literals) |
---|
106 | (is (= (length literals) 4)) |
---|
107 | (is-true (find-if #'(lambda(x) |
---|
108 | (and |
---|
109 | (string= (getf x :value) "rdfUnknown") |
---|
110 | (string= (getf x :type) |
---|
111 | (concatenate 'string *rdf-ns* "unknown")) |
---|
112 | (not (getf x :ID)))) |
---|
113 | literals)) |
---|
114 | (is-true (find-if #'(lambda(x) |
---|
115 | (and |
---|
116 | (string= (getf x :value) "isiID") |
---|
117 | (string= (getf x :type) |
---|
118 | "http://isidorus/test#ID") |
---|
119 | (not (getf x :ID)))) |
---|
120 | literals)) |
---|
121 | (is-true (find-if #'(lambda(x) |
---|
122 | (and |
---|
123 | (string= (getf x :value) "isiArc") |
---|
124 | (string= (getf x :type) |
---|
125 | "http://isidorus/test#arc") |
---|
126 | (not (getf x :ID)))) |
---|
127 | literals)) |
---|
128 | (is-true (find-if #'(lambda(x) |
---|
129 | (and |
---|
130 | (string= (getf x :value) "") |
---|
131 | (string= (getf x :type) |
---|
132 | "http://isidorus/test#empty") |
---|
133 | (not (getf x :ID)))) |
---|
134 | literals)) |
---|
135 | (map 'list #'(lambda(x) (is-false (getf x :lang))) |
---|
136 | literals))) |
---|
137 | |
---|
138 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder)))) |
---|
139 | (is (= (length (dom:child-nodes dom-1)) 1)) |
---|
140 | (dom:set-attribute-ns (elt (dom:child-nodes dom-1) 0) |
---|
141 | *xml-ns* "lang" "de") |
---|
142 | (let ((literals (rdf-importer::get-literals-of-node |
---|
143 | (elt (dom:child-nodes dom-1) 0) "en"))) |
---|
144 | (is-true literals) |
---|
145 | (is (= (length literals) 4)) |
---|
146 | (is-true (find-if #'(lambda(x) |
---|
147 | (and |
---|
148 | (string= (getf x :value) "rdfUnknown") |
---|
149 | (string= (getf x :type) |
---|
150 | (concatenate 'string *rdf-ns* "unknown")) |
---|
151 | (not (getf x :ID)))) |
---|
152 | literals)) |
---|
153 | (is-true (find-if #'(lambda(x) |
---|
154 | (and |
---|
155 | (string= (getf x :value) "isiID") |
---|
156 | (string= (getf x :type) |
---|
157 | "http://isidorus/test#ID") |
---|
158 | (not (getf x :ID)))) |
---|
159 | literals)) |
---|
160 | (is-true (find-if #'(lambda(x) |
---|
161 | (and |
---|
162 | (string= (getf x :value) "isiArc") |
---|
163 | (string= (getf x :type) |
---|
164 | "http://isidorus/test#arc") |
---|
165 | (not (getf x :ID)))) |
---|
166 | literals)) |
---|
167 | (is-true (find-if #'(lambda(x) |
---|
168 | (and |
---|
169 | (string= (getf x :value) "") |
---|
170 | (string= (getf x :type) |
---|
171 | "http://isidorus/test#empty") |
---|
172 | (not (getf x :ID)))) |
---|
173 | literals)) |
---|
174 | (map 'list #'(lambda(x) (is-true (string= (getf x :lang) "de"))) |
---|
175 | literals))))) |
---|
176 | |
---|
177 | |
---|
178 | (test test-parse-node |
---|
179 | "Tests the parse-node function." |
---|
180 | (let ((doc-1 |
---|
181 | (concatenate 'string "<rdf:UnknownType xmlns:rdf=\"" *rdf-ns* "\" " |
---|
182 | "xmlns:isi=\"" *rdf2tm-ns* "\" " |
---|
183 | "xmlns:arcs=\"http://test/arcs/\" " |
---|
184 | "rdf:ID=\"rdfID\" xml:base=\"xmlBase\" " |
---|
185 | "arcs:arc=\"arcsArc\">" |
---|
186 | "<arcs:rel>" |
---|
187 | "<rdf:Description rdf:about=\"element\"/>" |
---|
188 | "</arcs:rel>" |
---|
189 | "</rdf:UnknownType>"))) |
---|
190 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder)))) |
---|
191 | (is (length (dom:child-nodes dom-1)) 1) |
---|
192 | (let ((node (elt (dom:child-nodes dom-1) 0))) |
---|
193 | (is-true (rdf-importer::parse-node node)) |
---|
194 | (is-false (get-ns-attribute node "UUID" :ns-uri *rdf2tm-ns*)) |
---|
195 | (dom:set-attribute-ns node *rdf-ns* "about" "rdfAbout") |
---|
196 | (signals error (rdf-importer::parse-node node)) |
---|
197 | (dom:set-attribute-ns node *rdf-ns* "nodeID" "rdfNodeID") |
---|
198 | (signals error (rdf-importer::parse-node node)) |
---|
199 | (dom:remove-attribute-ns node *rdf-ns* "about") |
---|
200 | (signals error (rdf-importer::parse-node node)) |
---|
201 | (dom:remove-attribute-ns node *rdf-ns* "ID") |
---|
202 | (is-true (rdf-importer::parse-node node)) |
---|
203 | (dom:set-attribute-ns node *rdf-ns* "about" "rdfAbout") |
---|
204 | (signals error (rdf-importer::parse-node node)) |
---|
205 | (is-false (get-ns-attribute node "UUID" :ns-uri *rdf2tm-ns*)) |
---|
206 | (dom:remove-attribute-ns node *rdf-ns* "about") |
---|
207 | (dom:remove-attribute-ns node *rdf-ns* "nodeID") |
---|
208 | (is-true (rdf-importer::parse-node node)) |
---|
209 | (is-true (get-ns-attribute node "UUID" :ns-uri *rdf2tm-ns*)) |
---|
210 | (dom:set-attribute-ns node *rdf-ns* "resource" "rdfResource") |
---|
211 | (signals error (rdf-importer::parse-node node)) |
---|
212 | (dom:set-attribute-ns node *rdf-ns* "resource" "") |
---|
213 | (is-true (rdf-importer::parse-node node)) |
---|
214 | (dom:replace-child node (dom:create-text-node dom-1 "anyText") |
---|
215 | (xpath-single-child-elem-by-qname |
---|
216 | node "http://test/arcs/" "rel")) |
---|
217 | (signals error (rdf-importer::parse-node node)))))) |
---|
218 | |
---|
219 | |
---|
220 | (test test-get-literals-of-property |
---|
221 | "Tests the function get-literals-or-property." |
---|
222 | (let ((doc-1 |
---|
223 | (concatenate 'string "<prop:property xmlns:prop=\"http://props/\" " |
---|
224 | "xmlns:rdf=\"" *rdf-ns* "\" " |
---|
225 | "xmlns:rdfs=\"" *rdfs-ns* "\" " |
---|
226 | "rdf:type=\"rdfType\" rdf:resource=\"rdfResource\" " |
---|
227 | "rdf:nodeID=\"rdfNodeID\" " |
---|
228 | "prop:prop1=\"http://should/be/a/literal\" " |
---|
229 | "prop:prop2=\"prop-2\" " |
---|
230 | "prop:prop3=\"\">content-text</prop:property>"))) |
---|
231 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder)))) |
---|
232 | (is-true dom-1) |
---|
233 | (is (= (length (dom:child-nodes dom-1)) 1)) |
---|
234 | (let ((property (elt (dom:child-nodes dom-1) 0))) |
---|
235 | (let ((literals (rdf-importer::get-literals-of-property property nil))) |
---|
236 | (is (= (length literals) 3)) |
---|
237 | (is-true (find-if #'(lambda(x) |
---|
238 | (and |
---|
239 | (string= (getf x :value) |
---|
240 | "http://should/be/a/literal") |
---|
241 | (string= (getf x :type) "http://props/prop1") |
---|
242 | (not (getf x :ID)))) |
---|
243 | literals)) |
---|
244 | (is-true (find-if #'(lambda(x) |
---|
245 | (and |
---|
246 | (string= (getf x :value) "prop-2") |
---|
247 | (string= (getf x :type) "http://props/prop2") |
---|
248 | (not (getf x :ID)))) |
---|
249 | literals)) |
---|
250 | (is-true (find-if #'(lambda(x) |
---|
251 | (and |
---|
252 | (string= (getf x :value) "") |
---|
253 | (string= (getf x :type) "http://props/prop3") |
---|
254 | (not (getf x :ID)))) |
---|
255 | literals))))))) |
---|
256 | |
---|
257 | |
---|
258 | (test test-parse-property |
---|
259 | "Tests the function parse-property." |
---|
260 | (let ((doc-1 |
---|
261 | (concatenate 'string "<rdf:Description xmlns:rdf=\"" *rdf-ns* "\" " |
---|
262 | "xmlns:rdfs=\"" *rdfs-ns* "\" " |
---|
263 | "xmlns:prop=\"http://isidorus/props/\">" |
---|
264 | "<prop:prop0 rdf:parseType=\"Resource\" />" |
---|
265 | "<prop:prop1 rdf:parseType=\"Resource\">" |
---|
266 | "<prop:prop1_0 rdf:resource=\"prop21\" />" |
---|
267 | "</prop:prop1>" |
---|
268 | "<prop:prop2 rdf:parseType=\"Literal\">" |
---|
269 | "<content_root>content-text</content_root>" |
---|
270 | "</prop:prop2>" |
---|
271 | "<prop:prop3 rdf:parseType=\"Collection\" />" |
---|
272 | "<prop:prop4 rdf:parseType=\"Collection\">" |
---|
273 | "<prop:prop4_0 rdf:resource=\"prop5_1\" />" |
---|
274 | "<prop:prop4_1 rdf:nodeID=\"prop5_2\" />" |
---|
275 | "<prop:prop4_2/>" |
---|
276 | "</prop:prop4>" |
---|
277 | "<prop:prop5 />" |
---|
278 | "<prop:prop6>prop6</prop:prop6>" |
---|
279 | "<prop:prop7 rdf:nodeID=\"prop7\"/>" |
---|
280 | "<prop:prop8 rdf:resource=\"prop8\" />" |
---|
281 | "<prop:prop9 rdf:type=\"typeProp9\"> </prop:prop9>" |
---|
282 | "<prop:prop10 rdf:datatype=\"datatypeProp10\" />" |
---|
283 | "<prop:prop11 rdf:ID=\"IDProp11\"> </prop:prop11>" |
---|
284 | "<prop:prop12 rdf:ID=\"IDprop12\" rdf:nodeID=\"prop12\">" |
---|
285 | " </prop:prop12>" |
---|
286 | "<prop:prop13 />" |
---|
287 | "<prop:prop14>prop14</prop:prop14>" |
---|
288 | "<prop:prop15 rdf:nodeID=\"prop15\"/>" |
---|
289 | "<prop:prop16 rdf:resource=\"prop16\" />" |
---|
290 | "<prop:prop17 rdf:type=\"typeProp17\"> </prop:prop17>" |
---|
291 | "<prop:prop18 rdf:ID=\"IDprop18\" rdf:nodeID=\"prop18\">" |
---|
292 | " </prop:prop18>" |
---|
293 | "</rdf:Description>"))) |
---|
294 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder)))) |
---|
295 | (is-true dom-1) |
---|
296 | (is (= (length (dom:child-nodes dom-1)) 1)) |
---|
297 | (let ((child (elt (dom:child-nodes dom-1) 0))) |
---|
298 | (let ((children (rdf-importer::child-nodes-or-text child)) |
---|
299 | (text-node (dom:create-text-node dom-1 "new text node"))) |
---|
300 | (is (= (length children) 19)) |
---|
301 | (loop for property across children |
---|
302 | do (is-true (rdf-importer::parse-property property 0))) |
---|
303 | (dotimes (i (length children)) |
---|
304 | (if (or (= i 0) (= i 1) (= i 3) (= i 4) (= i 9) (= i 17)) |
---|
305 | (is-true (get-ns-attribute (elt children i) "UUID" |
---|
306 | :ns-uri *rdf2tm-ns*)) |
---|
307 | (is-false (get-ns-attribute (elt children i) "UUID" |
---|
308 | :ns-uri *rdf2tm-ns*)))) |
---|
309 | (let ((prop (elt children 0))) |
---|
310 | (dom:set-attribute-ns prop *rdf-ns* "parseType" "Unknown") |
---|
311 | (signals error (rdf-importer::parse-property prop 0)) |
---|
312 | (dom:set-attribute-ns prop *rdf-ns* "parseType" "Resource") |
---|
313 | (is-true (rdf-importer::parse-property prop 0)) |
---|
314 | (dom:set-attribute-ns prop *rdf-ns* "ID" "newID") |
---|
315 | (is-true (rdf-importer::parse-property prop 0)) |
---|
316 | (dom:set-attribute-ns prop *rdf-ns* "bad" "bad") |
---|
317 | (signals error (rdf-importer::parse-property prop 0)) |
---|
318 | (dom:remove-attribute-ns prop *rdf-ns* "bad") |
---|
319 | (is-true (rdf-importer::parse-property prop 0)) |
---|
320 | (dom:append-child prop text-node) |
---|
321 | (signals error (rdf-importer::parse-property prop 0)) |
---|
322 | (dom:remove-child prop text-node) |
---|
323 | (is-true (rdf-importer::parse-property prop 0))) |
---|
324 | (let ((prop (elt children 1))) |
---|
325 | (dom:set-attribute-ns prop *rdf-ns* "nodeID" "bad") |
---|
326 | (signals error (rdf-importer::parse-property prop 0)) |
---|
327 | (dom:remove-attribute-ns prop *rdf-ns* "nodeID") |
---|
328 | (is-true (rdf-importer::parse-property prop 0)) |
---|
329 | (dom:set-attribute-ns prop *rdf-ns* "ID" "newID") |
---|
330 | (is-true (rdf-importer::parse-property prop 0)) |
---|
331 | (dom:append-child prop text-node) |
---|
332 | (signals error (rdf-importer::parse-property prop 0)) |
---|
333 | (dom:remove-child prop text-node) |
---|
334 | (is-true (rdf-importer::parse-property prop 0))) |
---|
335 | (let ((prop (elt children 3))) |
---|
336 | (dom:append-child prop text-node) |
---|
337 | (signals error (rdf-importer::parse-property prop 0)) |
---|
338 | (dom:remove-child prop text-node) |
---|
339 | (is-true (rdf-importer::parse-property prop 0))) |
---|
340 | (let ((prop (elt children 4))) |
---|
341 | (dom:append-child prop text-node) |
---|
342 | (signals error (rdf-importer::parse-property prop 0)) |
---|
343 | (dom:remove-child prop text-node) |
---|
344 | (is-true (rdf-importer::parse-property prop 0))) |
---|
345 | (let ((prop (elt children 5))) |
---|
346 | (dom:set-attribute-ns prop *rdf-ns* "type" "newType") |
---|
347 | (is-true (rdf-importer::parse-property prop 0)) |
---|
348 | (dom:set-attribute-ns prop *rdf-ns* "unknown" "unknown") |
---|
349 | (is-true (rdf-importer::parse-property prop 0)) |
---|
350 | (dom:append-child prop text-node) |
---|
351 | (dom:remove-child prop text-node) |
---|
352 | (is-true (rdf-importer::parse-property prop 0)) |
---|
353 | (dom:remove-attribute-ns prop *rdf-ns* "unknown") |
---|
354 | (is-true (rdf-importer::parse-property prop 0)) |
---|
355 | (dom:append-child prop text-node) |
---|
356 | (signals error (rdf-importer::parse-property prop 0)) |
---|
357 | (dom:remove-child prop text-node) |
---|
358 | (is-true (rdf-importer::parse-property prop 0))) |
---|
359 | (let ((prop (elt children 10))) |
---|
360 | (dom:set-attribute-ns prop *rdf-ns* "type" "newType") |
---|
361 | (signals error (rdf-importer::parse-property prop 0)) |
---|
362 | (dom:remove-attribute-ns prop *rdf-ns* "type") |
---|
363 | (is-true (rdf-importer::parse-property prop 0)) |
---|
364 | (dom:set-attribute-ns prop *rdf-ns* "nodeID" "newNodeID") |
---|
365 | (signals error (rdf-importer::parse-property prop 0)) |
---|
366 | (dom:remove-attribute-ns prop *rdf-ns* "nodeID") |
---|
367 | (is-true (rdf-importer::parse-property prop 0)) |
---|
368 | (dom:set-attribute-ns prop *rdf-ns* "resource" "newResource") |
---|
369 | (signals error (rdf-importer::parse-property prop 0)) |
---|
370 | (dom:remove-attribute-ns prop *rdf-ns* "resource") |
---|
371 | (is-true (rdf-importer::parse-property prop 0)) |
---|
372 | (dom:set-attribute-ns prop *rdf-ns* "ID" "newID") |
---|
373 | (is-true (rdf-importer::parse-property prop 0)))))))) |
---|
374 | |
---|
375 | |
---|
376 | (test test-get-types |
---|
377 | "Tests the functions get-type-of-node-name, get-types-of-content, |
---|
378 | get-node-rerfs, absolute-uri-p, absolutize-value and absolutize-id." |
---|
379 | (let ((tm-id "http://test-tm") |
---|
380 | (doc-1 |
---|
381 | (concatenate 'string "<rdf:anyType xmlns:rdf=\"" *rdf-ns* "\" " |
---|
382 | "xmlns:isi=\"" *rdf2tm-ns* "\" " |
---|
383 | "xmlns:arcs=\"http://test/arcs/\" " |
---|
384 | "xml:base=\"xml-base/first\" " |
---|
385 | "rdf:about=\"resource\" rdf:type=\"attr-type\">" |
---|
386 | "<rdf:type rdf:ID=\"rdfID\" " |
---|
387 | "rdf:resource=\"content-type-1\"/>" |
---|
388 | "<rdf:type /><!-- blank_node -->" |
---|
389 | "<rdf:type arcs:arc=\"literalArc\"/>" |
---|
390 | "<rdf:type rdf:parseType=\"Collection\" " |
---|
391 | " xml:base=\"http://xml-base/absolute/\">" |
---|
392 | "<!-- blank_node that is a list -->" |
---|
393 | "<rdf:Description rdf:about=\"c-about-type\"/>" |
---|
394 | "<rdf:Description rdf:ID=\"c-id-type\"/>" |
---|
395 | "<rdf:Description rdf:nodeID=\"c-nodeID-type\"/>" |
---|
396 | "<rdf:Description/><!-- blank_node -->" |
---|
397 | "</rdf:type>" |
---|
398 | "<rdf:type rdf:ID=\"rdfID2\">" |
---|
399 | "<rdf:Description rdf:about=\"c-about-type-2\"/>" |
---|
400 | "</rdf:type>" |
---|
401 | "<rdf:type>" |
---|
402 | "<rdf:Description rdf:nodeID=\"c-nodeID-type-2\"/>" |
---|
403 | "</rdf:type>" |
---|
404 | "<rdf:type xml:base=\"http://new-base/\">" |
---|
405 | "<rdf:Description rdf:ID=\"c-ID-type-2\"/>" |
---|
406 | "</rdf:type>" |
---|
407 | "<rdf:type rdf:ID=\"rdfID3\">" |
---|
408 | "<rdf:Description/>" |
---|
409 | "</rdf:type>" |
---|
410 | "<arcs:arc rdf:resource=\"anyArc\"/>" |
---|
411 | "<rdf:arc>" |
---|
412 | "<rdf:Description rdf:about=\"anyResource\"/>" |
---|
413 | "</rdf:arc>" |
---|
414 | "</rdf:anyType>"))) |
---|
415 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder)))) |
---|
416 | (is-true dom-1) |
---|
417 | (is (= (length (dom:child-nodes dom-1)) 1)) |
---|
418 | (is-true (absolute-uri-p tm-id)) |
---|
419 | (is-false (absolute-uri-p "http//bad")) |
---|
420 | (is-false (absolute-uri-p "")) |
---|
421 | (is-false (absolute-uri-p " ")) |
---|
422 | (is-false (absolute-uri-p nil)) |
---|
423 | (let ((node (elt (dom:child-nodes dom-1) 0))) |
---|
424 | (loop for property across (rdf-importer::child-nodes-or-text node) |
---|
425 | do (rdf-importer::parse-property property 0)) |
---|
426 | (let ((types |
---|
427 | (append |
---|
428 | (list (list |
---|
429 | :topicid (rdf-importer::get-type-of-node-name node) |
---|
430 | :psi (rdf-importer::get-type-of-node-name node) |
---|
431 | :ID nil)) |
---|
432 | (rdf-importer::get-types-of-node-content node tm-id nil))) |
---|
433 | (node-uuid (get-ns-attribute |
---|
434 | (elt (rdf-importer::child-nodes-or-text |
---|
435 | (elt (rdf-importer::child-nodes-or-text node) 7)) |
---|
436 | 0) |
---|
437 | "UUID" :ns-uri *rdf2tm-ns*))) |
---|
438 | (is (= (length types) 10)) |
---|
439 | (is-true (find-if |
---|
440 | #'(lambda(x) |
---|
441 | (and (string= (getf x :topicid) |
---|
442 | (concatenate |
---|
443 | 'string *rdf-ns* "anyType")) |
---|
444 | (string= (getf x :topicid) |
---|
445 | (concatenate |
---|
446 | 'string *rdf-ns* "anyType")) |
---|
447 | (not (getf x :ID)))) |
---|
448 | types)) |
---|
449 | (is-true (find-if |
---|
450 | #'(lambda(x) |
---|
451 | (and (string= (getf x :topicid) |
---|
452 | (concatenate |
---|
453 | 'string tm-id |
---|
454 | "/xml-base/first/attr-type")) |
---|
455 | (string= (getf x :psi) |
---|
456 | (concatenate |
---|
457 | 'string tm-id |
---|
458 | "/xml-base/first/attr-type")) |
---|
459 | (not (getf x :ID)))) |
---|
460 | types)) |
---|
461 | (is-true (find-if |
---|
462 | #'(lambda(x) |
---|
463 | (and (string= (getf x :topicid) |
---|
464 | "http://test-tm/xml-base/first/content-type-1") |
---|
465 | (string= (getf x :psi) |
---|
466 | "http://test-tm/xml-base/first/content-type-1") |
---|
467 | (string= (getf x :ID) |
---|
468 | "http://test-tm/xml-base/first#rdfID"))) |
---|
469 | types)) |
---|
470 | (is-true (find-if |
---|
471 | #'(lambda(x) |
---|
472 | (and (string= (getf x :topicid) |
---|
473 | (concatenate |
---|
474 | 'string tm-id |
---|
475 | "/xml-base/first/c-about-type-2")) |
---|
476 | (string= (getf x :psi) |
---|
477 | (concatenate |
---|
478 | 'string tm-id |
---|
479 | "/xml-base/first/c-about-type-2")) |
---|
480 | (string= (getf x :ID) |
---|
481 | "http://test-tm/xml-base/first#rdfID2"))) |
---|
482 | types)) |
---|
483 | (is-true (find-if |
---|
484 | #'(lambda(x) |
---|
485 | (and (string= (getf x :topicid) "c-nodeID-type-2") |
---|
486 | (not (getf x :psi)) |
---|
487 | (not (getf x :ID)))) |
---|
488 | types)) |
---|
489 | (is-true (find-if |
---|
490 | #'(lambda(x) |
---|
491 | (and (string= (getf x :topicid) |
---|
492 | "http://new-base#c-ID-type-2") |
---|
493 | (string= (getf x :psi) |
---|
494 | "http://new-base#c-ID-type-2") |
---|
495 | (not (getf x :ID)))) |
---|
496 | types)) |
---|
497 | (is-true (find-if |
---|
498 | #'(lambda(x) |
---|
499 | (and (string= (getf x :topicid) node-uuid) |
---|
500 | (not (getf x :psi)) |
---|
501 | (string= (getf x :ID) |
---|
502 | "http://test-tm/xml-base/first#rdfID3"))) |
---|
503 | types)) |
---|
504 | (is-true (= 10 (count-if #'(lambda(x) |
---|
505 | (> (length (getf x :topicid)) 0)) |
---|
506 | types)))))))) |
---|
507 | |
---|
508 | |
---|
509 | (test test-get-literals-of-content |
---|
510 | (let ((doc-1 |
---|
511 | (concatenate 'string "<rdf:Description xmlns:rdf=\"" *rdf-ns* "\" " |
---|
512 | "xmlns:rdfs=\"" *rdfs-ns* "\" " |
---|
513 | "xmlns:prop=\"http://isidorus/props/\" " |
---|
514 | "xml:base=\"base/first\" xml:lang=\"de\" >" |
---|
515 | "<prop:lit0>text0</prop:lit0>" |
---|
516 | "<prop:lit1 rdf:parseType=\"Literal\">text1</prop:lit1>" |
---|
517 | "<prop:lit2 xml:base=\"http://base/absolute\" " |
---|
518 | "rdf:datatype=\"dType1\">text2</prop:lit2>" |
---|
519 | "<prop:arc rdf:parseType=\"Collection\"/>" |
---|
520 | "<prop:lit3 xml:lang=\"en\" rdf:datatype=\"dType2\">" |
---|
521 | "<![CDATA[text3]]></prop:lit3>" |
---|
522 | "<prop:lit4 rdf:datatype=\"dType2\"><root><child/></root>" |
---|
523 | " </prop:lit4>" |
---|
524 | "<prop:lit5 rdf:ID=\"rdfID\" " |
---|
525 | "rdf:parseType=\"Literal\"><root><child>" |
---|
526 | "childText5</child> </root></prop:lit5>" |
---|
527 | "<prop:lit6 xml:lang=\"\" rdf:parseType=\"Literal\">" |
---|
528 | " <![CDATA[text6]]> abc " |
---|
529 | "</prop:lit6>" |
---|
530 | "</rdf:Description>"))) |
---|
531 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder))) |
---|
532 | (tm-id "http://test-tm")) |
---|
533 | (is-true dom-1) |
---|
534 | (is (= (length (dom:child-nodes dom-1)) 1)) |
---|
535 | (let ((node (elt (dom:child-nodes dom-1) 0))) |
---|
536 | (dotimes (iter (length (dom:child-nodes node))) |
---|
537 | (is-true (rdf-importer::parse-property |
---|
538 | (elt (dom:child-nodes node) iter) 0))) |
---|
539 | (let ((literals (rdf-importer::get-literals-of-node-content |
---|
540 | node tm-id nil nil))) |
---|
541 | (is (= (length literals) 7)) |
---|
542 | (is-true (find-if |
---|
543 | #'(lambda(x) |
---|
544 | (and (string= (getf x :value) "text0") |
---|
545 | (string= (getf x :type) |
---|
546 | "http://isidorus/props/lit0") |
---|
547 | (not (getf x :ID)) |
---|
548 | (string= (getf x :lang) "de") |
---|
549 | (string= (getf x :datatype) *xml-string*))) |
---|
550 | literals)) |
---|
551 | (is-true (find-if |
---|
552 | #'(lambda(x) |
---|
553 | (and (string= (getf x :value) "text1") |
---|
554 | (string= (getf x :type) |
---|
555 | "http://isidorus/props/lit1") |
---|
556 | (not (getf x :ID)) |
---|
557 | (string= (getf x :lang) "de") |
---|
558 | (string= (getf x :datatype) *xml-string*))) |
---|
559 | literals)) |
---|
560 | (is-true (find-if |
---|
561 | #'(lambda(x) |
---|
562 | (and (string= (getf x :value) "text2") |
---|
563 | (string= (getf x :type) |
---|
564 | "http://isidorus/props/lit2") |
---|
565 | (not (getf x :ID)) |
---|
566 | (string= (getf x :lang) "de") |
---|
567 | (string= (getf x :datatype) |
---|
568 | "http://base/absolute/dType1"))) |
---|
569 | literals)) |
---|
570 | (is-true (find-if |
---|
571 | #'(lambda(x) |
---|
572 | (and (string= (getf x :value) "text3") |
---|
573 | (string= (getf x :type) |
---|
574 | "http://isidorus/props/lit3") |
---|
575 | (not (getf x :ID)) |
---|
576 | (string= (getf x :lang) "en") |
---|
577 | (string= (getf x :datatype) |
---|
578 | "http://test-tm/base/first/dType2"))) |
---|
579 | literals)) |
---|
580 | (is-true (find-if |
---|
581 | #'(lambda(x) |
---|
582 | (and (string= (getf x :value) |
---|
583 | "<root><child></child></root> ") |
---|
584 | (string= (getf x :type) |
---|
585 | "http://isidorus/props/lit4") |
---|
586 | (not (getf x :ID)) |
---|
587 | (string= (getf x :lang) "de") |
---|
588 | (string= (getf x :datatype) |
---|
589 | "http://test-tm/base/first/dType2"))) |
---|
590 | literals)) |
---|
591 | (is-true (find-if |
---|
592 | #'(lambda(x) |
---|
593 | (and (string= (getf x :value) |
---|
594 | "<root><child>childText5</child> </root>") |
---|
595 | (string= (getf x :type) |
---|
596 | "http://isidorus/props/lit5") |
---|
597 | (string= (getf x :ID) |
---|
598 | "http://test-tm/base/first#rdfID") |
---|
599 | (string= (getf x :lang) "de") |
---|
600 | (string= (getf x :datatype) *xml-string*))) |
---|
601 | literals)) |
---|
602 | (is-true (find-if |
---|
603 | #'(lambda(x) |
---|
604 | (and (string= (getf x :value) " text6 abc ") |
---|
605 | (string= (getf x :type) |
---|
606 | "http://isidorus/props/lit6") |
---|
607 | (not (getf x :ID)) |
---|
608 | (not (getf x :lang)) |
---|
609 | (string= (getf x :datatype) *xml-string*))) |
---|
610 | literals))))))) |
---|
611 | |
---|
612 | |
---|
613 | (test test-get-super-classes-of-node-content |
---|
614 | (let ((doc-1 |
---|
615 | (concatenate 'string "<rdf:Description xmlns:rdf=\"" *rdf-ns* "\" " |
---|
616 | "xmlns:isi=\"" *rdf2tm-ns* "\" " |
---|
617 | "xmlns:rdfs=\"" *rdfs-ns* "\" " |
---|
618 | "xmlns:arcs=\"http://test/arcs/\" " |
---|
619 | "xml:base=\"xml-base/first\" " |
---|
620 | "rdf:about=\"resource\" rdf:type=\"attr-type\">" |
---|
621 | "<rdfs:subClassOf rdf:ID=\"rdfID\" " |
---|
622 | "rdf:resource=\"content-type-1\"/>" |
---|
623 | "<rdfs:subClassOf /><!-- blank_node -->" |
---|
624 | "<rdfs:subClassOf arcs:arc=\"literalArc\"/>" |
---|
625 | "<rdfs:subClassOf rdf:parseType=\"Collection\" " |
---|
626 | " xml:base=\"http://xml-base/absolute/\">" |
---|
627 | "<!-- blank_node that is a list -->" |
---|
628 | "<rdf:Description rdf:about=\"c-about-type\"/>" |
---|
629 | "<rdf:Description rdf:ID=\"c-id-type\"/>" |
---|
630 | "<rdf:Description rdf:nodeID=\"c-nodeID-type\"/>" |
---|
631 | "<rdf:Description/><!-- blank_node -->" |
---|
632 | "</rdfs:subClassOf>" |
---|
633 | "<rdfs:subClassOf rdf:ID=\"rdfID2\">" |
---|
634 | "<rdf:Description rdf:about=\"c-about-type-2\"/>" |
---|
635 | "</rdfs:subClassOf>" |
---|
636 | "<rdfs:subClassOf>" |
---|
637 | "<rdf:Description rdf:nodeID=\"c-nodeID-type-2\"/>" |
---|
638 | "</rdfs:subClassOf>" |
---|
639 | "<rdfs:subClassOf xml:base=\"http://new-base/\">" |
---|
640 | "<rdf:Description rdf:ID=\"c-ID-type-2\"/>" |
---|
641 | "</rdfs:subClassOf>" |
---|
642 | "<rdfs:subClassOf rdf:ID=\"rdfID3\">" |
---|
643 | "<rdf:Description/>" |
---|
644 | "</rdfs:subClassOf>" |
---|
645 | "<arcs:arc rdf:resource=\"anyArc\"/>" |
---|
646 | "<rdfs:arc>" |
---|
647 | "<rdf:Description rdf:about=\"anyResource\"/>" |
---|
648 | "</rdfs:arc>" |
---|
649 | "</rdf:Description>"))) |
---|
650 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder)))) |
---|
651 | (is-true dom-1) |
---|
652 | (is (= (length (dom:child-nodes dom-1)))) |
---|
653 | (let ((node (elt (dom:child-nodes dom-1) 0)) |
---|
654 | (tm-id "http://test-tm") |
---|
655 | (xml-base "/base/initial")) |
---|
656 | (is-true node) |
---|
657 | (is-true (rdf-importer::parse-node node)) |
---|
658 | (loop for property across (rdf-importer::child-nodes-or-text node) |
---|
659 | do (is-true (rdf-importer::parse-property property 0))) |
---|
660 | (let ((super-classes (rdf-importer::get-super-classes-of-node-content |
---|
661 | node tm-id xml-base))) |
---|
662 | (is (= (length super-classes) 8)) |
---|
663 | (is-true |
---|
664 | (find-if |
---|
665 | #'(lambda(x) |
---|
666 | (and |
---|
667 | (string= |
---|
668 | (getf x :psi) |
---|
669 | "http://test-tm/base/initial/xml-base/first/content-type-1") |
---|
670 | (string= |
---|
671 | (getf x :topicid) |
---|
672 | "http://test-tm/base/initial/xml-base/first/content-type-1") |
---|
673 | (string= |
---|
674 | (getf x :ID) |
---|
675 | "http://test-tm/base/initial/xml-base/first#rdfID"))) |
---|
676 | super-classes)) |
---|
677 | (is-true (find-if |
---|
678 | #'(lambda(x) |
---|
679 | (and |
---|
680 | (string= |
---|
681 | (getf x :topicid) |
---|
682 | (concatenate 'string tm-id xml-base |
---|
683 | "/xml-base/first/c-about-type-2")) |
---|
684 | (string= |
---|
685 | (getf x :psi) |
---|
686 | (concatenate 'string tm-id xml-base |
---|
687 | "/xml-base/first/c-about-type-2")) |
---|
688 | (string= (getf x :ID) |
---|
689 | (concatenate 'string tm-id xml-base |
---|
690 | "/xml-base/first#rdfID2")))) |
---|
691 | super-classes)) |
---|
692 | (is-true (find-if |
---|
693 | #'(lambda(x) |
---|
694 | (and (string= (getf x :topicid) "c-nodeID-type-2") |
---|
695 | (not (getf x :psi)) |
---|
696 | (not (getf x :ID)))) |
---|
697 | super-classes)) |
---|
698 | (is-true (find-if |
---|
699 | #'(lambda(x) |
---|
700 | (and (string= (getf x :topicid) |
---|
701 | "http://new-base#c-ID-type-2") |
---|
702 | (string= (getf x :psi) |
---|
703 | "http://new-base#c-ID-type-2") |
---|
704 | (not (getf x :ID)))) |
---|
705 | super-classes)) |
---|
706 | (is (= (count-if #'(lambda(x) (> (length (getf x :topicid)) 0)) |
---|
707 | super-classes) |
---|
708 | 8)) |
---|
709 | (is-true (find-if |
---|
710 | #'(lambda(x) |
---|
711 | (and |
---|
712 | (string= |
---|
713 | (getf x :ID) |
---|
714 | "http://test-tm/base/initial/xml-base/first#rdfID3") |
---|
715 | (not (getf x :psi)) |
---|
716 | (> (length (getf x :topicid))))) |
---|
717 | super-classes)) |
---|
718 | (dom:append-child (elt (rdf-importer::child-nodes-or-text node) 1) |
---|
719 | (dom:create-text-node dom-1 "new text")) |
---|
720 | (signals error (rdf-importer::parse-property |
---|
721 | (elt (rdf-importer::child-nodes-or-text node) 1) 0))))))) |
---|
722 | |
---|
723 | |
---|
724 | (test test-get-associations-of-node-content |
---|
725 | (let ((doc-1 |
---|
726 | (concatenate 'string "<rdf:Description xmlns:rdf=\"" *rdf-ns* "\" " |
---|
727 | "xmlns:isi=\"" *rdf2tm-ns* "\" " |
---|
728 | "xmlns:rdfs=\"" *rdfs-ns* "\" " |
---|
729 | "xmlns:arcs=\"http://test/arcs/\" " |
---|
730 | "xml:base=\"http://xml-base/first\" " |
---|
731 | "rdf:about=\"resource\" rdf:type=\"attr-type\">" |
---|
732 | "<rdf:type rdf:resource=\"anyType\" />" |
---|
733 | "<rdf:type> </rdf:type>" |
---|
734 | "<rdfs:subClassOf rdf:nodeID=\"anyClass\" />" |
---|
735 | "<rdfs:subClassOf> </rdfs:subClassOf>" |
---|
736 | "<rdf:unknown rdf:resource=\"assoc-1\"/>" |
---|
737 | "<rdfs:unknown rdf:type=\"assoc-2-type\">" |
---|
738 | " </rdfs:unknown>" |
---|
739 | "<arcs:arc1 rdf:ID=\"rdfID-1\" " |
---|
740 | "rdf:nodeID=\"arc1-nodeID\"/>" |
---|
741 | "<arcs:arc2 rdf:parseType=\"Collection\">" |
---|
742 | "<rdf:Description rdf:about=\"col\" />" |
---|
743 | "</arcs:arc2>" |
---|
744 | "<arcs:arc3 rdf:parseType=\"Resource\" " |
---|
745 | "rdf:ID=\"rdfID-2\" />" |
---|
746 | "<arcs:lit rdf:parseType=\"Literal\" />" |
---|
747 | "<arcs:arc4 arcs:arc5=\"text-arc5\" />" |
---|
748 | "<arcs:arc6 rdf:ID=\"rdfID-3\">" |
---|
749 | "<rdf:Description rdf:about=\"con-1\" />" |
---|
750 | "</arcs:arc6>" |
---|
751 | "<arcs:arc7>" |
---|
752 | "<rdf:Description rdf:nodeID=\"con-2\" />" |
---|
753 | "</arcs:arc7>" |
---|
754 | "<arcs:arc8>" |
---|
755 | "<rdf:Description rdf:ID=\"rdfID-4\" />" |
---|
756 | "</arcs:arc8>" |
---|
757 | "<arcs:arc9 rdf:ID=\"rdfID-5\" xml:base=\"add\">" |
---|
758 | "<rdf:Description />" |
---|
759 | "</arcs:arc9>" |
---|
760 | "<rdfs:type rdf:resource=\"assoc-11\"> </rdfs:type>" |
---|
761 | "<rdf:subClassOf rdf:nodeID=\"assoc-12\" />" |
---|
762 | "</rdf:Description>"))) |
---|
763 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder))) |
---|
764 | (tm-id "http://test-tm")) |
---|
765 | (is-true dom-1) |
---|
766 | (is (= (length (dom:child-nodes dom-1)) 1)) |
---|
767 | (let ((node (elt (dom:child-nodes dom-1) 0))) |
---|
768 | (loop for property across (rdf-importer::child-nodes-or-text node) |
---|
769 | do (is-true (rdf-importer::parse-property property 0))) |
---|
770 | (let ((associations |
---|
771 | (rdf-importer::get-associations-of-node-content node tm-id nil))) |
---|
772 | (is (= (length associations) 12)) |
---|
773 | (is-true (find-if |
---|
774 | #'(lambda(x) |
---|
775 | (and (string= (getf x :type) |
---|
776 | (concatenate 'string *rdf-ns* "unknown")) |
---|
777 | (string= (getf x :topicid) |
---|
778 | "http://xml-base/first/assoc-1") |
---|
779 | (string= (getf x :psi) |
---|
780 | "http://xml-base/first/assoc-1") |
---|
781 | (not (getf x :ID)))) |
---|
782 | associations)) |
---|
783 | (is-true (find-if |
---|
784 | #'(lambda(x) |
---|
785 | (and (string= (getf x :type) "http://test/arcs/arc1") |
---|
786 | (string= (getf x :ID) "http://xml-base/first#rdfID-1") |
---|
787 | (string= (getf x :topicid) "arc1-nodeID") |
---|
788 | (not (getf x :psi)))) |
---|
789 | associations)) |
---|
790 | (is-true (find-if |
---|
791 | #'(lambda(x) |
---|
792 | (and (string= (getf x :type) "http://test/arcs/arc2") |
---|
793 | (> (length (getf x :topicid)) 0) |
---|
794 | (not (getf x :psi)) |
---|
795 | (not (getf x :ID)))) |
---|
796 | associations)) |
---|
797 | (is-true (find-if |
---|
798 | #'(lambda(x) |
---|
799 | (and (string= (getf x :type) "http://test/arcs/arc3") |
---|
800 | (string= (getf x :ID) |
---|
801 | "http://xml-base/first#rdfID-2") |
---|
802 | (not (getf x :psi)) |
---|
803 | (> (length (getf x :topicid)) 0))) |
---|
804 | associations)) |
---|
805 | (is-true (find-if |
---|
806 | #'(lambda(x) |
---|
807 | (and (string= (getf x :type) "http://test/arcs/arc4") |
---|
808 | (not (getf x :ID)) |
---|
809 | (not (getf x :psi)) |
---|
810 | (> (length (getf x :topicid)) 0))) |
---|
811 | associations)) |
---|
812 | (is-true (find-if |
---|
813 | #'(lambda(x) |
---|
814 | (and (string= (getf x :type) "http://test/arcs/arc4") |
---|
815 | (not (getf x :ID)) |
---|
816 | (not (getf x :psi)) |
---|
817 | (> (length (getf x :topicid)) 0))) |
---|
818 | associations)) |
---|
819 | (is-true (find-if |
---|
820 | #'(lambda(x) |
---|
821 | (and (string= (getf x :type) "http://test/arcs/arc6") |
---|
822 | (string= (getf x :ID) |
---|
823 | "http://xml-base/first#rdfID-3") |
---|
824 | (string= (getf x :topicid) |
---|
825 | "http://xml-base/first/con-1") |
---|
826 | (string= (getf x :psi) |
---|
827 | "http://xml-base/first/con-1"))) |
---|
828 | associations)) |
---|
829 | (is-true (find-if |
---|
830 | #'(lambda(x) |
---|
831 | (and (string= (getf x :type) "http://test/arcs/arc7") |
---|
832 | (not (getf x :ID)) |
---|
833 | (string= (getf x :topicid) "con-2") |
---|
834 | (not (getf x :psi)))) |
---|
835 | associations)) |
---|
836 | (is-true (find-if |
---|
837 | #'(lambda(x) |
---|
838 | (and (string= (getf x :type) "http://test/arcs/arc8") |
---|
839 | (not (getf x :ID)) |
---|
840 | (string= (getf x :topicid) |
---|
841 | "http://xml-base/first#rdfID-4") |
---|
842 | (string= (getf x :psi) |
---|
843 | "http://xml-base/first#rdfID-4"))) |
---|
844 | associations)) |
---|
845 | (is-true (find-if |
---|
846 | #'(lambda(x) |
---|
847 | (and (string= (getf x :type) "http://test/arcs/arc9") |
---|
848 | (string= (getf x :ID) |
---|
849 | "http://xml-base/first/add#rdfID-5") |
---|
850 | (not (getf x :psi)) |
---|
851 | (> (length (getf x :topicid))))) |
---|
852 | associations)) |
---|
853 | (is-true (find-if |
---|
854 | #'(lambda(x) |
---|
855 | (and (string= (getf x :type) |
---|
856 | (concatenate 'string *rdfs-ns* "type")) |
---|
857 | (not (getf x :ID)) |
---|
858 | (string= (getf x :psi) |
---|
859 | "http://xml-base/first/assoc-11") |
---|
860 | (string= (getf x :topicid) |
---|
861 | "http://xml-base/first/assoc-11"))) |
---|
862 | associations)) |
---|
863 | (is-true (find-if |
---|
864 | #'(lambda(x) |
---|
865 | (and (string= (getf x :type) |
---|
866 | (concatenate 'string *rdf-ns* |
---|
867 | "subClassOf")) |
---|
868 | (not (getf x :ID)) |
---|
869 | (not (getf x :psi)) |
---|
870 | (string= (getf x :topicid) "assoc-12"))) |
---|
871 | associations))))))) |
---|
872 | |
---|
873 | |
---|
874 | (test test-parse-properties-of-node |
---|
875 | (let ((doc-1 |
---|
876 | (concatenate 'string "<rdf:Description xmlns:rdf=\"" *rdf-ns* "\" " |
---|
877 | "xmlns:arcs=\"http://test/arcs/\" " |
---|
878 | "xml:base=\"http://xml-base/first\" " |
---|
879 | "rdf:about=\"resource\" rdf:type=\"attr-type\" " |
---|
880 | "rdf:li=\"li-attr\">" |
---|
881 | "<rdf:li rdf:resource=\"anyType\" />" |
---|
882 | "<rdf:li> text-1 </rdf:li>" |
---|
883 | "<rdf:li rdf:nodeID=\"anyClass\" />" |
---|
884 | "<rdf:li> </rdf:li>" |
---|
885 | "<rdf:li rdf:resource=\"assoc-1\"/>" |
---|
886 | "<rdf:li rdf:type=\"assoc-2-type\">" |
---|
887 | " </rdf:li>" |
---|
888 | "<rdf:li rdf:parseType=\"Literal\" > text-3</rdf:li>" |
---|
889 | "<rdf:_123 arcs:arc5=\"text-arc5\"/>" |
---|
890 | "<rdf:arc6 rdf:ID=\"rdfID-3\"> text-4 </rdf:arc6>" |
---|
891 | "<rdf:arcs rdf:ID=\"rdfID-4\" xml:lang=\" \">" |
---|
892 | "text-5</rdf:arcs>" |
---|
893 | "</rdf:Description>"))) |
---|
894 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder))) |
---|
895 | (tm-id "http://test-tm")) |
---|
896 | (setf rdf-importer::*_n-map* nil) |
---|
897 | (is-true dom-1) |
---|
898 | (is (= (length (dom:child-nodes dom-1)))) |
---|
899 | (let ((node (elt (dom:child-nodes dom-1) 0))) |
---|
900 | (is-true (rdf-importer::parse-node node)) |
---|
901 | (is-true (rdf-importer::parse-properties-of-node |
---|
902 | node "http://xml-base/first/resource")) |
---|
903 | (is (= (length rdf-importer::*_n-map*) 1)) |
---|
904 | (is (= (length (getf (first rdf-importer::*_n-map*) :props)) 8)) |
---|
905 | (dotimes (iter (length rdf-importer::*_n-map*)) |
---|
906 | (is-true (find-if |
---|
907 | #'(lambda(x) |
---|
908 | (string= (getf x :name) |
---|
909 | (concatenate |
---|
910 | 'string *rdf-ns* "_" |
---|
911 | (write-to-string (+ 1 iter))))) |
---|
912 | (getf (first rdf-importer::*_n-map*) :props)))) |
---|
913 | (let ((assocs |
---|
914 | (rdf-importer::get-associations-of-node-content node tm-id nil)) |
---|
915 | (content-literals |
---|
916 | (rdf-importer::get-literals-of-node-content node tm-id nil "de")) |
---|
917 | (attr-literals |
---|
918 | (rdf-importer::get-literals-of-node node nil))) |
---|
919 | (is (= (length assocs) 5)) |
---|
920 | (is (= (length content-literals) 5)) |
---|
921 | (is (= (length attr-literals) 1)) |
---|
922 | (is-true (find-if #'(lambda(x) |
---|
923 | (and (string= (getf x :type) |
---|
924 | (concatenate 'string *rdf-ns* "_1")) |
---|
925 | (not (getf x :lang)) |
---|
926 | (string= (getf x :value) "li-attr") |
---|
927 | (not (getf x :lang)) |
---|
928 | (not (getf x :ID)))) |
---|
929 | attr-literals)) |
---|
930 | (is-true (find-if #'(lambda(x) |
---|
931 | (and (string= (getf x :topicid) |
---|
932 | "http://xml-base/first/anyType") |
---|
933 | (string= (getf x :psi) |
---|
934 | "http://xml-base/first/anyType") |
---|
935 | (string= (getf x :type) |
---|
936 | (concatenate 'string *rdf-ns* "_2")) |
---|
937 | (not (getf x :ID)))) |
---|
938 | assocs)) |
---|
939 | (is-true (find-if #'(lambda(x) |
---|
940 | (and (string= (getf x :value) " text-1 ") |
---|
941 | (string= (getf x :lang) "de") |
---|
942 | (string= (getf x :datatype) *xml-string*) |
---|
943 | (string= (getf x :type) |
---|
944 | (concatenate 'string *rdf-ns* "_3")) |
---|
945 | (not (getf x :ID)))) |
---|
946 | content-literals)) |
---|
947 | (is-true (find-if #'(lambda(x) |
---|
948 | (and (string= (getf x :topicid) "anyClass") |
---|
949 | (not (getf x :psi)) |
---|
950 | (string= (getf x :type) |
---|
951 | (concatenate 'string *rdf-ns* "_4")) |
---|
952 | (not (getf x :ID)))) |
---|
953 | assocs)) |
---|
954 | (is-true (find-if #'(lambda(x) |
---|
955 | (and (string= (getf x :value) " ") |
---|
956 | (string= (getf x :type) |
---|
957 | (concatenate 'string *rdf-ns* "_5")) |
---|
958 | (string= (getf x :datatype) *xml-string*) |
---|
959 | (string= (getf x :lang) "de") |
---|
960 | (not (getf x :ID)))) |
---|
961 | content-literals)) |
---|
962 | (is-true (find-if #'(lambda(x) |
---|
963 | (and (string= (getf x :topicid) |
---|
964 | "http://xml-base/first/assoc-1") |
---|
965 | (string= (getf x :psi) |
---|
966 | "http://xml-base/first/assoc-1") |
---|
967 | (string= (getf x :type) |
---|
968 | (concatenate 'string *rdf-ns* "_6")) |
---|
969 | (not (getf x :ID)))) |
---|
970 | assocs)) |
---|
971 | (is-true (find-if #'(lambda(x) |
---|
972 | (and (> (length (getf x :topicid)) 0) |
---|
973 | (not (getf x :psi)) |
---|
974 | (string= (getf x :type) |
---|
975 | (concatenate 'string *rdf-ns* "_7")) |
---|
976 | (not (getf x :ID)))) |
---|
977 | assocs)) |
---|
978 | (is-true (find-if #'(lambda(x) |
---|
979 | (and (string= (getf x :value) " text-3") |
---|
980 | (string= (getf x :lang) "de") |
---|
981 | (string= (getf x :datatype) *xml-string*) |
---|
982 | (string= (getf x :type) |
---|
983 | (concatenate 'string *rdf-ns* "_8")) |
---|
984 | (not (getf x :ID)))) |
---|
985 | content-literals)) |
---|
986 | (is-true (find-if #'(lambda(x) |
---|
987 | (and (string= (getf x :value) " text-4 ") |
---|
988 | (string= (getf x :lang) "de") |
---|
989 | (string= (getf x :datatype) *xml-string*) |
---|
990 | (string= |
---|
991 | (getf x :type) |
---|
992 | (concatenate 'string *rdf-ns* "arc6")) |
---|
993 | (string= |
---|
994 | (getf x :ID) |
---|
995 | "http://xml-base/first#rdfID-3"))) |
---|
996 | content-literals)) |
---|
997 | (is-true (find-if #'(lambda(x) |
---|
998 | (and (string= (getf x :value) "text-5") |
---|
999 | (string= (getf x :lang) nil) |
---|
1000 | (string= (getf x :datatype) *xml-string*) |
---|
1001 | (string= |
---|
1002 | (getf x :type) |
---|
1003 | (concatenate 'string *rdf-ns* "arcs")) |
---|
1004 | (string= |
---|
1005 | (getf x :ID) |
---|
1006 | "http://xml-base/first#rdfID-4"))) |
---|
1007 | content-literals))) |
---|
1008 | (setf rdf-importer::*_n-map* nil))))) |
---|
1009 | |
---|
1010 | |
---|
1011 | (test test-import-node-1 |
---|
1012 | "Tests the function import-node non-recursively." |
---|
1013 | (let ((db-dir "data_base") |
---|
1014 | (tm-id "http://test-tm/") |
---|
1015 | (revision-1 100) |
---|
1016 | (revision-2 200) |
---|
1017 | (revision-3 300) |
---|
1018 | (document-id "doc-id") |
---|
1019 | (doc-1 |
---|
1020 | (concatenate 'string "<rdf:RDF xmlns:rdf=\"" *rdf-ns* "\" " |
---|
1021 | "xmlns:arcs=\"http://test/arcs/\" " |
---|
1022 | "xmlns:rdfs=\"" *rdfs-ns* "\">" |
---|
1023 | "<rdf:Description rdf:about=\"first-node\">" |
---|
1024 | "<rdf:type rdf:resource=\"first-type\" />" |
---|
1025 | "</rdf:Description>" |
---|
1026 | "<rdf:Description rdf:type=\"second-type\" " |
---|
1027 | "rdf:nodeID=\"second-node\">" |
---|
1028 | "<rdfs:subClassOf>" |
---|
1029 | "<rdf:Description rdf:ID=\"third-node\" />" |
---|
1030 | "</rdfs:subClassOf>" |
---|
1031 | "</rdf:Description>" |
---|
1032 | "<rdf:Description arcs:arc1=\"arc-1\">" |
---|
1033 | "<arcs:arc2 rdf:datatype=\"dt\">arc-2</arcs:arc2>" |
---|
1034 | "</rdf:Description>" |
---|
1035 | "<rdf:Description rdf:about=\"fourth-node\">" |
---|
1036 | "<arcs:arc3 rdf:parseType=\"Literal\"><root>" |
---|
1037 | "<content type=\"anyContent\">content</content>" |
---|
1038 | "</root></arcs:arc3>" |
---|
1039 | "</rdf:Description>" |
---|
1040 | "<rdf:Description rdf:ID=\"fifth-node\">" |
---|
1041 | "<arcs:arc4 rdf:parseType=\"Resource\">" |
---|
1042 | "<arcs:arc5 rdf:resource=\"arc-5\" />" |
---|
1043 | "</arcs:arc4>" |
---|
1044 | "</rdf:Description>" |
---|
1045 | "</rdf:RDF>"))) |
---|
1046 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder)))) |
---|
1047 | (is-true dom-1) |
---|
1048 | (is (= (length (dom:child-nodes dom-1)) 1)) |
---|
1049 | (let ((rdf-node (elt (dom:child-nodes dom-1) 0))) |
---|
1050 | (is (= (length (dom:child-nodes rdf-node)) 5)) |
---|
1051 | (let ((node (elt (dom:child-nodes rdf-node) 0))) |
---|
1052 | (rdf-init-db :db-dir db-dir :start-revision revision-1) |
---|
1053 | (rdf-importer::import-node node tm-id revision-2 |
---|
1054 | :document-id document-id) |
---|
1055 | (is (= (length (elephant:get-instances-by-class 'd:TopicC)) 20)) |
---|
1056 | (let ((first-node (get-item-by-id "http://test-tm/first-node" |
---|
1057 | :xtm-id document-id |
---|
1058 | :revision 0)) |
---|
1059 | (first-type (get-item-by-id "http://test-tm/first-type" |
---|
1060 | :xtm-id document-id |
---|
1061 | :revision 0))) |
---|
1062 | (is-true first-node) |
---|
1063 | (is (= (length (d::versions first-node)) 1)) |
---|
1064 | (is (= (d::start-revision (first (d::versions first-node))) |
---|
1065 | revision-2)) |
---|
1066 | (is (= (d::end-revision (first (d::versions first-node))) 0)) |
---|
1067 | (is-true first-type) |
---|
1068 | (is (= (length (d:player-in-roles first-node)) 1)) |
---|
1069 | (is (= (length (d:player-in-roles first-type)) 1)) |
---|
1070 | (let ((instance-role |
---|
1071 | (first (d:player-in-roles first-node :revision 0))) |
---|
1072 | (type-role |
---|
1073 | (first (d:player-in-roles first-type :revision 0))) |
---|
1074 | (type-assoc |
---|
1075 | (d:parent (first (d:player-in-roles first-node :revision 0)) |
---|
1076 | :revision 0))) |
---|
1077 | (is (= (length (d::versions type-assoc)) 1)) |
---|
1078 | (is (= (d::start-revision (first (d::versions type-assoc))) |
---|
1079 | revision-2)) |
---|
1080 | (is (eql (d:instance-of instance-role) |
---|
1081 | (d:get-item-by-psi *instance-psi*))) |
---|
1082 | (is (eql (d:instance-of type-role) |
---|
1083 | (d:get-item-by-psi *type-psi*))) |
---|
1084 | (is (eql (d:instance-of type-assoc) |
---|
1085 | (d:get-item-by-psi *type-instance-psi*))) |
---|
1086 | (is (= (length (d:roles type-assoc :revision 0)) 2)) |
---|
1087 | (is (= (length (d:psis first-node)) 1)) |
---|
1088 | (is (= (length (d:psis first-type)) 1)) |
---|
1089 | (is (string= (d:uri (first (d:psis first-node))) |
---|
1090 | "http://test-tm/first-node")) |
---|
1091 | (is (string= (d:uri (first (d:psis first-type))) |
---|
1092 | "http://test-tm/first-type")) |
---|
1093 | (is (= (length (elephant:get-instances-by-class 'd:OccurrenceC)))) |
---|
1094 | (is (= (length (elephant:get-instances-by-class 'd:NameC)))) |
---|
1095 | (is (= (length (elephant:get-instances-by-class 'd:VariantC))))) |
---|
1096 | (dotimes (iter (length (dom:child-nodes rdf-node))) |
---|
1097 | (rdf-importer::import-node (elt (dom:child-nodes rdf-node) iter) |
---|
1098 | tm-id revision-3 |
---|
1099 | :document-id document-id)) |
---|
1100 | (let ((first-node (get-item-by-id "http://test-tm/first-node" |
---|
1101 | :xtm-id document-id |
---|
1102 | :revision 0)) |
---|
1103 | (first-type (get-item-by-id "http://test-tm/first-type" |
---|
1104 | :xtm-id document-id |
---|
1105 | :revision 0)) |
---|
1106 | (second-node (get-item-by-id "second-node" |
---|
1107 | :xtm-id document-id |
---|
1108 | :revision 0)) |
---|
1109 | (second-type (get-item-by-id "http://test-tm/second-type" |
---|
1110 | :xtm-id document-id |
---|
1111 | :revision 0)) |
---|
1112 | (third-node (get-item-by-id "http://test-tm#third-node" |
---|
1113 | :xtm-id document-id |
---|
1114 | :revision 0))) |
---|
1115 | (is-true second-node) |
---|
1116 | (is-false (d:psis second-node :revision 0)) |
---|
1117 | (is-false (d:occurrences second-node :revision 0)) |
---|
1118 | (is-false (d:names second-node :revision 0)) |
---|
1119 | (is-true first-node) |
---|
1120 | (is (= (length (d::versions first-node)) 2)) |
---|
1121 | (is-true (find-if #'(lambda(x) |
---|
1122 | (and (= (d::start-revision x) revision-2) |
---|
1123 | (= (d::end-revision x) revision-3))) |
---|
1124 | (d::versions first-node))) |
---|
1125 | (is-true (find-if #'(lambda(x) |
---|
1126 | (and (= (d::start-revision x) revision-3) |
---|
1127 | (= (d::end-revision x) 0))) |
---|
1128 | (d::versions first-node))) |
---|
1129 | (let ((instance-role |
---|
1130 | (first (d:player-in-roles first-node :revision 0))) |
---|
1131 | (type-role |
---|
1132 | (first (d:player-in-roles first-type :revision 0))) |
---|
1133 | (type-assoc |
---|
1134 | (d:parent (first (d:player-in-roles first-node |
---|
1135 | :revision 0)))) |
---|
1136 | (type-topic (get-item-by-psi *type-psi* :revision 0)) |
---|
1137 | (instance-topic (get-item-by-psi *instance-psi* :revision 0)) |
---|
1138 | (type-instance-topic (get-item-by-psi *type-instance-psi* |
---|
1139 | :revision 0)) |
---|
1140 | (supertype-topic (get-item-by-psi *supertype-psi* |
---|
1141 | :revision 0)) |
---|
1142 | (subtype-topic (get-item-by-psi *subtype-psi* |
---|
1143 | :revision 0)) |
---|
1144 | (supertype-subtype-topic |
---|
1145 | (get-item-by-psi *supertype-subtype-psi* :revision 0)) |
---|
1146 | (arc2-occurrence (elephant:get-instance-by-value |
---|
1147 | 'd:OccurrenceC 'd:charvalue "arc-2")) |
---|
1148 | (arc3-occurrence |
---|
1149 | (elephant:get-instance-by-value |
---|
1150 | 'd:OccurrenceC 'd:charvalue |
---|
1151 | "<root><content type=\"anyContent\">content</content></root>")) |
---|
1152 | (fifth-node (d:get-item-by-id "http://test-tm#fifth-node" |
---|
1153 | :xtm-id document-id |
---|
1154 | :revision 0))) |
---|
1155 | (is (eql (d:instance-of instance-role :revision 0) |
---|
1156 | (d:get-item-by-psi *instance-psi* :revision 0))) |
---|
1157 | (is (eql (d:instance-of type-role :revision 0) |
---|
1158 | (d:get-item-by-psi *type-psi* :revision 0))) |
---|
1159 | (is (eql (d:instance-of type-assoc :revision 0) |
---|
1160 | (d:get-item-by-psi *type-instance-psi* :revision 0))) |
---|
1161 | (is (= (length (d:roles type-assoc :revision 0)) 2)) |
---|
1162 | (is (= (length (d:psis first-node :revision 0)) 1)) |
---|
1163 | (is (= (length (d:psis first-type :revision 0)) 1)) |
---|
1164 | (is (= (length (d::versions type-assoc)) 2)) |
---|
1165 | (is (= (length (d:player-in-roles second-node :revision 0)) 2)) |
---|
1166 | (is-true (find-if |
---|
1167 | #'(lambda(x) |
---|
1168 | (and (eql (d:instance-of x) instance-topic) |
---|
1169 | (eql (d:instance-of (d:parent x) ) |
---|
1170 | type-instance-topic))) |
---|
1171 | (d:player-in-roles second-node))) |
---|
1172 | (is-true (find-if |
---|
1173 | #'(lambda(x) |
---|
1174 | (and (eql (d:instance-of x) subtype-topic) |
---|
1175 | (eql (d:instance-of (d:parent x) ) |
---|
1176 | supertype-subtype-topic))) |
---|
1177 | (d:player-in-roles second-node))) |
---|
1178 | (is-true (find-if |
---|
1179 | #'(lambda(x) |
---|
1180 | (and (eql (d:instance-of x) type-topic) |
---|
1181 | (eql (d:instance-of (d:parent x) ) |
---|
1182 | type-instance-topic))) |
---|
1183 | (d:player-in-roles second-type))) |
---|
1184 | (is-true (find-if |
---|
1185 | #'(lambda(x) |
---|
1186 | (and (eql (d:instance-of x) supertype-topic) |
---|
1187 | (eql (d:instance-of (d:parent x) ) |
---|
1188 | supertype-subtype-topic))) |
---|
1189 | (d:player-in-roles third-node))) |
---|
1190 | (is-true arc2-occurrence) |
---|
1191 | (is (string= (d:datatype arc2-occurrence) "http://test-tm/dt")) |
---|
1192 | (is-false (d:psis (d:parent arc2-occurrence))) |
---|
1193 | (is (= (length (d::versions (d:parent arc2-occurrence))) 1)) |
---|
1194 | (is (= (d::start-revision |
---|
1195 | (first (d::versions (d:parent arc2-occurrence)))) |
---|
1196 | revision-3)) |
---|
1197 | (is (= (d::end-revision |
---|
1198 | (first (d::versions (d:parent arc2-occurrence)))) 0)) |
---|
1199 | (is-true arc3-occurrence) |
---|
1200 | (is (= (length (d:psis (d:parent arc3-occurrence))))) |
---|
1201 | (is (string= (d:uri (first (d:psis (d:parent arc3-occurrence)))) |
---|
1202 | "http://test-tm/fourth-node")) |
---|
1203 | (is (string= (d:datatype arc3-occurrence) |
---|
1204 | *xml-string*)) |
---|
1205 | (is-true fifth-node) |
---|
1206 | (is (= (length (d:psis fifth-node)) 1)) |
---|
1207 | (is (string= (d:uri (first (d:psis fifth-node))) |
---|
1208 | "http://test-tm#fifth-node")) |
---|
1209 | (is-false (d:occurrences fifth-node)) |
---|
1210 | (is-false (d:names fifth-node)) |
---|
1211 | (is (= (length (d:player-in-roles fifth-node)))) |
---|
1212 | (let ((assoc (d:parent (first (d:player-in-roles |
---|
1213 | fifth-node))))) |
---|
1214 | (is-true assoc) |
---|
1215 | (let ((object-role |
---|
1216 | (find-if |
---|
1217 | #'(lambda(role) |
---|
1218 | (eql (d:instance-of role) |
---|
1219 | (d:get-item-by-psi *rdf2tm-object*))) |
---|
1220 | (d:roles assoc))) |
---|
1221 | (subject-role |
---|
1222 | (find-if |
---|
1223 | #'(lambda(role) |
---|
1224 | (eql (d:instance-of role) |
---|
1225 | (d:get-item-by-psi *rdf2tm-subject*))) |
---|
1226 | (d:roles assoc)))) |
---|
1227 | (is-true object-role) |
---|
1228 | (is-true subject-role) |
---|
1229 | (is (eql (d:player subject-role) fifth-node)) |
---|
1230 | (is-false (d:psis (d:player object-role)))))))))))) |
---|
1231 | (elephant:close-store)) |
---|
1232 | |
---|
1233 | |
---|
1234 | (test test-import-dom |
---|
1235 | "Tests the function import-node when used recursively." |
---|
1236 | (let ((db-dir "data_base") |
---|
1237 | (tm-id "http://test-tm/") |
---|
1238 | (revision-1 100) |
---|
1239 | (document-id "doc-id") |
---|
1240 | (doc-1 |
---|
1241 | (concatenate 'string "<rdf:RDF xmlns:rdf=\"" *rdf-ns* "\" " |
---|
1242 | "xmlns:arcs=\"http://test/arcs/\">" |
---|
1243 | " <rdf:Description rdf:about=\"first-node\">" |
---|
1244 | " <rdf:type rdf:nodeID=\"second-node\"/>" |
---|
1245 | " <arcs:arc1 rdf:resource=\"third-node\"/>" |
---|
1246 | " <arcs:arc2 rdf:datatype=\"long\">123</arcs:arc2>" |
---|
1247 | " <arcs:arc3>" |
---|
1248 | " <rdf:Description>" |
---|
1249 | " <arcs:arc4 rdf:parseType=\"Collection\">" |
---|
1250 | " <rdf:Description rdf:about=\"item-1\"/>" |
---|
1251 | " <rdf:Description rdf:about=\"item-2\">" |
---|
1252 | " <arcs:arc5 rdf:parseType=\"Resource\">" |
---|
1253 | " <arcs:arc6 rdf:resource=\"fourth-node\"/>" |
---|
1254 | " <arcs:arc7>" |
---|
1255 | " <rdf:Description rdf:about=\"fifth-node\"/>" |
---|
1256 | " </arcs:arc7>" |
---|
1257 | " <arcs:arc8 rdf:parseType=\"Collection\" />" |
---|
1258 | " </arcs:arc5>" |
---|
1259 | " </rdf:Description>" |
---|
1260 | " </arcs:arc4>" |
---|
1261 | " </rdf:Description>" |
---|
1262 | " </arcs:arc3>" |
---|
1263 | " </rdf:Description>" |
---|
1264 | " <rdf:Description rdf:nodeID=\"second-node\" />" |
---|
1265 | "</rdf:RDF>"))) |
---|
1266 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder)))) |
---|
1267 | (is-true dom-1) |
---|
1268 | (is (= (length (dom:child-nodes dom-1)) 1)) |
---|
1269 | (rdf-init-db :db-dir db-dir :start-revision revision-1) |
---|
1270 | (let ((rdf-node (elt (dom:child-nodes dom-1) 0))) |
---|
1271 | (is (= (length (rdf-importer::child-nodes-or-text rdf-node |
---|
1272 | :trim t)) |
---|
1273 | 2)) |
---|
1274 | (rdf-importer::import-dom rdf-node revision-1 :tm-id tm-id |
---|
1275 | :document-id document-id) |
---|
1276 | (is (= (length (elephant:get-instances-by-class 'd:TopicC)) 40)) |
---|
1277 | (is (= (length (elephant:get-instances-by-class 'd:AssociationC)) 12)) |
---|
1278 | (setf rdf-importer::*current-xtm* document-id) |
---|
1279 | (is (= (length |
---|
1280 | (intersection |
---|
1281 | (map 'list #'d:instance-of |
---|
1282 | (elephant:get-instances-by-class 'd:AssociationC)) |
---|
1283 | (list |
---|
1284 | (d:get-item-by-id (concatenate |
---|
1285 | 'string |
---|
1286 | constants::*rdf-nil*) |
---|
1287 | :xtm-id rdf-importer::*rdf-core-xtm*) |
---|
1288 | (d:get-item-by-psi constants::*type-instance-psi*) |
---|
1289 | (dotimes (iter 9) |
---|
1290 | (let ((pos (+ iter 1)) |
---|
1291 | (topics nil)) |
---|
1292 | (when (/= pos 2) |
---|
1293 | (push (get-item-by-id |
---|
1294 | (concatenate |
---|
1295 | 'string "http://test/arcs/arc" |
---|
1296 | (write-to-string pos))) topics)) |
---|
1297 | topics))))))) |
---|
1298 | (let ((first-node (get-item-by-id "http://test-tm/first-node")) |
---|
1299 | (second-node (get-item-by-id "second-node")) |
---|
1300 | (third-node (get-item-by-id "http://test-tm/third-node")) |
---|
1301 | (fourth-node (get-item-by-id "http://test-tm/fourth-node")) |
---|
1302 | (fifth-node (get-item-by-id "http://test-tm/fifth-node")) |
---|
1303 | (item-1 (get-item-by-id "http://test-tm/item-1")) |
---|
1304 | (item-2 (get-item-by-id "http://test-tm/item-2")) |
---|
1305 | (arc1 (get-item-by-id "http://test/arcs/arc1")) |
---|
1306 | (arc2 (get-item-by-id "http://test/arcs/arc2")) |
---|
1307 | (arc3 (get-item-by-id "http://test/arcs/arc3")) |
---|
1308 | (arc4 (get-item-by-id "http://test/arcs/arc4")) |
---|
1309 | (arc5 (get-item-by-id "http://test/arcs/arc5")) |
---|
1310 | (arc6 (get-item-by-id "http://test/arcs/arc6")) |
---|
1311 | (arc7 (get-item-by-id "http://test/arcs/arc7")) |
---|
1312 | (arc8 (get-item-by-id "http://test/arcs/arc8")) |
---|
1313 | (instance (d:get-item-by-psi constants::*instance-psi*)) |
---|
1314 | (type (d:get-item-by-psi constants::*type-psi*)) |
---|
1315 | (type-instance (d:get-item-by-psi |
---|
1316 | constants:*type-instance-psi*)) |
---|
1317 | (subject (d:get-item-by-psi constants::*rdf2tm-subject*)) |
---|
1318 | (object (d:get-item-by-psi constants::*rdf2tm-object*)) |
---|
1319 | (rdf-first (d:get-item-by-psi constants:*rdf-first*)) |
---|
1320 | (rdf-rest (d:get-item-by-psi constants:*rdf-rest*)) |
---|
1321 | (rdf-nil (d:get-item-by-psi constants:*rdf-nil*))) |
---|
1322 | (is (= (length (d:psis first-node)) 1)) |
---|
1323 | (is (string= (d:uri (first (d:psis first-node))) |
---|
1324 | "http://test-tm/first-node")) |
---|
1325 | (is (= (length (d:psis second-node)) 0)) |
---|
1326 | (is (= (length (d:psis third-node)) 1)) |
---|
1327 | (is (string= (d:uri (first (d:psis third-node))) |
---|
1328 | "http://test-tm/third-node")) |
---|
1329 | (is (= (length (d:psis fourth-node)) 1)) |
---|
1330 | (is (string= (d:uri (first (d:psis fourth-node))) |
---|
1331 | "http://test-tm/fourth-node")) |
---|
1332 | (is (= (length (d:psis fifth-node)) 1)) |
---|
1333 | (is (string= (d:uri (first (d:psis fifth-node))) |
---|
1334 | "http://test-tm/fifth-node")) |
---|
1335 | (is (= (length (d:psis item-1)) 1)) |
---|
1336 | (is (string= (d:uri (first (d:psis item-1))) |
---|
1337 | "http://test-tm/item-1")) |
---|
1338 | (is (= (length (d:psis item-2)) 1)) |
---|
1339 | (is (string= (d:uri (first (d:psis item-2))) |
---|
1340 | "http://test-tm/item-2")) |
---|
1341 | (is (= (length (d:psis arc1)) 1)) |
---|
1342 | (is (string= (d:uri (first (d:psis arc1))) |
---|
1343 | "http://test/arcs/arc1")) |
---|
1344 | (is (= (length (d:psis arc2)) 1)) |
---|
1345 | (is (string= (d:uri (first (d:psis arc2))) |
---|
1346 | "http://test/arcs/arc2")) |
---|
1347 | (is (= (length (d:psis arc3)) 1)) |
---|
1348 | (is (string= (d:uri (first (d:psis arc3))) |
---|
1349 | "http://test/arcs/arc3")) |
---|
1350 | (is (= (length (d:psis arc4)) 1)) |
---|
1351 | (is (string= (d:uri (first (d:psis arc4))) |
---|
1352 | "http://test/arcs/arc4")) |
---|
1353 | (is (= (length (d:psis arc5)) 1)) |
---|
1354 | (is (string= (d:uri (first (d:psis arc5))) |
---|
1355 | "http://test/arcs/arc5")) |
---|
1356 | (is (= (length (d:psis arc6)) 1)) |
---|
1357 | (is (string= (d:uri (first (d:psis arc6))) |
---|
1358 | "http://test/arcs/arc6")) |
---|
1359 | (is (= (length (d:psis arc7)) 1)) |
---|
1360 | (is (string= (d:uri (first (d:psis arc7))) |
---|
1361 | "http://test/arcs/arc7")) |
---|
1362 | (is (= (length (d:psis arc8)) 1)) |
---|
1363 | (is (string= (d:uri (first (d:psis arc8))) |
---|
1364 | "http://test/arcs/arc8")) |
---|
1365 | (is (= (length (d:psis rdf-first)) 1)) |
---|
1366 | (is (string= (d:uri (first (d:psis rdf-first))) |
---|
1367 | constants:*rdf-first*)) |
---|
1368 | (is (= (length (d:psis rdf-rest)) 1)) |
---|
1369 | (is (string= (d:uri (first (d:psis rdf-rest))) |
---|
1370 | constants:*rdf-rest*)) |
---|
1371 | (is (= (length (d:psis rdf-nil)) 1)) |
---|
1372 | (is (string= (d:uri (first (d:psis rdf-nil))) |
---|
1373 | constants:*rdf-nil*)) |
---|
1374 | (is (= (length (elephant:get-instances-by-class 'd:OccurrenceC)) |
---|
1375 | 1)) |
---|
1376 | (is (string= (d:charvalue (first (elephant:get-instances-by-class |
---|
1377 | 'd:OccurrenceC))) |
---|
1378 | "123")) |
---|
1379 | (is (string= (d:datatype (first (elephant:get-instances-by-class |
---|
1380 | 'd:OccurrenceC))) |
---|
1381 | "http://test-tm/long")) |
---|
1382 | (is (= (length (d:occurrences first-node)) 1)) |
---|
1383 | (is (= (length (d:player-in-roles first-node)) 3)) |
---|
1384 | (is (= (count-if |
---|
1385 | #'(lambda(x) |
---|
1386 | (or (and (eql (d:instance-of x) instance) |
---|
1387 | (eql (d:instance-of (d:parent x)) |
---|
1388 | type-instance)) |
---|
1389 | (and (eql (d:instance-of x) subject) |
---|
1390 | (eql (d:instance-of (d:parent x)) arc1)) |
---|
1391 | (and (eql (d:instance-of x) subject) |
---|
1392 | (eql (d:instance-of (d:parent x)) arc3)))) |
---|
1393 | (d:player-in-roles first-node)) |
---|
1394 | 3)) |
---|
1395 | (is (= (length (d:player-in-roles second-node)) 1)) |
---|
1396 | (is-true (find-if |
---|
1397 | #'(lambda(x) |
---|
1398 | (and (eql (d:instance-of x) type) |
---|
1399 | (eql (d:instance-of (d:parent x)) |
---|
1400 | type-instance))) |
---|
1401 | (d:player-in-roles second-node))) |
---|
1402 | (is (= (length (d:player-in-roles third-node)) 1)) |
---|
1403 | (is-true (find-if |
---|
1404 | #'(lambda(x) |
---|
1405 | (and (eql (d:instance-of x) object) |
---|
1406 | (eql (d:instance-of (d:parent x)) |
---|
1407 | arc1))) |
---|
1408 | (d:player-in-roles third-node))) |
---|
1409 | (let ((uuid-1 |
---|
1410 | (d:player |
---|
1411 | (find-if |
---|
1412 | #'(lambda(y) |
---|
1413 | (and (eql (d:instance-of y) object) |
---|
1414 | (= 0 (length (d:psis (d:player y)))))) |
---|
1415 | (d:roles |
---|
1416 | (d:parent |
---|
1417 | (find-if |
---|
1418 | #'(lambda(x) |
---|
1419 | (and (eql (d:instance-of x) subject) |
---|
1420 | (eql (d:instance-of (d:parent x)) arc3))) |
---|
1421 | (d:player-in-roles first-node)))))))) |
---|
1422 | (is-true uuid-1) |
---|
1423 | (is (= (length (d:player-in-roles uuid-1)) 2)) |
---|
1424 | (is-true (find-if |
---|
1425 | #'(lambda(x) |
---|
1426 | (and (eql (d:instance-of x) subject) |
---|
1427 | (eql (d:instance-of (d:parent x)) arc4))) |
---|
1428 | (d:player-in-roles uuid-1))) |
---|
1429 | (let ((col-1 |
---|
1430 | (d:player |
---|
1431 | (find-if |
---|
1432 | #'(lambda(y) |
---|
1433 | (and (eql (d:instance-of y) object) |
---|
1434 | (= 0 (length (d:psis (d:player y)))))) |
---|
1435 | (d:roles |
---|
1436 | (d:parent |
---|
1437 | (find-if |
---|
1438 | #'(lambda(x) |
---|
1439 | (and (eql (d:instance-of x) subject) |
---|
1440 | (eql (d:instance-of (d:parent x)) arc4))) |
---|
1441 | (d:player-in-roles uuid-1)))))))) |
---|
1442 | (is-true col-1) |
---|
1443 | (is (= (length (d:player-in-roles col-1)) 3)) |
---|
1444 | (is-true (find-if |
---|
1445 | #'(lambda(x) |
---|
1446 | (and (eql (d:instance-of x) subject) |
---|
1447 | (eql (d:instance-of (d:parent x)) |
---|
1448 | rdf-first))) |
---|
1449 | (d:player-in-roles col-1))) |
---|
1450 | (is-true (find-if |
---|
1451 | #'(lambda(x) |
---|
1452 | (and (eql (d:instance-of x) subject) |
---|
1453 | (eql (d:instance-of (d:parent x)) |
---|
1454 | rdf-rest))) |
---|
1455 | (d:player-in-roles col-1))) |
---|
1456 | (is-true (find-if |
---|
1457 | #'(lambda(x) |
---|
1458 | (and (eql (d:instance-of x) object) |
---|
1459 | (eql (d:instance-of (d:parent x)) |
---|
1460 | arc4))) |
---|
1461 | (d:player-in-roles col-1))) |
---|
1462 | (is (= (length (d:player-in-roles item-1)) 1)) |
---|
1463 | (is-true (find-if |
---|
1464 | #'(lambda(x) |
---|
1465 | (and (eql (d:instance-of x) object) |
---|
1466 | (eql (d:instance-of (d:parent x)) |
---|
1467 | rdf-first))) |
---|
1468 | (d:player-in-roles item-1))) |
---|
1469 | (let ((col-2 |
---|
1470 | (let ((role |
---|
1471 | (find-if |
---|
1472 | #'(lambda(x) |
---|
1473 | (and (eql (d:instance-of x) subject) |
---|
1474 | (eql (d:instance-of (d:parent x)) |
---|
1475 | rdf-rest))) |
---|
1476 | (d:player-in-roles col-1)))) |
---|
1477 | (is (= (length (d:roles (d:parent role))) 2)) |
---|
1478 | (let ((other-role |
---|
1479 | (find-if #'(lambda(x) |
---|
1480 | (and (not (eql x role)) |
---|
1481 | (eql (d:instance-of x) |
---|
1482 | object))) |
---|
1483 | (d:roles (d:parent role))))) |
---|
1484 | (d:player other-role))))) |
---|
1485 | (is-true col-2) |
---|
1486 | (is (= (length (d:psis col-2)) 0)) |
---|
1487 | (is (= (length (d:player-in-roles col-2)) 3)) |
---|
1488 | (is-true (find-if |
---|
1489 | #'(lambda(x) |
---|
1490 | (and (eql (d:instance-of x) subject) |
---|
1491 | (eql (d:instance-of (d:parent x)) |
---|
1492 | rdf-first))) |
---|
1493 | (d:player-in-roles col-2))) |
---|
1494 | (is-true (find-if |
---|
1495 | #'(lambda(x) |
---|
1496 | (and (eql (d:instance-of x) subject) |
---|
1497 | (eql (d:instance-of (d:parent x)) |
---|
1498 | rdf-rest))) |
---|
1499 | (d:player-in-roles col-2))) |
---|
1500 | (let ((col-3 |
---|
1501 | (let ((role |
---|
1502 | (find-if |
---|
1503 | #'(lambda(x) |
---|
1504 | (and (eql (d:instance-of x) subject) |
---|
1505 | (eql (d:instance-of (d:parent x)) |
---|
1506 | rdf-rest))) |
---|
1507 | (d:player-in-roles col-2)))) |
---|
1508 | |
---|
1509 | (is (= (length (d:roles (d:parent role))) 2)) |
---|
1510 | (let ((other-role |
---|
1511 | (find-if |
---|
1512 | #'(lambda(x) |
---|
1513 | (not (eql x role))) |
---|
1514 | (d:roles (d:parent role))))) |
---|
1515 | (d:player other-role))))) |
---|
1516 | (is-true col-3) |
---|
1517 | (is (= (length (d:psis col-3)) 1)) |
---|
1518 | (is (string= (d:uri (first (d:psis col-3))) |
---|
1519 | constants:*rdf-nil*)) |
---|
1520 | (is (= (length (d:player-in-roles col-3)) 2))))) |
---|
1521 | (is (= (length (d:player-in-roles item-1)) 1)) |
---|
1522 | (is (= (length (d:player-in-roles item-2)) 2)) |
---|
1523 | (is-true (find-if |
---|
1524 | #'(lambda(x) |
---|
1525 | (and (eql (d:instance-of x) subject) |
---|
1526 | (eql (d:instance-of (d:parent x)) arc5))) |
---|
1527 | (d:player-in-roles item-2))) |
---|
1528 | (let ((uuid-2 |
---|
1529 | (d:player |
---|
1530 | (find-if |
---|
1531 | #'(lambda(y) |
---|
1532 | (and (eql (d:instance-of y) object) |
---|
1533 | (= 0 (length (d:psis (d:player y)))))) |
---|
1534 | (d:roles |
---|
1535 | (d:parent |
---|
1536 | (find-if |
---|
1537 | #'(lambda(x) |
---|
1538 | (and (eql (d:instance-of x) subject) |
---|
1539 | (eql (d:instance-of (d:parent x)) arc5))) |
---|
1540 | (d:player-in-roles item-2)))))))) |
---|
1541 | (is-true uuid-2) |
---|
1542 | (is (= (length (d:player-in-roles uuid-2)) 4)) |
---|
1543 | (is (= (count-if |
---|
1544 | #'(lambda(x) |
---|
1545 | (or (and (eql (d:instance-of x) object) |
---|
1546 | (eql (d:instance-of (d:parent x)) arc5)) |
---|
1547 | (and (eql (d:instance-of x) subject) |
---|
1548 | (or |
---|
1549 | (eql (d:instance-of (d:parent x)) arc6) |
---|
1550 | (eql (d:instance-of (d:parent x)) arc7) |
---|
1551 | (eql (d:instance-of |
---|
1552 | (d:parent x)) arc8))))) |
---|
1553 | (d:player-in-roles uuid-2)) |
---|
1554 | 4)) |
---|
1555 | (is (= (length (d:player-in-roles fourth-node)) 1)) |
---|
1556 | (is (= (length (d:player-in-roles fifth-node)) 1)) |
---|
1557 | (let ((col-2 |
---|
1558 | (d:player |
---|
1559 | (find-if |
---|
1560 | #'(lambda(y) |
---|
1561 | (and (eql (d:instance-of y) object) |
---|
1562 | (= 1 (length (d:psis (d:player y)))))) |
---|
1563 | (d:roles |
---|
1564 | (d:parent |
---|
1565 | (find-if |
---|
1566 | #'(lambda(x) |
---|
1567 | (and (eql (d:instance-of x) subject) |
---|
1568 | (eql (d:instance-of (d:parent x)) arc8))) |
---|
1569 | (d:player-in-roles uuid-2)))))))) |
---|
1570 | (is (= (length (d:psis col-2)) 1)) |
---|
1571 | (is (string= constants:*rdf-nil* |
---|
1572 | (d:uri (first (d:psis col-2))))) |
---|
1573 | (is-true col-2) |
---|
1574 | (is (= (length (d:player-in-roles col-2)) 2))))))))) |
---|
1575 | (elephant:close-store)) |
---|
1576 | |
---|
1577 | |
---|
1578 | (test test-poems-rdf-occurrences |
---|
1579 | "Tests general functionality of the rdf-importer module with the file |
---|
1580 | poems_light.rdf." |
---|
1581 | (with-fixture rdf-test-db () |
---|
1582 | (let ((topics (elephant:get-instances-by-class 'd:TopicC)) |
---|
1583 | (occs (elephant:get-instances-by-class 'd:OccurrenceC)) |
---|
1584 | (assocs (elephant:get-instances-by-class 'd:AssociationC)) |
---|
1585 | (arcs "http://some.where/relationship/") |
---|
1586 | (goethe "http://some.where/author/Goethe") |
---|
1587 | (weimar "http://some.where/city/Weimar") |
---|
1588 | (berlin "http://some.where/metropolis/Berlin") |
---|
1589 | (frankfurt "http://some.where/metropolis/FrankfurtMain") |
---|
1590 | (germany "http://some.where/country/Germany") |
---|
1591 | (zauberlehrling "http://some.where/poem/Der_Zauberlehrling") |
---|
1592 | (prometheus "http://some.where/poem/Prometheus") |
---|
1593 | (erlkoenig "http://some.where/ballad/Der_Erlkoenig") |
---|
1594 | (date "http://www.w3.org/2001/XMLSchema#date") |
---|
1595 | (de (d:get-item-by-id "http://isidorus/rdf2tm_mapping/scope/de")) |
---|
1596 | (long "http://www.w3.org/2001/XMLSchema#unsignedLong")) |
---|
1597 | (is (= (length topics) 65)) |
---|
1598 | (is (= (length occs) 23)) |
---|
1599 | (is (= (length assocs) 30)) |
---|
1600 | (is-true de) |
---|
1601 | (is (= (count-if |
---|
1602 | #'(lambda(x) |
---|
1603 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1604 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1605 | (concatenate 'string arcs "firstName")) |
---|
1606 | (string= *xml-string* (d:datatype x)) |
---|
1607 | (= (length (d:themes x)) 0) |
---|
1608 | (= (length (d:psis (d:parent x))) 1) |
---|
1609 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1610 | goethe))) |
---|
1611 | occs) |
---|
1612 | 1)) |
---|
1613 | (is (= (count-if |
---|
1614 | #'(lambda(x) |
---|
1615 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1616 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1617 | (concatenate 'string arcs "lastName")) |
---|
1618 | (string= *xml-string* (d:datatype x)) |
---|
1619 | (= (length (d:themes x)) 0) |
---|
1620 | (= (length (d:psis (d:parent x))) 1) |
---|
1621 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1622 | goethe))) |
---|
1623 | occs) |
---|
1624 | 1)) |
---|
1625 | (is (= (count-if |
---|
1626 | #'(lambda(x) |
---|
1627 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1628 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1629 | (concatenate 'string arcs "fullName")) |
---|
1630 | (string= *xml-string* (d:datatype x)) |
---|
1631 | (= (length (d:themes x)) 0) |
---|
1632 | (= (length (d:psis (d:parent x))) 1) |
---|
1633 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1634 | weimar))) |
---|
1635 | occs) |
---|
1636 | 1)) |
---|
1637 | (is (= (count-if |
---|
1638 | #'(lambda(x) |
---|
1639 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1640 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1641 | (concatenate 'string arcs "fullName")) |
---|
1642 | (string= *xml-string* (d:datatype x)) |
---|
1643 | (= (length (d:themes x)) 0) |
---|
1644 | (= (length (d:psis (d:parent x))) 1) |
---|
1645 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1646 | frankfurt))) |
---|
1647 | occs) |
---|
1648 | 1)) |
---|
1649 | (is (= (count-if |
---|
1650 | #'(lambda(x) |
---|
1651 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1652 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1653 | (concatenate 'string arcs "nativeName")) |
---|
1654 | (string= *xml-string* (d:datatype x)) |
---|
1655 | (= 1 (length (d:themes x))) |
---|
1656 | (eql (first (d:themes x)) de) |
---|
1657 | (= (length (d:psis (d:parent x))) 1) |
---|
1658 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1659 | germany))) |
---|
1660 | occs) |
---|
1661 | 1)) |
---|
1662 | (is (= (count-if |
---|
1663 | #'(lambda(x) |
---|
1664 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1665 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1666 | (concatenate 'string arcs "title")) |
---|
1667 | (string= *xml-string* (d:datatype x)) |
---|
1668 | (string= (d:charvalue x) "Der Zauberlehrling") |
---|
1669 | (= 1 (length (d:themes x))) |
---|
1670 | (eql (first (d:themes x)) de) |
---|
1671 | (= (length (d:psis (d:parent x))) 1) |
---|
1672 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1673 | zauberlehrling))) |
---|
1674 | occs) |
---|
1675 | 1)) |
---|
1676 | (is (= (count-if |
---|
1677 | #'(lambda(x) |
---|
1678 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1679 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1680 | (concatenate 'string arcs "title")) |
---|
1681 | (= 0 (length (d:themes x))) |
---|
1682 | (string= (d:charvalue x) "Prometheus") |
---|
1683 | (string= *xml-string* (d:datatype x)) |
---|
1684 | (= (length (d:psis (d:parent x))) 1) |
---|
1685 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1686 | prometheus))) |
---|
1687 | occs) |
---|
1688 | 1)) |
---|
1689 | (is (= (count-if |
---|
1690 | #'(lambda(x) |
---|
1691 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1692 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1693 | (concatenate 'string arcs "title")) |
---|
1694 | (string= *xml-string* (d:datatype x)) |
---|
1695 | (string= (d:charvalue x) "Der Erlkönig") |
---|
1696 | (= 1 (length (d:themes x))) |
---|
1697 | (eql (first (d:themes x)) de) |
---|
1698 | (= (length (d:psis (d:parent x))) 1) |
---|
1699 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1700 | erlkoenig))) |
---|
1701 | occs) |
---|
1702 | 1)) |
---|
1703 | (is (= (count-if |
---|
1704 | #'(lambda(x) |
---|
1705 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1706 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1707 | (concatenate 'string arcs "content")) |
---|
1708 | (string= *xml-string* (d:datatype x)) |
---|
1709 | (string= (d:charvalue x) "Hat der alte Hexenmeister ...") |
---|
1710 | (= 1 (length (d:themes x))) |
---|
1711 | (eql (first (d:themes x)) de) |
---|
1712 | (= (length (d:psis (d:parent x))) 1) |
---|
1713 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1714 | zauberlehrling))) |
---|
1715 | occs) |
---|
1716 | 1)) |
---|
1717 | (is (= (count-if |
---|
1718 | #'(lambda(x) |
---|
1719 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1720 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1721 | (concatenate 'string arcs "content")) |
---|
1722 | (string= *xml-string* (d:datatype x)) |
---|
1723 | (string= (d:charvalue x) |
---|
1724 | " Bedecke deinen Himmel, Zeus, ... ") |
---|
1725 | (= 1 (length (d:themes x))) |
---|
1726 | (eql (first (d:themes x)) de) |
---|
1727 | (= (length (d:psis (d:parent x))) 1) |
---|
1728 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1729 | prometheus))) |
---|
1730 | occs) |
---|
1731 | 1)) |
---|
1732 | (is (= (count-if |
---|
1733 | #'(lambda(x) |
---|
1734 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1735 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1736 | (concatenate 'string arcs "content")) |
---|
1737 | (string= *xml-string* (d:datatype x)) |
---|
1738 | (string= (d:charvalue x) |
---|
1739 | "Wer reitet so spÀt durch Nacht und Wind? ...") |
---|
1740 | (= 1 (length (d:themes x))) |
---|
1741 | (eql (first (d:themes x)) de) |
---|
1742 | (= (length (d:psis (d:parent x))) 1) |
---|
1743 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1744 | erlkoenig))) |
---|
1745 | occs) |
---|
1746 | 1)) |
---|
1747 | (is (= (count-if |
---|
1748 | #'(lambda(x) |
---|
1749 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1750 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1751 | (concatenate 'string arcs "population")) |
---|
1752 | (string= long (d:datatype x)) |
---|
1753 | (= 0 (length (d:themes x))) |
---|
1754 | (= (length (d:psis (d:parent x))) 1) |
---|
1755 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1756 | weimar))) |
---|
1757 | occs) |
---|
1758 | 1)) |
---|
1759 | (is (= (count-if |
---|
1760 | #'(lambda(x) |
---|
1761 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1762 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1763 | (concatenate 'string arcs "population")) |
---|
1764 | (string= long (d:datatype x)) |
---|
1765 | (= 0 (length (d:themes x))) |
---|
1766 | (= (length (d:psis (d:parent x))) 1) |
---|
1767 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1768 | frankfurt))) |
---|
1769 | occs) |
---|
1770 | 1)) |
---|
1771 | (is (= (count-if |
---|
1772 | #'(lambda(x) |
---|
1773 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1774 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1775 | (concatenate 'string arcs "population")) |
---|
1776 | (string= long (d:datatype x)) |
---|
1777 | (= 0 (length (d:themes x))) |
---|
1778 | (= (length (d:psis (d:parent x))) 1) |
---|
1779 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1780 | berlin))) |
---|
1781 | occs) |
---|
1782 | 1)) |
---|
1783 | (is (= (count-if |
---|
1784 | #'(lambda(x) |
---|
1785 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1786 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1787 | (concatenate 'string arcs "population")) |
---|
1788 | (string= long (d:datatype x)) |
---|
1789 | (= 0 (length (d:themes x))) |
---|
1790 | (= (length (d:psis (d:parent x))) 1) |
---|
1791 | (string= (d:uri (first (d:psis (d:parent x)))) |
---|
1792 | germany))) |
---|
1793 | occs) |
---|
1794 | 1)) |
---|
1795 | (is (= (count-if |
---|
1796 | #'(lambda(x) |
---|
1797 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1798 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1799 | (concatenate 'string arcs "date")) |
---|
1800 | (string= date (d:datatype x)) |
---|
1801 | (= 0 (length (d:themes x))) |
---|
1802 | (= (length (d:psis (d:parent x))) 0))) |
---|
1803 | occs) |
---|
1804 | 2)) |
---|
1805 | (is (= (count-if |
---|
1806 | #'(lambda(x) |
---|
1807 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1808 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1809 | (concatenate 'string arcs "start")) |
---|
1810 | (string= date (d:datatype x)) |
---|
1811 | (= 1 (length (d:themes x))) |
---|
1812 | (eql (first (d:themes x)) de) |
---|
1813 | (= (length (d:psis (d:parent x))) 0))) |
---|
1814 | |
---|
1815 | occs) |
---|
1816 | 1)) |
---|
1817 | (is (= (count-if |
---|
1818 | #'(lambda(x) |
---|
1819 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1820 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1821 | (concatenate 'string arcs "start")) |
---|
1822 | (string= date (d:datatype x)) |
---|
1823 | (= 0 (length (d:themes x))) |
---|
1824 | (= (length (d:psis (d:parent x))) 0))) |
---|
1825 | |
---|
1826 | occs) |
---|
1827 | 2)) |
---|
1828 | (is (= (count-if |
---|
1829 | #'(lambda(x) |
---|
1830 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1831 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1832 | (concatenate 'string arcs "end")) |
---|
1833 | (string= date (d:datatype x)) |
---|
1834 | (= 1 (length (d:themes x))) |
---|
1835 | (eql (first (d:themes x)) de) |
---|
1836 | (= (length (d:psis (d:parent x))) 0))) |
---|
1837 | occs) |
---|
1838 | 1)) |
---|
1839 | (is (= (count-if |
---|
1840 | #'(lambda(x) |
---|
1841 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1842 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1843 | (concatenate 'string arcs "end")) |
---|
1844 | (string= date (d:datatype x)) |
---|
1845 | (= 0 (length (d:themes x))) |
---|
1846 | (= (length (d:psis (d:parent x))) 0))) |
---|
1847 | occs) |
---|
1848 | 2))))) |
---|
1849 | |
---|
1850 | |
---|
1851 | (test test-poems-rdf-associations |
---|
1852 | "Tests general functionality of the rdf-importer module with the file |
---|
1853 | poems_light.rdf." |
---|
1854 | (with-fixture rdf-test-db () |
---|
1855 | (let ((assocs (elephant:get-instances-by-class 'd:AssociationC)) |
---|
1856 | (isi-object (d:get-item-by-psi constants::*rdf2tm-object*)) |
---|
1857 | (isi-subject (d:get-item-by-psi constants::*rdf2tm-subject*)) |
---|
1858 | (arcs "http://some.where/relationship/") |
---|
1859 | (goethe "http://some.where/author/Goethe") |
---|
1860 | (germany "http://some.where/country/Germany") |
---|
1861 | (berlin "http://some.where/metropolis/Berlin") |
---|
1862 | (german "http://some.where/language/German") |
---|
1863 | (frankfurt "http://some.where/metropolis/FrankfurtMain") |
---|
1864 | (weimar "http://some.where/city/Weimar") |
---|
1865 | (zauberlehrling "http://some.where/poem/Der_Zauberlehrling") |
---|
1866 | (prometheus "http://some.where/poem/Prometheus") |
---|
1867 | (erlkoenig "http://some.where/ballad/Der_Erlkoenig")) |
---|
1868 | (is (= (count-if |
---|
1869 | #'(lambda(x) |
---|
1870 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1871 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1872 | (concatenate 'string arcs "born")) |
---|
1873 | (= (length (d:roles x)) 2) |
---|
1874 | (find-if |
---|
1875 | #'(lambda(y) |
---|
1876 | (and (eql (d:instance-of y) isi-subject) |
---|
1877 | (= (length (d:psis (d:player y))) 1) |
---|
1878 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
1879 | goethe))) |
---|
1880 | (d:roles x)) |
---|
1881 | (find-if |
---|
1882 | #'(lambda(y) |
---|
1883 | (and (eql (d:instance-of y) isi-object) |
---|
1884 | (= (length (d:psis (d:player y))) 0))) |
---|
1885 | (d:roles x)))) |
---|
1886 | assocs) |
---|
1887 | 1)) |
---|
1888 | (is (= (count-if |
---|
1889 | #'(lambda(x) |
---|
1890 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1891 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1892 | (concatenate 'string arcs "died")) |
---|
1893 | (find-if |
---|
1894 | #'(lambda(y) |
---|
1895 | (and (eql (d:instance-of y) isi-subject) |
---|
1896 | (= (length (d:psis (d:player y))) 1) |
---|
1897 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
1898 | goethe))) |
---|
1899 | (d:roles x)) |
---|
1900 | (find-if |
---|
1901 | #'(lambda(y) |
---|
1902 | (and (eql (d:instance-of y) isi-object) |
---|
1903 | (= (length (d:psis (d:player y))) 0))) |
---|
1904 | (d:roles x)))) |
---|
1905 | assocs) |
---|
1906 | 1)) |
---|
1907 | (is (= (count-if |
---|
1908 | #'(lambda(x) |
---|
1909 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1910 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1911 | (concatenate 'string arcs "wrote")) |
---|
1912 | (find-if |
---|
1913 | #'(lambda(y) |
---|
1914 | (and (eql (d:instance-of y) isi-subject) |
---|
1915 | (= (length (d:psis (d:player y))) 1) |
---|
1916 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
1917 | goethe))) |
---|
1918 | (d:roles x)) |
---|
1919 | (find-if |
---|
1920 | #'(lambda(y) |
---|
1921 | (and (eql (d:instance-of y) isi-object) |
---|
1922 | (= (length (d:psis (d:player y))) 0))) |
---|
1923 | (d:roles x)))) |
---|
1924 | assocs) |
---|
1925 | 1)) |
---|
1926 | (is (= (count-if |
---|
1927 | #'(lambda(x) |
---|
1928 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1929 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1930 | (concatenate 'string arcs "capital")) |
---|
1931 | (find-if |
---|
1932 | #'(lambda(y) |
---|
1933 | (and (eql (d:instance-of y) isi-subject) |
---|
1934 | (= (length (d:psis (d:player y))) 1) |
---|
1935 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
1936 | germany))) |
---|
1937 | (d:roles x)) |
---|
1938 | (find-if |
---|
1939 | #'(lambda(y) |
---|
1940 | (and (eql (d:instance-of y) isi-object) |
---|
1941 | (= (length (d:psis (d:player y))) 1) |
---|
1942 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
1943 | berlin))) |
---|
1944 | (d:roles x)))) |
---|
1945 | assocs) |
---|
1946 | 1)) |
---|
1947 | (is (= (count-if |
---|
1948 | #'(lambda(x) |
---|
1949 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1950 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1951 | (concatenate 'string arcs "officialese")) |
---|
1952 | (find-if |
---|
1953 | #'(lambda(y) |
---|
1954 | (and (eql (d:instance-of y) isi-subject) |
---|
1955 | (= (length (d:psis (d:player y))) 1) |
---|
1956 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
1957 | germany))) |
---|
1958 | (d:roles x)) |
---|
1959 | (find-if |
---|
1960 | #'(lambda(y) |
---|
1961 | (and (eql (d:instance-of y) isi-object) |
---|
1962 | (= (length (d:psis (d:player y))) 1) |
---|
1963 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
1964 | german))) |
---|
1965 | (d:roles x)))) |
---|
1966 | assocs) |
---|
1967 | 1)) |
---|
1968 | (is (= (count-if |
---|
1969 | #'(lambda(x) |
---|
1970 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1971 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1972 | (concatenate 'string arcs "place")) |
---|
1973 | (find-if |
---|
1974 | #'(lambda(y) |
---|
1975 | (and (eql (d:instance-of y) isi-object) |
---|
1976 | (= (length (d:psis (d:player y))) 1) |
---|
1977 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
1978 | frankfurt))) |
---|
1979 | (d:roles x)) |
---|
1980 | (find-if |
---|
1981 | #'(lambda(y) |
---|
1982 | (and (eql (d:instance-of y) isi-subject) |
---|
1983 | (= (length (d:psis (d:player y))) 0))) |
---|
1984 | (d:roles x)))) |
---|
1985 | assocs) |
---|
1986 | 1)) |
---|
1987 | (is (= (count-if |
---|
1988 | #'(lambda(x) |
---|
1989 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
1990 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
1991 | (concatenate 'string arcs "place")) |
---|
1992 | (find-if |
---|
1993 | #'(lambda(y) |
---|
1994 | (and (eql (d:instance-of y) isi-object) |
---|
1995 | (= (length (d:psis (d:player y))) 1) |
---|
1996 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
1997 | weimar))) |
---|
1998 | (d:roles x)) |
---|
1999 | (find-if |
---|
2000 | #'(lambda(y) |
---|
2001 | (and (eql (d:instance-of y) isi-subject) |
---|
2002 | (= (length (d:psis (d:player y))) 0))) |
---|
2003 | (d:roles x)))) |
---|
2004 | assocs) |
---|
2005 | 1)) |
---|
2006 | (is (= (count-if |
---|
2007 | #'(lambda(x) |
---|
2008 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
2009 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
2010 | (concatenate 'string arcs "locatedIn")) |
---|
2011 | (find-if |
---|
2012 | #'(lambda(y) |
---|
2013 | (and (eql (d:instance-of y) isi-subject) |
---|
2014 | (= (length (d:psis (d:player y))) 1) |
---|
2015 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2016 | frankfurt))) |
---|
2017 | (d:roles x)) |
---|
2018 | (find-if |
---|
2019 | #'(lambda(y) |
---|
2020 | (and (eql (d:instance-of y) isi-object) |
---|
2021 | (= (length (d:psis (d:player y))) 1) |
---|
2022 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2023 | germany))) |
---|
2024 | (d:roles x)))) |
---|
2025 | assocs) |
---|
2026 | 1)) |
---|
2027 | (is (= (count-if |
---|
2028 | #'(lambda(x) |
---|
2029 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
2030 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
2031 | (concatenate 'string arcs "locatedIn")) |
---|
2032 | (find-if |
---|
2033 | #'(lambda(y) |
---|
2034 | (and (eql (d:instance-of y) isi-subject) |
---|
2035 | (= (length (d:psis (d:player y))) 1) |
---|
2036 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2037 | weimar))) |
---|
2038 | (d:roles x)) |
---|
2039 | (find-if |
---|
2040 | #'(lambda(y) |
---|
2041 | (and (eql (d:instance-of y) isi-object) |
---|
2042 | (= (length (d:psis (d:player y))) 1) |
---|
2043 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2044 | germany))) |
---|
2045 | (d:roles x)))) |
---|
2046 | assocs) |
---|
2047 | 1)) |
---|
2048 | (is (= (count-if |
---|
2049 | #'(lambda(x) |
---|
2050 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
2051 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
2052 | (concatenate 'string arcs "locatedIn")) |
---|
2053 | (find-if |
---|
2054 | #'(lambda(y) |
---|
2055 | (and (eql (d:instance-of y) isi-subject) |
---|
2056 | (= (length (d:psis (d:player y))) 1) |
---|
2057 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2058 | berlin))) |
---|
2059 | (d:roles x)) |
---|
2060 | (find-if |
---|
2061 | #'(lambda(y) |
---|
2062 | (and (eql (d:instance-of y) isi-object) |
---|
2063 | (= (length (d:psis (d:player y))) 1) |
---|
2064 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2065 | germany))) |
---|
2066 | (d:roles x)))) |
---|
2067 | assocs) |
---|
2068 | 1)) |
---|
2069 | (is (= (count-if |
---|
2070 | #'(lambda(x) |
---|
2071 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
2072 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
2073 | (concatenate 'string arcs "dateRange")) |
---|
2074 | (find-if |
---|
2075 | #'(lambda(y) |
---|
2076 | (and (eql (d:instance-of y) isi-subject) |
---|
2077 | (= (length (d:psis (d:player y))) 1) |
---|
2078 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2079 | prometheus))) |
---|
2080 | (d:roles x)) |
---|
2081 | (find-if |
---|
2082 | #'(lambda(y) |
---|
2083 | (and (eql (d:instance-of y) isi-object) |
---|
2084 | (= (length (d:psis (d:player y))) 0))) |
---|
2085 | (d:roles x)))) |
---|
2086 | assocs) |
---|
2087 | 1)) |
---|
2088 | (is (= (count-if |
---|
2089 | #'(lambda(x) |
---|
2090 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
2091 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
2092 | (concatenate 'string arcs "dateRange")) |
---|
2093 | (find-if |
---|
2094 | #'(lambda(y) |
---|
2095 | (and (eql (d:instance-of y) isi-subject) |
---|
2096 | (= (length (d:psis (d:player y))) 1) |
---|
2097 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2098 | zauberlehrling))) |
---|
2099 | (d:roles x)) |
---|
2100 | (find-if |
---|
2101 | #'(lambda(y) |
---|
2102 | (and (eql (d:instance-of y) isi-object) |
---|
2103 | (= (length (d:psis (d:player y))) 0))) |
---|
2104 | (d:roles x)))) |
---|
2105 | assocs) |
---|
2106 | 1)) |
---|
2107 | (is (= (count-if |
---|
2108 | #'(lambda(x) |
---|
2109 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
2110 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
2111 | (concatenate 'string arcs "dateRange")) |
---|
2112 | (find-if |
---|
2113 | #'(lambda(y) |
---|
2114 | (and (eql (d:instance-of y) isi-subject) |
---|
2115 | (= (length (d:psis (d:player y))) 1) |
---|
2116 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2117 | erlkoenig))) |
---|
2118 | (d:roles x)) |
---|
2119 | (find-if |
---|
2120 | #'(lambda(y) |
---|
2121 | (and (eql (d:instance-of y) isi-object) |
---|
2122 | (= (length (d:psis (d:player y))) 0))) |
---|
2123 | (d:roles x)))) |
---|
2124 | assocs) |
---|
2125 | 1)) |
---|
2126 | (is (= (count-if |
---|
2127 | #'(lambda(x) |
---|
2128 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
2129 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
2130 | (concatenate 'string constants:*rdf-ns* "_1")) |
---|
2131 | (find-if |
---|
2132 | #'(lambda(y) |
---|
2133 | (and (eql (d:instance-of y) isi-subject) |
---|
2134 | (= (length (d:psis (d:player y))) 0))) |
---|
2135 | (d:roles x)) |
---|
2136 | (find-if |
---|
2137 | #'(lambda(y) |
---|
2138 | (and (eql (d:instance-of y) isi-object) |
---|
2139 | (= (length (d:psis (d:player y))) 1) |
---|
2140 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2141 | zauberlehrling))) |
---|
2142 | (d:roles x)))) |
---|
2143 | assocs) |
---|
2144 | 1)) |
---|
2145 | (is (= (count-if |
---|
2146 | #'(lambda(x) |
---|
2147 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
2148 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
2149 | (concatenate 'string constants:*rdf-ns* "_2")) |
---|
2150 | (find-if |
---|
2151 | #'(lambda(y) |
---|
2152 | (and (eql (d:instance-of y) isi-subject) |
---|
2153 | (= (length (d:psis (d:player y))) 0))) |
---|
2154 | (d:roles x)) |
---|
2155 | (find-if |
---|
2156 | #'(lambda(y) |
---|
2157 | (and (eql (d:instance-of y) isi-object) |
---|
2158 | (= (length (d:psis (d:player y))) 1) |
---|
2159 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2160 | erlkoenig))) |
---|
2161 | (d:roles x)))) |
---|
2162 | assocs) |
---|
2163 | 1)) |
---|
2164 | (is (= (count-if |
---|
2165 | #'(lambda(x) |
---|
2166 | (and (= (length (d:psis (d:instance-of x))) 1) |
---|
2167 | (string= (d:uri (first (d:psis (d:instance-of x)))) |
---|
2168 | (concatenate 'string constants:*rdf-ns* "_3")) |
---|
2169 | (find-if |
---|
2170 | #'(lambda(y) |
---|
2171 | (and (eql (d:instance-of y) isi-subject) |
---|
2172 | (= (length (d:psis (d:player y))) 0))) |
---|
2173 | (d:roles x)) |
---|
2174 | (find-if |
---|
2175 | #'(lambda(y) |
---|
2176 | (and (eql (d:instance-of y) isi-object) |
---|
2177 | (= (length (d:psis (d:player y))) 1) |
---|
2178 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2179 | prometheus))) |
---|
2180 | (d:roles x)))) |
---|
2181 | assocs) |
---|
2182 | 1))))) |
---|
2183 | |
---|
2184 | |
---|
2185 | (test test-poems-rdf-typing |
---|
2186 | "Tests general functionality of the rdf-importer module with the file |
---|
2187 | poems_light.rdf." |
---|
2188 | (with-fixture rdf-test-db () |
---|
2189 | (let ((assocs (elephant:get-instances-by-class 'd:AssociationC)) |
---|
2190 | (type (get-item-by-psi constants:*type-psi*)) |
---|
2191 | (instance (get-item-by-psi constants:*instance-psi*)) |
---|
2192 | (type-instance (get-item-by-psi constants:*type-instance-psi*)) |
---|
2193 | (subtype (get-item-by-psi constants:*subtype-psi*)) |
---|
2194 | (supertype (get-item-by-psi constants:*supertype-psi*)) |
---|
2195 | (supertype-subtype |
---|
2196 | (get-item-by-psi constants:*supertype-subtype-psi*)) |
---|
2197 | (region "http://some.where/types/Region") |
---|
2198 | (metropolis "http://some.where/types/Metropolis") |
---|
2199 | (city "http://some.where/types/City") |
---|
2200 | (frankfurt "http://some.where/metropolis/FrankfurtMain") |
---|
2201 | (weimar "http://some.where/city/Weimar") |
---|
2202 | (berlin "http://some.where/metropolis/Berlin") |
---|
2203 | (language "http://some.where/types/Language") |
---|
2204 | (german "http://some.where/language/German") |
---|
2205 | (author "http://some.where/types/Author") |
---|
2206 | (goethe "http://some.where/author/Goethe") |
---|
2207 | (bag (concatenate 'string constants::*rdf-ns* "Bag")) |
---|
2208 | (poem "http://some.where/types/Poem") |
---|
2209 | (ballad "http://some.where/types/Ballad") |
---|
2210 | (zauberlehrling "http://some.where/poem/Der_Zauberlehrling") |
---|
2211 | (prometheus "http://some.where/poem/Prometheus") |
---|
2212 | (erlkoenig "http://some.where/ballad/Der_Erlkoenig") |
---|
2213 | (country "http://some.where/types/Country")) |
---|
2214 | (is (= (count-if |
---|
2215 | #'(lambda(x) |
---|
2216 | (and (eql (d:instance-of x) supertype-subtype) |
---|
2217 | (= (length (d:roles x)) 2) |
---|
2218 | (= (count-if |
---|
2219 | #'(lambda(y) |
---|
2220 | (or (eql (d:instance-of y) supertype) |
---|
2221 | (eql (d:instance-of y) subtype))) |
---|
2222 | (d:roles x))))) |
---|
2223 | assocs))) |
---|
2224 | (is (= (count-if |
---|
2225 | #'(lambda(x) |
---|
2226 | (and (eql (d:instance-of x) supertype-subtype) |
---|
2227 | (= (length (d:roles x)) 2) |
---|
2228 | (find-if |
---|
2229 | #'(lambda(y) |
---|
2230 | (and (eql (d:instance-of y) supertype) |
---|
2231 | (= (length (d:psis (d:player y))) 1) |
---|
2232 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2233 | region))) |
---|
2234 | (d:roles x)) |
---|
2235 | (find-if |
---|
2236 | #'(lambda(y) |
---|
2237 | (and (eql (d:instance-of y) subtype) |
---|
2238 | (= (length (d:psis (d:player y))) 1) |
---|
2239 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2240 | metropolis))) |
---|
2241 | (d:roles x)))) |
---|
2242 | assocs))) |
---|
2243 | (is (= (count-if |
---|
2244 | #'(lambda(x) |
---|
2245 | (and (eql (d:instance-of x) supertype-subtype) |
---|
2246 | (= (length (d:roles x)) 2) |
---|
2247 | (find-if |
---|
2248 | #'(lambda(y) |
---|
2249 | (and (eql (d:instance-of y) supertype) |
---|
2250 | (= (length (d:psis (d:player y))) 1) |
---|
2251 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2252 | region))) |
---|
2253 | (d:roles x)) |
---|
2254 | (find-if |
---|
2255 | #'(lambda(y) |
---|
2256 | (and (eql (d:instance-of y) subtype) |
---|
2257 | (= (length (d:psis (d:player y))) 1) |
---|
2258 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2259 | city))) |
---|
2260 | (d:roles x)))) |
---|
2261 | assocs))) |
---|
2262 | (is (= (count-if |
---|
2263 | #'(lambda(x) |
---|
2264 | (and (eql (d:instance-of x) type-instance) |
---|
2265 | (= (length (d:roles x)) 2) |
---|
2266 | (find-if |
---|
2267 | #'(lambda(y) |
---|
2268 | (and (eql (d:instance-of y) type) |
---|
2269 | (= (length (d:psis (d:player y))) 1) |
---|
2270 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2271 | metropolis))) |
---|
2272 | (d:roles x)) |
---|
2273 | (find-if |
---|
2274 | #'(lambda(y) |
---|
2275 | (and (eql (d:instance-of y) instance) |
---|
2276 | (= (length (d:psis (d:player y))) 1) |
---|
2277 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2278 | frankfurt))) |
---|
2279 | (d:roles x)))) |
---|
2280 | assocs))) |
---|
2281 | (is (= (count-if |
---|
2282 | #'(lambda(x) |
---|
2283 | (and (eql (d:instance-of x) type-instance) |
---|
2284 | (= (length (d:roles x)) 2) |
---|
2285 | (find-if |
---|
2286 | #'(lambda(y) |
---|
2287 | (and (eql (d:instance-of y) type) |
---|
2288 | (= (length (d:psis (d:player y))) 1) |
---|
2289 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2290 | metropolis))) |
---|
2291 | (d:roles x)) |
---|
2292 | (find-if |
---|
2293 | #'(lambda(y) |
---|
2294 | (and (eql (d:instance-of y) instance) |
---|
2295 | (= (length (d:psis (d:player y))) 1) |
---|
2296 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2297 | berlin))) |
---|
2298 | (d:roles x)))) |
---|
2299 | assocs))) |
---|
2300 | (is (= (count-if |
---|
2301 | #'(lambda(x) |
---|
2302 | (and (eql (d:instance-of x) type-instance) |
---|
2303 | (= (length (d:roles x)) 2) |
---|
2304 | (find-if |
---|
2305 | #'(lambda(y) |
---|
2306 | (and (eql (d:instance-of y) type) |
---|
2307 | (= (length (d:psis (d:player y))) 1) |
---|
2308 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2309 | city))) |
---|
2310 | (d:roles x)) |
---|
2311 | (find-if |
---|
2312 | #'(lambda(y) |
---|
2313 | (and (eql (d:instance-of y) instance) |
---|
2314 | (= (length (d:psis (d:player y))) 1) |
---|
2315 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2316 | weimar))) |
---|
2317 | (d:roles x)))) |
---|
2318 | assocs))) |
---|
2319 | (is (= (count-if |
---|
2320 | #'(lambda(x) |
---|
2321 | (and (eql (d:instance-of x) type-instance) |
---|
2322 | (= (length (d:roles x)) 2) |
---|
2323 | (find-if |
---|
2324 | #'(lambda(y) |
---|
2325 | (and (eql (d:instance-of y) type) |
---|
2326 | (= (length (d:psis (d:player y))) 1) |
---|
2327 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2328 | language))) |
---|
2329 | (d:roles x)) |
---|
2330 | (find-if |
---|
2331 | #'(lambda(y) |
---|
2332 | (and (eql (d:instance-of y) instance) |
---|
2333 | (= (length (d:psis (d:player y))) 1) |
---|
2334 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2335 | german))) |
---|
2336 | (d:roles x)))) |
---|
2337 | assocs))) |
---|
2338 | (is (= (count-if |
---|
2339 | #'(lambda(x) |
---|
2340 | (and (eql (d:instance-of x) type-instance) |
---|
2341 | (= (length (d:roles x)) 2) |
---|
2342 | (find-if |
---|
2343 | #'(lambda(y) |
---|
2344 | (and (eql (d:instance-of y) type) |
---|
2345 | (= (length (d:psis (d:player y))) 1) |
---|
2346 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2347 | bag))) |
---|
2348 | (d:roles x)) |
---|
2349 | (find-if |
---|
2350 | #'(lambda(y) |
---|
2351 | (and (eql (d:instance-of y) instance) |
---|
2352 | (= (length (d:psis (d:player y))) 0))) |
---|
2353 | (d:roles x)))) |
---|
2354 | assocs))) |
---|
2355 | (is (= (count-if |
---|
2356 | #'(lambda(x) |
---|
2357 | (and (eql (d:instance-of x) type-instance) |
---|
2358 | (= (length (d:roles x)) 2) |
---|
2359 | (find-if |
---|
2360 | #'(lambda(y) |
---|
2361 | (and (eql (d:instance-of y) type) |
---|
2362 | (= (length (d:psis (d:player y))) 1) |
---|
2363 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2364 | author))) |
---|
2365 | (d:roles x)) |
---|
2366 | (find-if |
---|
2367 | #'(lambda(y) |
---|
2368 | (and (eql (d:instance-of y) instance) |
---|
2369 | (= (length (d:psis (d:player y))) 1) |
---|
2370 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2371 | goethe))) |
---|
2372 | (d:roles x)))) |
---|
2373 | assocs))) |
---|
2374 | (is (= (count-if |
---|
2375 | #'(lambda(x) |
---|
2376 | (and (eql (d:instance-of x) type-instance) |
---|
2377 | (= (length (d:roles x)) 2) |
---|
2378 | (find-if |
---|
2379 | #'(lambda(y) |
---|
2380 | (and (eql (d:instance-of y) type) |
---|
2381 | (= (length (d:psis (d:player y))) 1) |
---|
2382 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2383 | ballad))) |
---|
2384 | (d:roles x)) |
---|
2385 | (find-if |
---|
2386 | #'(lambda(y) |
---|
2387 | (and (eql (d:instance-of y) instance) |
---|
2388 | (= (length (d:psis (d:player y))) 1) |
---|
2389 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2390 | erlkoenig))) |
---|
2391 | (d:roles x)))) |
---|
2392 | assocs))) |
---|
2393 | (is (= (count-if |
---|
2394 | #'(lambda(x) |
---|
2395 | (and (eql (d:instance-of x) type-instance) |
---|
2396 | (= (length (d:roles x)) 2) |
---|
2397 | (find-if |
---|
2398 | #'(lambda(y) |
---|
2399 | (and (eql (d:instance-of y) type) |
---|
2400 | (= (length (d:psis (d:player y))) 1) |
---|
2401 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2402 | poem))) |
---|
2403 | (d:roles x)) |
---|
2404 | (find-if |
---|
2405 | #'(lambda(y) |
---|
2406 | (and (eql (d:instance-of y) instance) |
---|
2407 | (= (length (d:psis (d:player y))) 1) |
---|
2408 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2409 | zauberlehrling))) |
---|
2410 | (d:roles x)))) |
---|
2411 | assocs))) |
---|
2412 | (is (= (count-if |
---|
2413 | #'(lambda(x) |
---|
2414 | (and (eql (d:instance-of x) type-instance) |
---|
2415 | (= (length (d:roles x)) 2) |
---|
2416 | (find-if |
---|
2417 | #'(lambda(y) |
---|
2418 | (and (eql (d:instance-of y) type) |
---|
2419 | (= (length (d:psis (d:player y))) 1) |
---|
2420 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2421 | poem))) |
---|
2422 | (d:roles x)) |
---|
2423 | (find-if |
---|
2424 | #'(lambda(y) |
---|
2425 | (and (eql (d:instance-of y) instance) |
---|
2426 | (= (length (d:psis (d:player y))) 1) |
---|
2427 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2428 | prometheus))) |
---|
2429 | (d:roles x)))) |
---|
2430 | assocs))) |
---|
2431 | (is (= (count-if |
---|
2432 | #'(lambda(x) |
---|
2433 | (and (eql (d:instance-of x) type-instance) |
---|
2434 | (= (length (d:roles x)) 2) |
---|
2435 | (find-if |
---|
2436 | #'(lambda(y) |
---|
2437 | (and (eql (d:instance-of y) type) |
---|
2438 | (= (length (d:psis (d:player y))) 1) |
---|
2439 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2440 | country))) |
---|
2441 | (d:roles x)) |
---|
2442 | (find-if |
---|
2443 | #'(lambda(y) |
---|
2444 | (and (eql (d:instance-of y) instance) |
---|
2445 | (= (length (d:psis (d:player y))) 1) |
---|
2446 | (string= (d:uri (first (d:psis (d:player y)))) |
---|
2447 | poem))) |
---|
2448 | (d:roles x)))) |
---|
2449 | assocs)))))) |
---|
2450 | |
---|
2451 | |
---|
2452 | (defun check-topic (top psi) |
---|
2453 | "A simple helper for test-poems-rdf-topics." |
---|
2454 | (is-true top) |
---|
2455 | (is (= (length (d:psis top)) (if psi 1 0))) |
---|
2456 | (when psi |
---|
2457 | (is (string= (d:uri (first (d:psis top))) psi))) |
---|
2458 | (is (= (length (d:names top)) 0))) |
---|
2459 | |
---|
2460 | |
---|
2461 | (test test-poems-rdf-topics |
---|
2462 | "Tests general functionality of the rdf-importer module with the file |
---|
2463 | poems_light.rdf." |
---|
2464 | (with-fixture rdf-test-db () |
---|
2465 | (let ((arcs "http://some.where/relationship/") |
---|
2466 | (types "http://some.where/types/")) |
---|
2467 | (let ((goethe (get-item-by-id "http://some.where/author/Goethe")) |
---|
2468 | (author (get-item-by-id (concatenate 'string types "Author"))) |
---|
2469 | (first-name (get-item-by-id |
---|
2470 | (concatenate 'string arcs "firstName"))) |
---|
2471 | (last-name (get-item-by-id |
---|
2472 | (concatenate 'string arcs "lastName"))) |
---|
2473 | (born (get-item-by-id (concatenate 'string arcs "born"))) |
---|
2474 | (event (get-item-by-id (concatenate 'string types "Event"))) |
---|
2475 | (date (get-item-by-id (concatenate 'string arcs "date"))) |
---|
2476 | (place (get-item-by-id (concatenate 'string arcs "place"))) |
---|
2477 | (frankfurt (get-item-by-id |
---|
2478 | "http://some.where/metropolis/FrankfurtMain")) |
---|
2479 | (metropolis (get-item-by-id (concatenate 'string types |
---|
2480 | "Metropolis"))) |
---|
2481 | (region (get-item-by-id (concatenate 'string types "Region"))) |
---|
2482 | (population (get-item-by-id (concatenate 'string arcs |
---|
2483 | "population"))) |
---|
2484 | (locatedIn (get-item-by-id (concatenate 'string arcs |
---|
2485 | "locatedIn"))) |
---|
2486 | (germany (get-item-by-id "http://some.where/country/Germany")) |
---|
2487 | (country (get-item-by-id (concatenate 'string types "Country"))) |
---|
2488 | (native-name (get-item-by-id (concatenate 'string arcs |
---|
2489 | "nativeName"))) |
---|
2490 | (officialese (get-item-by-id (concatenate 'string arcs |
---|
2491 | "officialese"))) |
---|
2492 | (german (get-item-by-id "http://some.where/language/German")) |
---|
2493 | (capital (get-item-by-id (concatenate 'string arcs "capital"))) |
---|
2494 | (berlin (get-item-by-id "http://some.where/metropolis/Berlin")) |
---|
2495 | (died (get-item-by-id (concatenate 'string arcs "died"))) |
---|
2496 | (weimar (get-item-by-id "http://some.where/city/Weimar")) |
---|
2497 | (city (get-item-by-id (concatenate 'string types "City"))) |
---|
2498 | (wrote (get-item-by-id (concatenate 'string arcs "wrote"))) |
---|
2499 | (goethe-literature (get-item-by-id "goethe_literature")) |
---|
2500 | (bag (get-item-by-id (concatenate 'string *rdf-ns* "Bag"))) |
---|
2501 | (_1 (get-item-by-id (concatenate 'string *rdf-ns* "_1"))) |
---|
2502 | (_2 (get-item-by-id (concatenate 'string *rdf-ns* "_2"))) |
---|
2503 | (_3 (get-item-by-id (concatenate 'string *rdf-ns* "_3"))) |
---|
2504 | (zauberlehrling |
---|
2505 | (get-item-by-id "http://some.where/poem/Der_Zauberlehrling")) |
---|
2506 | (poem (get-item-by-id (concatenate 'string types "Poem"))) |
---|
2507 | (dateRange (get-item-by-id (concatenate 'string arcs "dateRange"))) |
---|
2508 | (start (get-item-by-id (concatenate 'string arcs "start"))) |
---|
2509 | (end (get-item-by-id (concatenate 'string arcs "end"))) |
---|
2510 | (title (get-item-by-id (concatenate 'string arcs "title"))) |
---|
2511 | (content (get-item-by-id (concatenate 'string arcs "content"))) |
---|
2512 | (erlkoenig (get-item-by-id "http://some.where/ballad/Der_Erlkoenig")) |
---|
2513 | (ballad (get-item-by-id (concatenate 'string types "Ballad"))) |
---|
2514 | (de (get-item-by-id (concatenate |
---|
2515 | 'string constants::*rdf2tm-scope-prefix* |
---|
2516 | "de"))) |
---|
2517 | (prometheus (get-item-by-id "http://some.where/poem/Prometheus")) |
---|
2518 | (language (get-item-by-id (concatenate 'string types "Language"))) |
---|
2519 | (full-name (get-item-by-id (concatenate 'string arcs "fullName")))) |
---|
2520 | (check-topic goethe "http://some.where/author/Goethe") |
---|
2521 | (check-topic author (concatenate 'string types "Author")) |
---|
2522 | (check-topic first-name (concatenate 'string arcs "firstName")) |
---|
2523 | (check-topic last-name (concatenate 'string arcs "lastName")) |
---|
2524 | (check-topic born (concatenate 'string arcs "born")) |
---|
2525 | (check-topic event (concatenate 'string types "Event")) |
---|
2526 | (check-topic date (concatenate 'string arcs "date")) |
---|
2527 | (check-topic place (concatenate 'string arcs "place")) |
---|
2528 | (check-topic frankfurt "http://some.where/metropolis/FrankfurtMain") |
---|
2529 | (check-topic metropolis (concatenate 'string types "Metropolis")) |
---|
2530 | (check-topic region (concatenate 'string types "Region")) |
---|
2531 | (check-topic population (concatenate 'string arcs "population")) |
---|
2532 | (check-topic locatedIn (concatenate 'string arcs "locatedIn")) |
---|
2533 | (check-topic germany "http://some.where/country/Germany") |
---|
2534 | (check-topic country (concatenate 'string types "Country")) |
---|
2535 | (check-topic native-name (concatenate 'string arcs "nativeName")) |
---|
2536 | (check-topic officialese (concatenate 'string arcs "officialese")) |
---|
2537 | (check-topic german "http://some.where/language/German") |
---|
2538 | (check-topic capital (concatenate 'string arcs "capital")) |
---|
2539 | (check-topic berlin "http://some.where/metropolis/Berlin") |
---|
2540 | (check-topic died (concatenate 'string arcs "died")) |
---|
2541 | (check-topic weimar "http://some.where/city/Weimar") |
---|
2542 | (check-topic city (concatenate 'string types "City")) |
---|
2543 | (check-topic wrote (concatenate 'string arcs "wrote")) |
---|
2544 | (check-topic goethe-literature nil) |
---|
2545 | (check-topic bag (concatenate 'string *rdf-ns* "Bag")) |
---|
2546 | (check-topic _1 (concatenate 'string *rdf-ns* "_1")) |
---|
2547 | (check-topic _2 (concatenate 'string *rdf-ns* "_2")) |
---|
2548 | (check-topic _3 (concatenate 'string *rdf-ns* "_3")) |
---|
2549 | (check-topic zauberlehrling "http://some.where/poem/Der_Zauberlehrling") |
---|
2550 | (check-topic poem (concatenate 'string types "Poem")) |
---|
2551 | (check-topic dateRange (concatenate 'string arcs "dateRange")) |
---|
2552 | (check-topic start (concatenate 'string arcs "start")) |
---|
2553 | (check-topic end (concatenate 'string arcs "end")) |
---|
2554 | (check-topic title (concatenate 'string arcs "title")) |
---|
2555 | (check-topic content (concatenate 'string arcs "content")) |
---|
2556 | (check-topic erlkoenig "http://some.where/ballad/Der_Erlkoenig") |
---|
2557 | (check-topic ballad (concatenate 'string types "Ballad")) |
---|
2558 | (check-topic de (concatenate 'string constants::*rdf2tm-scope-prefix* |
---|
2559 | "de")) |
---|
2560 | (check-topic prometheus "http://some.where/poem/Prometheus") |
---|
2561 | (check-topic language (concatenate 'string types "Language")) |
---|
2562 | (check-topic full-name (concatenate 'string arcs "fullName")) |
---|
2563 | (is (= (count-if #'(lambda(x) |
---|
2564 | (null (d:psis x))) |
---|
2565 | (elephant:get-instances-by-class 'd:TopicC)) |
---|
2566 | 6)))))) |
---|
2567 | |
---|
2568 | |
---|
2569 | (test test-empty-collection |
---|
2570 | "Tests importing of empty collections." |
---|
2571 | (let ((db-dir "data_base") |
---|
2572 | (tm-id "http://test-tm/") |
---|
2573 | (revision-1 100) |
---|
2574 | (document-id "doc-id") |
---|
2575 | (doc-1 |
---|
2576 | (concatenate 'string "<rdf:RDF xmlns:rdf=\"" *rdf-ns* "\" " |
---|
2577 | "xmlns:arcs=\"http://test/arcs/\">" |
---|
2578 | " <rdf:Description rdf:about=\"first-node\">" |
---|
2579 | " <arcs:arc rdf:parseType=\"Collection\" />" |
---|
2580 | " </rdf:Description>" |
---|
2581 | "</rdf:RDF>"))) |
---|
2582 | (let ((rdf-node (elt (dom:child-nodes |
---|
2583 | (cxml:parse doc-1 (cxml-dom:make-dom-builder))) |
---|
2584 | 0))) |
---|
2585 | (is-true rdf-node) |
---|
2586 | (rdf-init-db :db-dir db-dir :start-revision revision-1) |
---|
2587 | (rdf-importer::import-dom rdf-node revision-1 :tm-id tm-id |
---|
2588 | :document-id document-id) |
---|
2589 | (is (= (length (elephant:get-instances-by-class 'd:TopicC)) 21)) |
---|
2590 | (is (= (length (elephant:get-instances-by-class 'd:AssociationC)) 1)) |
---|
2591 | (is (= (length (elephant:get-instances-by-class 'd:OccurrenceC)) 0)) |
---|
2592 | (is (= (length (elephant:get-instances-by-class 'd:NameC)) 0)) |
---|
2593 | (let ((first-node (d:get-item-by-id "http://test-tm/first-node" |
---|
2594 | :xtm-id document-id)) |
---|
2595 | (arc (d:get-item-by-id "http://test/arcs/arc" |
---|
2596 | :xtm-id document-id)) |
---|
2597 | (rdf-nil (d:get-item-by-id constants:*rdf-nil* |
---|
2598 | :xtm-id document-id)) |
---|
2599 | (subject (d:get-item-by-id constants:*rdf2tm-subject*)) |
---|
2600 | (object (d:get-item-by-id constants:*rdf2tm-object*))) |
---|
2601 | (is-true subject) |
---|
2602 | (is-true object) |
---|
2603 | (is-true first-node) |
---|
2604 | (is (= (length (d:psis first-node)) 1)) |
---|
2605 | (is (string= (d:uri (first (d:psis first-node))) |
---|
2606 | "http://test-tm/first-node")) |
---|
2607 | (is-true arc) |
---|
2608 | (is (= (length (d:psis arc)) 1)) |
---|
2609 | (is (string= (d:uri (first (d:psis arc))) |
---|
2610 | "http://test/arcs/arc")) |
---|
2611 | (is-true rdf-nil) |
---|
2612 | (is (= (length (d:psis rdf-nil)) 1)) |
---|
2613 | (is (string= (d:uri (first (d:psis rdf-nil))) constants:*rdf-nil*)) |
---|
2614 | (is (= (length (d:player-in-roles first-node)) 1)) |
---|
2615 | (is (= (length (d:player-in-roles arc)) 0)) |
---|
2616 | (is (= (length (d:player-in-roles rdf-nil)) 1)) |
---|
2617 | (is-true (find-if |
---|
2618 | #'(lambda(x) |
---|
2619 | (and (eql (d:instance-of x) subject) |
---|
2620 | (eql (d:instance-of (d:parent x)) arc))) |
---|
2621 | (d:player-in-roles first-node))) |
---|
2622 | (is-true (find-if |
---|
2623 | #'(lambda(x) |
---|
2624 | (and (eql (d:instance-of x) object) |
---|
2625 | (eql (d:instance-of (d:parent x)) arc))) |
---|
2626 | (d:player-in-roles rdf-nil))))))) |
---|
2627 | |
---|
2628 | |
---|
2629 | (test test-collection |
---|
2630 | "Tests importing of non-empty collections." |
---|
2631 | (let ((db-dir "data_base") |
---|
2632 | (tm-id "http://test-tm/") |
---|
2633 | (revision-1 100) |
---|
2634 | (document-id "doc-id") |
---|
2635 | (doc-1 |
---|
2636 | (concatenate 'string "<rdf:RDF xmlns:rdf=\"" *rdf-ns* "\" " |
---|
2637 | "xmlns:arcs=\"http://test/arcs/\">" |
---|
2638 | " <rdf:Description rdf:about=\"first-node\">" |
---|
2639 | " <arcs:arc rdf:parseType=\"Collection\">" |
---|
2640 | " <rdf:Description rdf:about=\"item-1\"/>" |
---|
2641 | " <arcs:Node rdf:about=\"item-2\"/>" |
---|
2642 | " </arcs:arc>" |
---|
2643 | " </rdf:Description>" |
---|
2644 | "</rdf:RDF>"))) |
---|
2645 | (let ((rdf-node (elt (dom:child-nodes |
---|
2646 | (cxml:parse doc-1 (cxml-dom:make-dom-builder))) |
---|
2647 | 0))) |
---|
2648 | (is-true rdf-node) |
---|
2649 | (rdf-init-db :db-dir db-dir :start-revision revision-1) |
---|
2650 | (rdf-importer::import-dom rdf-node revision-1 :tm-id tm-id |
---|
2651 | :document-id document-id) |
---|
2652 | (is (= (length (elephant:get-instances-by-class 'd:TopicC)) 28)) |
---|
2653 | (is (= (length (elephant:get-instances-by-class 'd:AssociationC)) 6)) |
---|
2654 | (is (= (length (elephant:get-instances-by-class 'd:OccurrenceC)) 0)) |
---|
2655 | (is (= (length (elephant:get-instances-by-class 'd:NameC)) 0)) |
---|
2656 | (let ((first-node (d:get-item-by-id "http://test-tm/first-node" |
---|
2657 | :xtm-id document-id)) |
---|
2658 | (arc (d:get-item-by-id "http://test/arcs/arc" |
---|
2659 | :xtm-id document-id)) |
---|
2660 | (item-1 (d:get-item-by-id "http://test-tm/item-1" |
---|
2661 | :xtm-id document-id)) |
---|
2662 | (item-2 (d:get-item-by-id "http://test-tm/item-2" |
---|
2663 | :xtm-id document-id)) |
---|
2664 | (node (d:get-item-by-id "http://test/arcs/Node" |
---|
2665 | :xtm-id document-id)) |
---|
2666 | (rdf-first (d:get-item-by-id constants:*rdf-first* |
---|
2667 | :xtm-id document-id)) |
---|
2668 | (rdf-rest (d:get-item-by-id constants:*rdf-rest* |
---|
2669 | :xtm-id document-id)) |
---|
2670 | (rdf-nil (d:get-item-by-id constants:*rdf-nil* |
---|
2671 | :xtm-id document-id)) |
---|
2672 | (subject (d:get-item-by-id constants:*rdf2tm-subject* |
---|
2673 | :xtm-id document-id)) |
---|
2674 | (object (d:get-item-by-id constants:*rdf2tm-object* |
---|
2675 | :xtm-id document-id)) |
---|
2676 | (instance (d:get-item-by-psi constants:*instance-psi*)) |
---|
2677 | (type (d:get-item-by-psi constants:*type-psi*)) |
---|
2678 | (type-instance (d:get-item-by-psi constants:*type-instance-psi*))) |
---|
2679 | (is-true first-node) |
---|
2680 | (is (= (length (d:psis first-node)) 1)) |
---|
2681 | (is (string= (d:uri (first (d:psis first-node))) |
---|
2682 | "http://test-tm/first-node")) |
---|
2683 | (is (= (length (d:player-in-roles first-node)) 1)) |
---|
2684 | (is-true arc) |
---|
2685 | (is (= (length (d:psis arc)) 1)) |
---|
2686 | (is (string= (d:uri (first (d:psis arc))) |
---|
2687 | "http://test/arcs/arc")) |
---|
2688 | (is (= (length (d:player-in-roles arc)) 0)) |
---|
2689 | (is-true item-1) |
---|
2690 | (is (= (length (d:psis item-1)) 1)) |
---|
2691 | (is (string= (d:uri (first (d:psis item-1))) |
---|
2692 | "http://test-tm/item-1")) |
---|
2693 | (is (= (length (d:player-in-roles item-1)) 1)) |
---|
2694 | (is-true item-2) |
---|
2695 | (is (= (length (d:psis item-2)) 1)) |
---|
2696 | (is (string= (d:uri (first (d:psis item-2))) |
---|
2697 | "http://test-tm/item-2")) |
---|
2698 | (is (= (length (d:player-in-roles item-2)) 2)) |
---|
2699 | (is-true node) |
---|
2700 | (is (= (length (d:psis node)) 1)) |
---|
2701 | (is (string= (d:uri (first (d:psis node))) |
---|
2702 | "http://test/arcs/Node")) |
---|
2703 | (is (= (length (d:player-in-roles node)) 1)) |
---|
2704 | (is-true rdf-first) |
---|
2705 | (is-true rdf-rest) |
---|
2706 | (is-true rdf-nil) |
---|
2707 | (is (= (length (d:player-in-roles rdf-nil)) 1)) |
---|
2708 | (is-true subject) |
---|
2709 | (is-true object) |
---|
2710 | (let ((uuid-1 |
---|
2711 | (d:player |
---|
2712 | (find-if |
---|
2713 | #'(lambda(x) |
---|
2714 | (not (eql x (first (d:player-in-roles first-node))))) |
---|
2715 | (d:roles (d:parent (first (d:player-in-roles first-node))))))) |
---|
2716 | (uuid-2 |
---|
2717 | (d:player |
---|
2718 | (find-if |
---|
2719 | #'(lambda(x) |
---|
2720 | (not (eql x (first (d:player-in-roles rdf-nil))))) |
---|
2721 | (d:roles (d:parent (first (d:player-in-roles rdf-nil)))))))) |
---|
2722 | (is-true uuid-1) |
---|
2723 | (is (= (length (d:psis uuid-1)) 0)) |
---|
2724 | (is (= (length (d:player-in-roles uuid-1)) 3)) |
---|
2725 | (is-true uuid-2) |
---|
2726 | (is (= (length (d:psis uuid-2)) 0)) |
---|
2727 | (is (= (length (d:player-in-roles uuid-2)) 3)) |
---|
2728 | (is-true (find-if |
---|
2729 | #'(lambda(x) |
---|
2730 | (and (eql (d:instance-of x) subject) |
---|
2731 | (eql (d:instance-of (d:parent x)) arc))) |
---|
2732 | (d:player-in-roles first-node))) |
---|
2733 | (is-true (find-if |
---|
2734 | #'(lambda(x) |
---|
2735 | (and (eql (d:instance-of x) object) |
---|
2736 | (eql (d:instance-of (d:parent x)) arc))) |
---|
2737 | (d:player-in-roles uuid-1))) |
---|
2738 | (is-true (find-if |
---|
2739 | #'(lambda(x) |
---|
2740 | (and (eql (d:instance-of x) subject) |
---|
2741 | (eql (d:instance-of (d:parent x)) rdf-first))) |
---|
2742 | (d:player-in-roles uuid-1))) |
---|
2743 | (is-true (find-if |
---|
2744 | #'(lambda(x) |
---|
2745 | (and (eql (d:instance-of x) subject) |
---|
2746 | (eql (d:instance-of (d:parent x)) rdf-rest))) |
---|
2747 | (d:player-in-roles uuid-1))) |
---|
2748 | (is-true (find-if |
---|
2749 | #'(lambda(x) |
---|
2750 | (and (eql (d:instance-of x) object) |
---|
2751 | (eql (d:instance-of (d:parent x)) rdf-first))) |
---|
2752 | (d:player-in-roles item-1))) |
---|
2753 | (is-true (find-if |
---|
2754 | #'(lambda(x) |
---|
2755 | (and (eql (d:instance-of x) object) |
---|
2756 | (eql (d:instance-of (d:parent x)) rdf-rest))) |
---|
2757 | (d:player-in-roles uuid-2))) |
---|
2758 | (is-true (find-if |
---|
2759 | #'(lambda(x) |
---|
2760 | (and (eql (d:instance-of x) subject) |
---|
2761 | (eql (d:instance-of (d:parent x)) rdf-first))) |
---|
2762 | (d:player-in-roles uuid-2))) |
---|
2763 | (is-true (find-if |
---|
2764 | #'(lambda(x) |
---|
2765 | (and (eql (d:instance-of x) subject) |
---|
2766 | (eql (d:instance-of (d:parent x)) rdf-rest))) |
---|
2767 | (d:player-in-roles uuid-2))) |
---|
2768 | (is-true (find-if |
---|
2769 | #'(lambda(x) |
---|
2770 | (and (eql (d:instance-of x) object) |
---|
2771 | (eql (d:instance-of (d:parent x)) rdf-rest))) |
---|
2772 | (d:player-in-roles rdf-nil))) |
---|
2773 | (is-true (find-if |
---|
2774 | #'(lambda(x) |
---|
2775 | (and (eql (d:instance-of x) object) |
---|
2776 | (eql (d:instance-of (d:parent x)) rdf-first))) |
---|
2777 | (d:player-in-roles item-2))) |
---|
2778 | (is-true (find-if |
---|
2779 | #'(lambda(x) |
---|
2780 | (and (eql (d:instance-of x) instance) |
---|
2781 | (eql (d:instance-of (d:parent x)) type-instance))) |
---|
2782 | (d:player-in-roles item-2))) |
---|
2783 | (is-true (find-if |
---|
2784 | #'(lambda(x) |
---|
2785 | (and (eql (d:instance-of x) type) |
---|
2786 | (eql (d:instance-of (d:parent x)) type-instance))) |
---|
2787 | (d:player-in-roles node)))))))) |
---|
2788 | |
---|
2789 | |
---|
2790 | (test test-xml-base |
---|
2791 | "Tests the function get-xml-base." |
---|
2792 | (let ((doc-1 |
---|
2793 | (concatenate 'string "<rdf:RDF xmlns:rdf=\"" *rdf-ns* "\" " |
---|
2794 | "xmlns:arcs=\"http://test/arcs/\">" |
---|
2795 | " <rdf:Description xml:base=\"http://base-1\"/>" |
---|
2796 | " <rdf:Description xml:base=\"http://base-2#\"/>" |
---|
2797 | " <rdf:Description xml:base=\"http://base-3/\"/>" |
---|
2798 | "</rdf:RDF>"))) |
---|
2799 | (let ((dom-1 (cxml:parse doc-1 (cxml-dom:make-dom-builder)))) |
---|
2800 | (let ((rdf-node (elt (dom:child-nodes dom-1) 0))) |
---|
2801 | (let ((n-1 (elt (rdf-importer::child-nodes-or-text rdf-node |
---|
2802 | :trim t) 0)) |
---|
2803 | (n-2 (elt (rdf-importer::child-nodes-or-text rdf-node |
---|
2804 | :trim t) 1)) |
---|
2805 | (n-3 (elt (rdf-importer::child-nodes-or-text rdf-node |
---|
2806 | :trim t) 2))) |
---|
2807 | (is (string= (xml-tools::concatenate-uri |
---|
2808 | (xml-tools:get-xml-base n-1) |
---|
2809 | "test") |
---|
2810 | "http://base-1/test")) |
---|
2811 | (is (string= (xml-tools::concatenate-uri |
---|
2812 | (xml-tools:get-xml-base n-1) |
---|
2813 | "/test") |
---|
2814 | "http://base-1/test")) |
---|
2815 | (is (string= (xml-tools::concatenate-uri |
---|
2816 | (xml-tools:get-xml-base n-1) |
---|
2817 | "#test") |
---|
2818 | "http://base-1#test")) |
---|
2819 | (is (string= (xml-tools::concatenate-uri |
---|
2820 | (xml-tools:get-xml-base n-2) |
---|
2821 | "test") |
---|
2822 | "http://base-2#test")) |
---|
2823 | (is (string= (xml-tools::concatenate-uri |
---|
2824 | (xml-tools:get-xml-base n-2) |
---|
2825 | "#test") |
---|
2826 | "http://base-2#test")) |
---|
2827 | (is (string= (xml-tools::concatenate-uri |
---|
2828 | (xml-tools:get-xml-base n-2) |
---|
2829 | "/test") |
---|
2830 | "http://base-2/test")) |
---|
2831 | (is (string= (xml-tools::concatenate-uri |
---|
2832 | (xml-tools:get-xml-base n-2) |
---|
2833 | "/t/est") |
---|
2834 | "http://base-2/t/est")) |
---|
2835 | (is (string= (xml-tools::concatenate-uri |
---|
2836 | (xml-tools:get-xml-base n-2) |
---|
2837 | "t/est") |
---|
2838 | "http://base-2/t/est")) |
---|
2839 | (signals error (xml-tools::concatenate-uri |
---|
2840 | (xml-tools:get-xml-base n-2) "")) |
---|
2841 | (signals error (xml-tools::concatenate-uri |
---|
2842 | "" "test")) |
---|
2843 | (is (string= (xml-tools::concatenate-uri |
---|
2844 | (xml-tools:get-xml-base n-3) |
---|
2845 | "test") |
---|
2846 | "http://base-3/test")) |
---|
2847 | (is (string= (xml-tools::concatenate-uri |
---|
2848 | (xml-tools:get-xml-base n-3) |
---|
2849 | "#test") |
---|
2850 | "http://base-3/#test")) |
---|
2851 | (is (string= (xml-tools::concatenate-uri |
---|
2852 | (xml-tools:get-xml-base n-3) |
---|
2853 | "/test") |
---|
2854 | "http://base-3/test"))))))) |
---|
2855 | |
---|
2856 | |
---|
2857 | (test test-full-mapping-marge |
---|
2858 | "Tests the entire importer module." |
---|
2859 | (let ((dir "data_base") |
---|
2860 | (rdf-file unittests-constants:*full_mapping.rdf*) |
---|
2861 | (tm-id "http://full-mapping/") |
---|
2862 | (document-id "http://full_mapping.rdf")) |
---|
2863 | (when elephant:*store-controller* |
---|
2864 | (elephant:close-store)) |
---|
2865 | (fixtures::clean-out-db dir) |
---|
2866 | (rdf-importer:rdf-importer rdf-file dir |
---|
2867 | :tm-id tm-id |
---|
2868 | :document-id document-id) |
---|
2869 | (elephant:open-store (xml-importer:get-store-spec dir)) |
---|
2870 | (is (= (length (elephant:get-instances-by-class 'd:TopicC)) 15)) |
---|
2871 | (is (= (length (elephant:get-instances-by-class 'd:AssociationC)) 1)) |
---|
2872 | (is (= (length (elephant:get-instances-by-class 'd:NameC)) 4)) |
---|
2873 | (is (= (length (elephant:get-instances-by-class 'd:RoleC)) 2)) |
---|
2874 | (is (= (length (elephant:get-instances-by-class 'd:OccurrenceC)) 2)) |
---|
2875 | (is (= (length (elephant:get-instances-by-class 'd:VariantC)) 2)) |
---|
2876 | (setf d:*current-xtm* document-id) |
---|
2877 | (let ((firstName (get-item-by-id "http://simpsons/firstName")) |
---|
2878 | (lastName (get-item-by-id "http://simpsons/lastName")) |
---|
2879 | (display (get-item-by-id "http://simpsons/display")) |
---|
2880 | (profession (get-item-by-id "http://simpsons/profession")) |
---|
2881 | (married (get-item-by-id "http://simpsons/married")) |
---|
2882 | (husband (get-item-by-id "http://simpsons/husband")) |
---|
2883 | (wife (get-item-by-id "http://simpsons/wife")) |
---|
2884 | (en (get-item-by-id "http://simpsons/en")) |
---|
2885 | (type (get-item-by-psi *type-psi*)) |
---|
2886 | (instance (get-item-by-psi *instance-psi*)) |
---|
2887 | (type-instance (get-item-by-psi *type-instance-psi*)) |
---|
2888 | (isi-object (get-item-by-psi *rdf2tm-object*)) |
---|
2889 | (isi-subject (get-item-by-psi *rdf2tm-subject*)) |
---|
2890 | (marge (get-item-by-id "http://simpsons/marge")) |
---|
2891 | (homer (get-item-by-id "http://simpsons/homer")) |
---|
2892 | (role-husband |
---|
2893 | (find-if #'(lambda(x) |
---|
2894 | (let ((iis (d:item-identifiers x))) |
---|
2895 | (when (= (length iis) 1) |
---|
2896 | (string= (d:uri (first iis)) |
---|
2897 | "http://simpsons/role-husband/ii")))) |
---|
2898 | (elephant:get-instances-by-class 'd:RoleC))) |
---|
2899 | (role-wife |
---|
2900 | (find-if #'(lambda(x) |
---|
2901 | (let ((iis (d:item-identifiers x))) |
---|
2902 | (when (= (length iis) 1) |
---|
2903 | (string= (d:uri (first iis)) |
---|
2904 | "http://simpsons/role-wife/ii")))) |
---|
2905 | (elephant:get-instances-by-class 'd:RoleC)))) |
---|
2906 | (is-true firstName) |
---|
2907 | (is-true (empty-p firstName)) |
---|
2908 | (is-true lastName) |
---|
2909 | (is-true (empty-p lastName)) |
---|
2910 | (is-true display) |
---|
2911 | (is-true (empty-p display)) |
---|
2912 | (is-true profession) |
---|
2913 | (is-true (empty-p profession)) |
---|
2914 | (is-true married) |
---|
2915 | (is-true (empty-p married)) |
---|
2916 | (is-true husband) |
---|
2917 | (is-true (empty-p husband)) |
---|
2918 | (is-true wife) |
---|
2919 | (is-true (empty-p wife)) |
---|
2920 | (is-true en) |
---|
2921 | (is-true (empty-p en)) |
---|
2922 | (is-true type) |
---|
2923 | (is-true (empty-p type)) |
---|
2924 | (is-true instance) |
---|
2925 | (is-true (empty-p instance)) |
---|
2926 | (is-true type-instance) |
---|
2927 | (is-true (empty-p type-instance)) |
---|
2928 | (is-true isi-object) |
---|
2929 | (is-true (empty-p isi-object)) |
---|
2930 | (is-true isi-subject) |
---|
2931 | (is-true (empty-p isi-subject)) |
---|
2932 | (is-true role-husband) |
---|
2933 | (is-true role-wife) |
---|
2934 | (is-true homer) |
---|
2935 | (is (= (length (d:psis marge)) 2)) |
---|
2936 | (is-true (find-if #'(lambda(x) |
---|
2937 | (string= (d:uri x) "http://simpsons/marjorie")) |
---|
2938 | (d:psis marge))) |
---|
2939 | (is (= (length (d:names marge)) 2)) |
---|
2940 | (let ((marge-fn (find-if #'(lambda(x) |
---|
2941 | (eql (instance-of x) firstName)) |
---|
2942 | (d:names marge))) |
---|
2943 | (marge-ln (find-if #'(lambda(x) |
---|
2944 | (eql (instance-of x) lastName)) |
---|
2945 | (d:names marge))) |
---|
2946 | (marge-occ (find-if #'(lambda(x) |
---|
2947 | (eql (instance-of x) profession)) |
---|
2948 | (d:occurrences marge)))) |
---|
2949 | (is-true marge-fn) |
---|
2950 | (is-true marge-ln) |
---|
2951 | (is (string= (d:charvalue marge-fn) "Marjorie")) |
---|
2952 | (is (string= (d:charvalue marge-ln) "Simpson")) |
---|
2953 | (is (= (length (d:variants marge-fn :revision 0)) 1)) |
---|
2954 | (is (= (length (d:themes (first (d:variants marge-fn :revision 0)) |
---|
2955 | :revision 0)) 1)) |
---|
2956 | (is (eql (first (d:themes (first (d:variants marge-fn :revision 0)) |
---|
2957 | :revision 0)) display)) |
---|
2958 | (is (string= (d:charvalue (first (d:variants marge-fn :revision 0))) "Marge")) |
---|
2959 | (is (string= (d:datatype (first (d:variants marge-fn :revision 0))) *xml-string*)) |
---|
2960 | (is-true marge-occ) |
---|
2961 | (is (string= (d:charvalue marge-occ) "Housewife")) |
---|
2962 | (is (string= (d:datatype marge-occ) *xml-string*)) |
---|
2963 | (is (= (length (d:themes marge-occ :revision 0)) 0)) |
---|
2964 | (is (= (length (d:psis marge :revision 0)) 2)))))) |
---|
2965 | |
---|
2966 | |
---|
2967 | (test test-full-mapping-homer |
---|
2968 | "Tests the entire importer module." |
---|
2969 | (let ((dir "data_base") |
---|
2970 | (rdf-file unittests-constants:*full_mapping.rdf*) |
---|
2971 | (tm-id "http://full-mapping/") |
---|
2972 | (document-id "http://full_mapping.rdf")) |
---|
2973 | (when elephant:*store-controller* |
---|
2974 | (elephant:close-store)) |
---|
2975 | (fixtures::clean-out-db dir) |
---|
2976 | (rdf-importer:rdf-importer rdf-file dir |
---|
2977 | :tm-id tm-id |
---|
2978 | :document-id document-id) |
---|
2979 | (elephant:open-store (xml-importer:get-store-spec dir)) |
---|
2980 | (is (= (length (elephant:get-instances-by-class 'd:TopicC)) 15)) |
---|
2981 | (is (= (length (elephant:get-instances-by-class 'd:AssociationC)) 1)) |
---|
2982 | (is (= (length (elephant:get-instances-by-class 'd:NameC)) 4)) |
---|
2983 | (is (= (length (elephant:get-instances-by-class 'd:RoleC)) 2)) |
---|
2984 | (is (= (length (elephant:get-instances-by-class 'd:OccurrenceC)) 2)) |
---|
2985 | (is (= (length (elephant:get-instances-by-class 'd:VariantC)) 2)) |
---|
2986 | (setf d:*current-xtm* document-id) |
---|
2987 | (let ((firstName (get-item-by-id "http://simpsons/firstName")) |
---|
2988 | (lastName (get-item-by-id "http://simpsons/lastName")) |
---|
2989 | (display (get-item-by-id "http://simpsons/display")) |
---|
2990 | (profession (get-item-by-id "http://simpsons/profession")) |
---|
2991 | (married (get-item-by-id "http://simpsons/married")) |
---|
2992 | (husband (get-item-by-id "http://simpsons/husband")) |
---|
2993 | (wife (get-item-by-id "http://simpsons/wife")) |
---|
2994 | (en (get-item-by-id "http://simpsons/en")) |
---|
2995 | (type (get-item-by-psi *type-psi*)) |
---|
2996 | (instance (get-item-by-psi *instance-psi*)) |
---|
2997 | (type-instance (get-item-by-psi *type-instance-psi*)) |
---|
2998 | (isi-object (get-item-by-psi *rdf2tm-object*)) |
---|
2999 | (isi-subject (get-item-by-psi *rdf2tm-subject*)) |
---|
3000 | (marge (get-item-by-id "http://simpsons/marge")) |
---|
3001 | (homer (get-item-by-id "http://simpsons/homer")) |
---|
3002 | (role-husband |
---|
3003 | (find-if #'(lambda(x) |
---|
3004 | (let ((iis (d:item-identifiers x))) |
---|
3005 | (when (= (length iis) 1) |
---|
3006 | (string= (d:uri (first iis)) |
---|
3007 | "http://simpsons/role-husband/ii")))) |
---|
3008 | (elephant:get-instances-by-class 'd:RoleC))) |
---|
3009 | (role-wife |
---|
3010 | (find-if #'(lambda(x) |
---|
3011 | (let ((iis (d:item-identifiers x))) |
---|
3012 | (when (= (length iis) 1) |
---|
3013 | (string= (d:uri (first iis)) |
---|
3014 | "http://simpsons/role-wife/ii")))) |
---|
3015 | (elephant:get-instances-by-class 'd:RoleC)))) |
---|
3016 | (is-true firstName) |
---|
3017 | (is-true (empty-p firstName)) |
---|
3018 | (is-true lastName) |
---|
3019 | (is-true (empty-p lastName)) |
---|
3020 | (is-true display) |
---|
3021 | (is-true (empty-p display)) |
---|
3022 | (is-true profession) |
---|
3023 | (is-true (empty-p profession)) |
---|
3024 | (is-true married) |
---|
3025 | (is-true (empty-p married)) |
---|
3026 | (is-true husband) |
---|
3027 | (is-true (empty-p husband)) |
---|
3028 | (is-true wife) |
---|
3029 | (is-true (empty-p wife)) |
---|
3030 | (is-true en) |
---|
3031 | (is-true (empty-p en)) |
---|
3032 | (is-true type) |
---|
3033 | (is-true (empty-p type)) |
---|
3034 | (is-true instance) |
---|
3035 | (is-true (empty-p instance)) |
---|
3036 | (is-true type-instance) |
---|
3037 | (is-true (empty-p type-instance)) |
---|
3038 | (is-true isi-object) |
---|
3039 | (is-true (empty-p isi-object)) |
---|
3040 | (is-true isi-subject) |
---|
3041 | (is-true (empty-p isi-subject)) |
---|
3042 | (is-true role-husband) |
---|
3043 | (is-true role-wife) |
---|
3044 | (is-true marge) |
---|
3045 | (is-true (find-if #'(lambda(x) |
---|
3046 | (string= (d:uri x) "http://simpsons/homer_simpson")) |
---|
3047 | (d:psis homer))) |
---|
3048 | (is (= (length (d:locators homer)) 1)) |
---|
3049 | (is-true (find-if #'(lambda(x) |
---|
3050 | (string= (d:uri x) "http://some.where/resource")) |
---|
3051 | (d:locators homer))) |
---|
3052 | (is (= (length (d:item-identifiers homer)) 1)) |
---|
3053 | (is-true (find-if #'(lambda(x) |
---|
3054 | (string= (d:uri x) "http://simpsons/ii/homer")) |
---|
3055 | (d:item-identifiers homer))) |
---|
3056 | (is (= (length (d:names homer)) 2)) |
---|
3057 | (let ((homer-fn (find-if #'(lambda(x) |
---|
3058 | (eql (instance-of x) firstName)) |
---|
3059 | (d:names homer))) |
---|
3060 | (homer-ln (find-if #'(lambda(x) |
---|
3061 | (eql (instance-of x) lastName)) |
---|
3062 | (d:names homer))) |
---|
3063 | (homer-occ (find-if #'(lambda(x) |
---|
3064 | (eql (instance-of x) profession)) |
---|
3065 | (d:occurrences homer)))) |
---|
3066 | (is-true homer-fn) |
---|
3067 | (is-true homer-ln) |
---|
3068 | (is (string= (d:charvalue homer-fn) "Homer J.")) |
---|
3069 | (is (string= (d:charvalue homer-ln) "Simpson")) |
---|
3070 | (is (= (length (d:variants homer-fn)) 1)) |
---|
3071 | (is (= (length (d:themes (first (d:variants homer-fn)))) 1)) |
---|
3072 | (is (eql (first (d:themes (first (d:variants homer-fn)))) display)) |
---|
3073 | (is (string= (d:charvalue (first (d:variants homer-fn))) "Homer")) |
---|
3074 | (is (string= (d:datatype (first (d:variants homer-fn))) *xml-string*)) |
---|
3075 | (is-true homer-occ) |
---|
3076 | (is (string= (d:charvalue homer-occ) "Safety Inspector")) |
---|
3077 | (is (string= (d:datatype homer-occ) *xml-string*)) |
---|
3078 | (is (= (length (d:themes homer-occ)) 1)) |
---|
3079 | (is (eql (first (d:themes homer-occ)) en)))))) |
---|
3080 | |
---|
3081 | |
---|
3082 | (test test-full-mapping-association |
---|
3083 | "Tests the entire importer module." |
---|
3084 | (let ((dir "data_base") |
---|
3085 | (rdf-file unittests-constants:*full_mapping.rdf*) |
---|
3086 | (tm-id "http://full-mapping/") |
---|
3087 | (document-id "http://full_mapping.rdf")) |
---|
3088 | (when elephant:*store-controller* |
---|
3089 | (elephant:close-store)) |
---|
3090 | (fixtures::clean-out-db dir) |
---|
3091 | (rdf-importer:rdf-importer rdf-file dir |
---|
3092 | :tm-id tm-id |
---|
3093 | :document-id document-id) |
---|
3094 | (elephant:open-store (xml-importer:get-store-spec dir)) |
---|
3095 | (is (= (length (elephant:get-instances-by-class 'd:TopicC)) 15)) |
---|
3096 | (is (= (length (elephant:get-instances-by-class 'd:AssociationC)) 1)) |
---|
3097 | (is (= (length (elephant:get-instances-by-class 'd:NameC)) 4)) |
---|
3098 | (is (= (length (elephant:get-instances-by-class 'd:RoleC)) 2)) |
---|
3099 | (is (= (length (elephant:get-instances-by-class 'd:OccurrenceC)) 2)) |
---|
3100 | (is (= (length (elephant:get-instances-by-class 'd:VariantC)) 2)) |
---|
3101 | (setf d:*current-xtm* document-id) |
---|
3102 | (let ((married (get-item-by-id "http://simpsons/married")) |
---|
3103 | (husband (get-item-by-id "http://simpsons/husband")) |
---|
3104 | (wife (get-item-by-id "http://simpsons/wife")) |
---|
3105 | (marge (get-item-by-id "http://simpsons/marge")) |
---|
3106 | (homer (get-item-by-id "http://simpsons/homer")) |
---|
3107 | (assoc (first (elephant:get-instances-by-class 'd:AssociationC))) |
---|
3108 | (role-husband |
---|
3109 | (find-if #'(lambda(x) |
---|
3110 | (let ((iis (d:item-identifiers x))) |
---|
3111 | (when (= (length iis) 1) |
---|
3112 | (string= (d:uri (first iis)) |
---|
3113 | "http://simpsons/role-husband/ii")))) |
---|
3114 | (elephant:get-instances-by-class 'd:RoleC))) |
---|
3115 | (role-wife |
---|
3116 | (find-if #'(lambda(x) |
---|
3117 | (let ((iis (d:item-identifiers x))) |
---|
3118 | (when (= (length iis) 1) |
---|
3119 | (string= (d:uri (first iis)) |
---|
3120 | "http://simpsons/role-wife/ii")))) |
---|
3121 | (elephant:get-instances-by-class 'd:RoleC)))) |
---|
3122 | (is-true married) |
---|
3123 | (is-true (empty-p married)) |
---|
3124 | (is-true husband) |
---|
3125 | (is-true (empty-p husband)) |
---|
3126 | (is-true wife) |
---|
3127 | (is-true (empty-p wife)) |
---|
3128 | (is-true role-husband) |
---|
3129 | (is-true role-wife) |
---|
3130 | (is-true marge) |
---|
3131 | (is-true homer) |
---|
3132 | (is (= (length (intersection (list role-husband role-wife) |
---|
3133 | (d:roles assoc))) |
---|
3134 | 2)) |
---|
3135 | (is (eql (d:instance-of assoc) married)) |
---|
3136 | (is (= (length (d:item-identifiers assoc)) 2)) |
---|
3137 | (is (= (length |
---|
3138 | (intersection |
---|
3139 | (list |
---|
3140 | (elephant:get-instance-by-value |
---|
3141 | 'd:ItemIdentifierC 'd:uri "http://simpsons/married/ii-1") |
---|
3142 | (elephant:get-instance-by-value |
---|
3143 | 'd:ItemIdentifierC 'd:uri "http://simpsons/married/ii-2")) |
---|
3144 | (d:item-identifiers assoc))) |
---|
3145 | 2)) |
---|
3146 | (is (eql (d:instance-of role-husband) husband)) |
---|
3147 | (is (eql (d:instance-of role-wife) wife)) |
---|
3148 | (is (eql (d:player role-husband) homer)) |
---|
3149 | (is (eql (d:player role-wife) marge)) |
---|
3150 | (is (= (length (d:item-identifiers role-husband)) 1)) |
---|
3151 | (is (= (length (d:item-identifiers role-wife)) 1)) |
---|
3152 | (is (string= (d:uri (first (d:item-identifiers role-husband))) |
---|
3153 | "http://simpsons/role-husband/ii")) |
---|
3154 | (is (string= (d:uri (first (d:item-identifiers role-wife))) |
---|
3155 | "http://simpsons/role-wife/ii"))))) |
---|
3156 | |
---|
3157 | |
---|
3158 | (defun run-rdf-importer-tests() |
---|
3159 | "Runs all defined tests." |
---|
3160 | (when elephant:*store-controller* |
---|
3161 | (elephant:close-store)) |
---|
3162 | (it.bese.fiveam:run! 'test-get-literals-of-node) |
---|
3163 | (it.bese.fiveam:run! 'test-parse-node) |
---|
3164 | (it.bese.fiveam:run! 'test-get-literals-of-property) |
---|
3165 | (it.bese.fiveam:run! 'test-parse-property) |
---|
3166 | (it.bese.fiveam:run! 'test-get-types) |
---|
3167 | (it.bese.fiveam:run! 'test-get-literals-of-content) |
---|
3168 | (it.bese.fiveam:run! 'test-get-super-classes-of-node-content) |
---|
3169 | (it.bese.fiveam:run! 'test-get-associations-of-node-content) |
---|
3170 | (it.bese.fiveam:run! 'test-parse-properties-of-node) |
---|
3171 | (it.bese.fiveam:run! 'test-import-node-1) |
---|
3172 | (it.bese.fiveam:run! 'test-import-dom) |
---|
3173 | (it.bese.fiveam:run! 'test-poems-rdf-occurrences) |
---|
3174 | (it.bese.fiveam:run! 'test-poems-rdf-associations) |
---|
3175 | (it.bese.fiveam:run! 'test-poems-rdf-typing) |
---|
3176 | (it.bese.fiveam:run! 'test-poems-rdf-topics) |
---|
3177 | (it.bese.fiveam:run! 'test-empty-collection) |
---|
3178 | (it.bese.fiveam:run! 'test-collection) |
---|
3179 | (it.bese.fiveam:run! 'test-xml-base) |
---|
3180 | (it.bese.fiveam:run! 'test-full-mapping-marge) |
---|
3181 | (it.bese.fiveam:run! 'test-full-mapping-homer) |
---|
3182 | (it.bese.fiveam:run! 'test-full-mapping-association)) |
---|