[isidorus-cvs] r412 - in trunk/src: TM-SPARQL unit_tests
Lukas Giessmann
lgiessmann at common-lisp.net
Mon Apr 4 08:50:25 UTC 2011
Author: lgiessmann
Date: Mon Apr 4 04:50:25 2011
New Revision: 412
Log:
TM-SPARQL: fixed a bug in the processing of final results when creating result-intersections and finished a unit-tests for such a scenario
Modified:
trunk/src/TM-SPARQL/sparql.lisp
trunk/src/unit_tests/sparql_test.lisp
Modified: trunk/src/TM-SPARQL/sparql.lisp
==============================================================================
--- trunk/src/TM-SPARQL/sparql.lisp (original)
+++ trunk/src/TM-SPARQL/sparql.lisp Mon Apr 4 04:50:25 2011
@@ -1080,7 +1080,7 @@
:result (subject-result triple)))
(when (variable-p (predicate triple))
(list :variable (value (predicate triple))
- :result (predicate-result triple)))
+ :result (predicate-result triple)))
(when (variable-p (object triple))
(list :variable (value (object triple))
:result (object-result triple)))))))))
@@ -1116,7 +1116,7 @@
(let* ((all-values (results-for-variable variable-name result-lists))
(list-1 (when (>= (length all-values) 1)
(first all-values)))
- (list-2 (if (> (length all-values) 2)
+ (list-2 (if (>= (length all-values) 2)
(second all-values)
list-1))
(more-lists (rest (rest all-values))))
Modified: trunk/src/unit_tests/sparql_test.lisp
==============================================================================
--- trunk/src/unit_tests/sparql_test.lisp (original)
+++ trunk/src/unit_tests/sparql_test.lisp Mon Apr 4 04:50:25 2011
@@ -2079,6 +2079,7 @@
(map 'list #'(lambda(item)
(cond ((string= (getf item :variable) "pred1")
;one name without a type so it is not listed
+ ;as regular triple but as tms:topicProperty
(is (= (length (getf item :result)) 17)))
((string= (getf item :variable) "pred2")
(is (= (length (getf item :result)) 3))
@@ -2297,17 +2298,49 @@
+(test test-all-13
+ "Tests the entire module with the file sparql_test.xtm"
+ (with-fixture with-tm-filled-db ("data_base" *sparql_test.xtm*)
+ (tm-sparql:init-tm-sparql)
+ (let* ((q-1 (concat
+ "PREFIX tms:<" *tms* ">
+ SELECT * WHERE {
+ ?assoc tms:reifier <http://some.where/ii/association-reifier>.
+ ?assoc tms:role ?roles.
+ ?roles tms:reifier <http://some.where/ii/role-reifier>"
+ "}"))
+ (r-1 (tm-sparql:result (make-instance 'TM-SPARQL:SPARQL-Query :query q-1))))
+ (is-true (= (length r-1) 2))
+ (map 'list #'(lambda(item)
+ (cond
+ ((string= (getf item :variable) "assoc")
+ (is (= (length (getf item :result)) 1))
+ (is (string= (first (getf item :result))
+ "<http://some.where/ii/association>")))
+ ((string= (getf item :variable) "roles")
+ (is (= (length (getf item :result)) 1))
+ (is
+ (string=
+ (first (getf item :result))
+ (concat
+ "_:r"
+ (write-to-string
+ (elephant::oid
+ (loop for role in
+ (roles
+ (get-item-by-item-identifier
+ "http://some.where/ii/association"
+ :revision 0) :revision 0)
+ when (string=
+ (uri (first (psis (player role :revision 0)
+ :revision 0)))
+ "http://some.where/tmsparql/author/goethe")
+ return role)))))))))
+ r-1))))
-;TODO: test complex filters,
-; test complex relations between variables
-;TODO: PREFIX tms:<http://www.networkedplanet.com/tmsparql/>
-; SELECT * WHERE {
-; ?assoc tms:reifier <http://some.where/ii/association-reifier>.
-; ?assoc tms:role ?roles}
-; => ?assoc = http://some.where/ii/association
-; => ?roles = (http://some.where/ii/role-2, _:r????)
+;TODO: test complex filters
(defun run-sparql-tests ()
(it.bese.fiveam:run! 'sparql-test:sparql-tests))
More information about the Isidorus-cvs
mailing list