rvesse commented on code in PR #2085:
URL: https://github.com/apache/jena/pull/2085#discussion_r1404130934
##########
jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/Converters.java:
##########
@@ -317,4 +340,363 @@ public static Collection<Node> makeValueNodes(Iterator<?>
iter, PrefixMapping pr
return values;
}
+ /**
+ * Gathers the triples and adds them ot the collector.
Review Comment:
```suggestion
* Gathers the triples and adds them to the collector.
```
Typo
##########
jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/AbstractQueryBuilderTest.java:
##########
@@ -131,9 +131,47 @@ public void testMakeValueNodes() {
assertTrue(result.contains(NodeFactory.createURI("one")));
Node n = NodeFactory.createLiteral("5", XSDDatatype.XSDint);
- LiteralLabel ll =
LiteralLabelFactory.createTypedLiteral(Integer.valueOf(5));
assertTrue(result.contains(n));
}
+
+ private void assertTripleMatch(Triple expected, Triple actual) {
+ if (!expected.matches(actual)) {
+ fail("expected: "+expected+" actual: "+actual);
+ }
+ }
+
+ private void assertTripleMatch(Triple expected, TriplePath actual) {
+ assertTripleMatch(expected, actual.asTriple());
+ }
+
+ @Test
+ public void testMakeTriplePaths() {
+ List<Object> list = new ArrayList<Object>();
+ list.add(RDF.type);
+ builder.addPrefix("demo", "http://example.com/");
+ list.add("demo:type");
+ list.add("<one>");
+ list.add(Integer.valueOf(5));
+
+ Triple[] expected = {
+ Triple.create(Node.ANY, RDF.first.asNode(), RDF.type.asNode()),
+ Triple.create(Node.ANY, RDF.rest.asNode(), Node.ANY),
+ Triple.create(Node.ANY, RDF.first.asNode(),
NodeFactory.createURI("http://example.com/type")),
+ Triple.create(Node.ANY, RDF.rest.asNode(), Node.ANY),
+ Triple.create(Node.ANY, RDF.first.asNode(),
NodeFactory.createURI("one")),
+ Triple.create(Node.ANY, RDF.rest.asNode(), Node.ANY),
+ Triple.create(Node.ANY, RDF.first.asNode(),
NodeFactory.createLiteral("5", XSDDatatype.XSDint)),
+ Triple.create(Node.ANY, RDF.rest.asNode(), RDF.nil.asNode()),
+ Triple.create(Var.alloc("s"), Var.alloc("p"), Node.ANY),
+ };
+
Review Comment:
Could be worth some more robust testing here to ensure that each node for
the RDF list is actually unique node as the use of `Node.ANY` merely checks the
expected triple is present in each position, not that unique nodes have been
created.
At the same time there's a lot of test coverage elsewhere in this PR so that
may be overkill
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]