Github user afs commented on a diff in the pull request:
https://github.com/apache/jena/pull/211#discussion_r98633112
--- Diff:
jena-arq/src/test/java/org/apache/jena/riot/writer/TestJsonLDWriter.java ---
@@ -460,15 +468,77 @@ private Model simpleModel(String ns) {
// compactArrays is false -> an array for all props, even when
there's only one value
assertTrue(jsonld.indexOf("\"jobTitle\" : [ \"Professor\" ]") >
-1);
}
+
+ /**
+ * Test blanknodes.
+ *
+ * Several graphs, blanknodes with an id given by the user, or
generated by jena
+ */
+ @Test public final void blankNodesTest() throws IOException {
+ // create a dataset with one named graph, and some blanknodes
+
+ Dataset ds = null;
+ Model m = ModelFactory.createDefaultModel();
+ Model m2 = ModelFactory.createDefaultModel();
+ ds = DatasetFactory.create(m);
+ String namedModelName = "http://ex.com/namedgraph";
+ ds.addNamedModel(namedModelName, m2);
+
+ Resource s = m.createResource();
+ m.add(s, RDFS.label, "blank node 1 in default graph");
+
+ s = m2.createResource();
+ m2.add(s, RDFS.label, "blank node 2 in named graph");
+
+ // blanknodes with given id, shared by the 2 graphs
+
+ s = m.createResource(AnonId.create("_:foo"));
+ m.add(s, RDFS.label, "_:foo in default graph");
+
+ s = m2.createResource(AnonId.create("_:foo"));
+ m2.add(s, RDFS.label, "_:foo in named graph");
+
+ s = m.createResource(AnonId.create("xxx"));
+ m.add(s, RDFS.label, "xxx in default");
+
+ s = m2.createResource(AnonId.create("xxx"));
+ m2.add(s, RDFS.label, "xxx in named");
+
+ // this id will probably be changed in output
+ s = m.createResource(AnonId.create("_:b0"));
+ m.add(s, RDFS.label, "? in default graph");
+
+ s = m2.createResource(AnonId.create("_:b0"));
+ m2.add(s, RDFS.label, "? in named graph");
+
+ // write to jsonld
+
+ String jsonld = dataset2jsonld(ds.asDatasetGraph(),
RDFFormat.JSONLD, null);
+ System.out.println(jsonld);
+
+ // check we have kept the blanknodes identifiers that were valid
jsonld bn identifiers
+ assertTrue(jsonld.indexOf("\"_:foo\"") > -1);
--- End diff --
` if ( jsonld.contains("\"_:foo\"") )`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---