Skip to content

Commit

Permalink
Add test slicing a json object. See #202
Browse files Browse the repository at this point in the history
  • Loading branch information
enridaga committed Mar 23, 2022
1 parent c9c5ea2 commit 71b2c20
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ protected void properties(Properties properties) {
properties.setProperty("slice", "true");
properties.setProperty("json.path", "$.*");
}

// Object
if(name.getMethodName().equals("testObject$1")){
properties.setProperty("blank-nodes", "false");
Expand All @@ -90,6 +91,17 @@ protected void properties(Properties properties) {
properties.setProperty("blank-nodes", "false");
properties.setProperty("slice", "true"); // --> Throws an exception!!!
throwsException = true;
}else if(name.getMethodName().equals("testObject$3")){
properties.setProperty("blank-nodes", "false");
properties.setProperty("slice", "true");
properties.setProperty("json.path", "$");
}

// SliceObject
if(name.getMethodName().equals("testSliceObject$3")){
properties.setProperty("blank-nodes", "false");
properties.setProperty("slice", "true");
properties.setProperty("json.path", "$.content");
}
}

Expand Down Expand Up @@ -185,4 +197,17 @@ protected void properties(Properties properties) {
Assert.assertTrue(resultException.getMessage().equals("Not a JSON array"));
}

// @Test
// public void testObject$3(){
// L.info("Test simple Json object (slicing + JsonPath: $.*)");
// RDFDataMgr.write(System.err, result, Lang.N3);
// assertResultIsIsomorphicWithExpected();
// }

@Test
public void testSliceObject$3(){
L.info("Test simple Json object (slicing + JsonPath)");
RDFDataMgr.write(System.err, result, Lang.N3);
// Assert.assertTrue(resultException.getMessage().equals("Not a JSON array"));
}
}
1 change: 1 addition & 0 deletions sparql-anything-json/src/test/resources/SliceObject.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"content" : {"letter" : "A", "number": 1, "boolean": true} }
8 changes: 8 additions & 0 deletions sparql-anything-json/src/test/resources/SliceObject.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix fx: <http://sparql.xyz/facade-x/ns/>.
@prefix xyz: <http://sparql.xyz/facade-x/data/>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.

<http://www.example.org/document> a fx:root ; rdf:_1 <http://www.example.org/document/_1> .
<http://www.example.org/document/_1> xyz:letter "A" ; xyz:number "1"^^xsd:int ; ; xyz:boolean true .

0 comments on commit 71b2c20

Please sign in to comment.