[isidorus-cvs] r105 - trunk/src/unit_tests
Lukas Giessmann
lgiessmann at common-lisp.net
Tue Aug 4 07:48:17 UTC 2009
Author: lgiessmann
Date: Tue Aug 4 03:48:16 2009
New Revision: 105
Log:
added unit tests for rdf-reification; currently reification is not mapped directly into topic maps, the rdf:id attribute is mapped into special nodes with special arcs, described in rdf/xml which are mapped into topic maps
Modified:
trunk/src/unit_tests/rdf_importer_test.lisp
Modified: trunk/src/unit_tests/rdf_importer_test.lisp
==============================================================================
--- trunk/src/unit_tests/rdf_importer_test.lisp (original)
+++ trunk/src/unit_tests/rdf_importer_test.lisp Tue Aug 4 03:48:16 2009
@@ -31,7 +31,8 @@
*rdf2tm-subject*
*rdf-subject*
*rdf-object*
- *rdf-predicate*)
+ *rdf-predicate*
+ *rdf-statement*)
(:import-from :xml-tools
xpath-child-elems-by-qname
xpath-single-child-elem-by-qname
@@ -1240,8 +1241,196 @@
(rdf-importer::import-node (elt (dom:child-nodes rdf-node) iter)
tm-id revision-1
:document-id document-id))
-
- ))))
+ (let ((reification-1 (d:get-item-by-id "http://test-tm#reification-1"
+ :xtm-id document-id))
+ (reification-2 (d:get-item-by-id "http://test-tm#reification-2"
+ :xtm-id document-id))
+ (first-node (d:get-item-by-id "http://test-tm/first-node"
+ :xtm-id document-id))
+ (second-node (d:get-item-by-id "http://test-tm/second-node"
+ :xtm-id document-id))
+ (third-node (d:get-item-by-id "http://test-tm/third-node"
+ :xtm-id document-id))
+ (fourth-node (d:get-item-by-id "fourth-node"
+ :xtm-id document-id))
+ (fifth-node (d:get-item-by-id "http://test-tm/fifth-node"
+ :xtm-id document-id))
+ (arc1 (d:get-item-by-id "http://test/arcs/arc1"
+ :xtm-id document-id))
+ (arc2 (d:get-item-by-id "http://test/arcs/arc2"
+ :xtm-id document-id))
+ (arc3 (d:get-item-by-id "http://test/arcs/arc3"
+ :xtm-id document-id))
+ (arc4 (d:get-item-by-id "http://test/arcs/arc4"
+ :xtm-id document-id))
+ (statement (d:get-item-by-psi *rdf-statement*))
+ (object (d:get-item-by-psi *rdf-object*))
+ (subject (d:get-item-by-psi *rdf-subject*))
+ (predicate (d:get-item-by-psi *rdf-predicate*))
+ (type (d:get-item-by-psi *type-psi*))
+ (instance (d:get-item-by-psi *instance-psi*))
+ (type-instance (d:get-item-by-psi *type-instance-psi*))
+ (isi-subject (d:get-item-by-psi *rdf2tm-subject*))
+ (isi-object (d:get-item-by-psi *rdf2tm-object*)))
+ (is (= (length (d:psis reification-1)) 1))
+ (is (string= (d:uri (first (d:psis reification-1)))
+ "http://test-tm#reification-1"))
+ (is (= (length (d:psis reification-2)) 1))
+ (is (string= (d:uri (first (d:psis reification-2)))
+ "http://test-tm#reification-2"))
+ (is (= (length (d:psis first-node)) 1))
+ (is (string= (d:uri (first (d:psis first-node)))
+ "http://test-tm/first-node"))
+ (is (= (length (d:psis second-node)) 1))
+ (is (string= (d:uri (first (d:psis second-node)))
+ "http://test-tm/second-node"))
+ (is (= (length (d:psis third-node)) 1))
+ (is (string= (d:uri (first (d:psis third-node)))
+ "http://test-tm/third-node"))
+ (is (= (length (d:psis fourth-node)) 0))
+ (is (= (length (d:psis fifth-node)) 1))
+ (is (string= (d:uri (first (d:psis fifth-node)))
+ "http://test-tm/fifth-node"))
+ (is (= (length (d:psis arc1)) 1))
+ (is (string= (d:uri (first (d:psis arc1)))
+ "http://test/arcs/arc1"))
+ (is (= (length (d:psis arc2))))
+ (is (string= (d:uri (first (d:psis arc2)))
+ "http://test/arcs/arc2"))
+ (is (= (length (d:psis arc3))))
+ (is (string= (d:uri (first (d:psis arc3)))
+ "http://test/arcs/arc3"))
+ (is (= (length (d:psis arc4))))
+ (is (string= (d:uri (first (d:psis arc4)))
+ "http://test/arcs/arc4"))
+ (is-true statement)
+ (is-true object)
+ (is-true subject)
+ (is-true predicate)
+ (is-true type)
+ (is-true instance)
+ (is-true type-instance)
+ (is (= (length (d:player-in-roles first-node)) 2))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-subject)
+ (eql (d:instance-of (d:parent x)) arc1)))
+ (d:player-in-roles first-node)))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-object)
+ (eql (d:instance-of (d:parent x))
+ subject)))
+ (d:player-in-roles first-node)))
+ (is (= (length (d:player-in-roles second-node)) 2))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-object)
+ (eql (d:instance-of (d:parent x)) arc1)))
+ (d:player-in-roles second-node)))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-object)
+ (eql (d:instance-of (d:parent x))
+ object)))
+ (d:player-in-roles second-node)))
+ (is (= (length (d:player-in-roles statement)) 2))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) type)
+ (eql (d:instance-of (d:parent x))
+ type-instance)))
+ (d:player-in-roles statement)))
+ (is (= (length (d:player-in-roles arc1)) 1))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-object)
+ (eql (d:instance-of (d:parent x))
+ predicate)))
+ (d:player-in-roles arc1)))
+ (is (= (length (d:player-in-roles third-node)) 1))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-object)
+ (eql (d:instance-of (d:parent x))
+ arc2)))
+ (d:player-in-roles third-node)))
+ (is (= (length (d:player-in-roles reification-1)) 5))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-subject)
+ (eql (d:instance-of (d:parent x))
+ subject)))
+ (d:player-in-roles reification-1)))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-subject)
+ (eql (d:instance-of (d:parent x))
+ object)))
+ (d:player-in-roles reification-1)))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) instance)
+ (eql (d:instance-of (d:parent x))
+ type-instance)))
+ (d:player-in-roles reification-1)))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-subject)
+ (eql (d:instance-of (d:parent x))
+ object)))
+ (d:player-in-roles reification-1)))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-subject)
+ (eql (d:instance-of (d:parent x))
+ predicate)))
+ (d:player-in-roles reification-1)))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-subject)
+ (eql (d:instance-of (d:parent x))
+ arc2)))
+ (d:player-in-roles reification-1)))
+ (is (= (length (d:occurrences fourth-node)) 1))
+ (is (string= (d:charvalue (first (d:occurrences fourth-node)))
+ "occurrence data"))
+ (is (string= (d:datatype (first (d:occurrences fourth-node)))
+ "http://test-tm/dt"))
+ (is (eql (d:instance-of (first (d:occurrences fourth-node)))
+ arc3))
+ (is (= (length (d:player-in-roles fourth-node)) 1))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-object)
+ (eql (d:instance-of (d:parent x))
+ subject)))
+ (d:player-in-roles fourth-node)))
+ (is (= (length (d:player-in-roles arc3)) 1))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-object)
+ (eql (d:instance-of (d:parent x))
+ predicate)))
+ (d:player-in-roles arc3)))
+ (is (= (length (d:player-in-roles fifth-node)) 1))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-object)
+ (eql (d:instance-of (d:parent x))
+ arc4)))
+ (d:player-in-roles fifth-node)))
+ (is (= (length (d:occurrences reification-2)) 1))
+ (is (string= (d:charvalue (first (d:occurrences reification-2)))
+ "occurrence data"))
+ (is (string= (d:datatype (first (d:occurrences reification-2)))
+ "http://test-tm/dt"))
+ (is (= (length (d:player-in-roles reification-2)) 4))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-subject)
+ (eql (d:instance-of (d:parent x))
+ subject)))
+ (d:player-in-roles reification-2)))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-subject)
+ (eql (d:instance-of (d:parent x))
+ predicate)))
+ (d:player-in-roles reification-2)))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) isi-subject)
+ (eql (d:instance-of (d:parent x))
+ arc4)))
+ (d:player-in-roles reification-2)))
+ (is-true (find-if #'(lambda(x)
+ (and (eql (d:instance-of x) instance)
+ (eql (d:instance-of (d:parent x))
+ type-instance)))
+ (d:player-in-roles reification-2)))
+ (elephant:close-store))))))
More information about the Isidorus-cvs
mailing list