Browse Source

Added extra test case

Added extra test case to make sure datatypes were working with
functions, which they did.
Christophe Debruyne 7 years ago
parent
commit
766ac5186e

+ 0 - 2
test/resources/13.output/default.ttl

@@ -1,4 +1,2 @@
 <http://data.example.com/employee/7369>
         a       <http://example.com/ns#Employee> .
-<http://data.example.com/employee/7369>
-        a       <http://example.com/ns#Employee> .

+ 0 - 2
test/resources/13.output/http_foo_bar_bar_.ttl

@@ -1,4 +1,2 @@
 <http://data.example.com/employee/7369>
         <http://example.com/ns#name>  "SMITH" .
-<http://data.example.com/employee/7369>
-        <http://example.com/ns#name>  "SMITH" .

+ 40 - 0
test/resources/F03.mapping.ttl

@@ -0,0 +1,40 @@
+@prefix rr: <http://www.w3.org/ns/r2rml#> .
+@prefix rrf: <http://kdeg.scss.tcd.ie/ns/rrf#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+@prefix ex: <http://example.com/ns#> .
+
+<#TriplesMap1>
+    rr:logicalTable [ rr:tableName "EMP" ];
+    rr:subjectMap [
+        rr:template "http://data.example.com/employee/{EMPNO}";
+        rr:class ex:Employee;
+    ];
+    rr:predicateObjectMap [
+        rr:predicate ex:name;
+        rr:objectMap [ rr:column "ENAME" ];
+    ];
+    rr:predicateObjectMap [
+        rr:predicate ex:test;
+        rr:objectMap [
+	 		rr:datatype xsd:integer ;
+	        rrf:functionCall [
+	 			rrf:function <#foo> ;
+	 			rrf:parameterBindings (
+	 				[ rr:column "EMPNO" ]
+	 			) ;
+	 		] ; 
+	 	]
+    ]    
+    .
+    
+<#foo>
+	rrf:functionName "foo" ;
+	rrf:functionBody """
+	function foo(var1) {
+		return var1 ;
+	}
+	""" ;
+.
+	
+<#a> rr:objectMap <#b> .
+<#b> rr:column "ENAME" .

+ 6 - 0
test/resources/F03.output.ttl

@@ -0,0 +1,6 @@
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+@prefix ex: <http://example.com/ns#> .
+<http://data.example.com/employee/7369> rdf:type ex:Employee.
+<http://data.example.com/employee/7369> ex:name "SMITH".
+<http://data.example.com/employee/7369> ex:test "7369"^^xsd:integer.

+ 16 - 0
test/test/TestR2RMLF.java

@@ -14,6 +14,7 @@ import org.junit.BeforeClass;
 import junit.framework.TestCase;
 import r2rml.engine.Configuration;
 import r2rml.engine.R2RMLProcessor;
+import r2rml.function.JSEnv;
 
 /**
  * Unit test for testing the functionality of this implementation using an
@@ -102,6 +103,21 @@ public class TestR2RMLF extends TestCase {
 		target.read("./test/resources/F01.output.ttl");
 		assertEquals(true, model.difference(target).isEmpty());
 		assertEquals(true, target.difference(model).isEmpty());	
+		
+		JSEnv.reset();
+	}
+	
+	public void testExampleF03() {
+		Configuration configuration = new Configuration();
+		configuration.setMappingFile("./test/resources/F03.mapping.ttl");
+		configuration.setConnectionURL(connectionURL);
+		R2RMLProcessor engine = new R2RMLProcessor(configuration);
+		engine.execute();
+		Model model = engine.getDataset().getDefaultModel();
+		Model target = ModelFactory.createDefaultModel();
+		target.read("./test/resources/F03.output.ttl");
+		assertEquals(true, model.difference(target).isEmpty());
+		assertEquals(true, target.difference(model).isEmpty());	
 	}
 
 }