|
15 | 15 |
|
16 | 16 | import java.io.StringReader; |
17 | 17 | import java.io.StringWriter; |
| 18 | +import java.util.List; |
18 | 19 |
|
| 20 | +import org.eclipse.rdf4j.model.BNode; |
19 | 21 | import org.eclipse.rdf4j.model.IRI; |
20 | 22 | import org.eclipse.rdf4j.model.Model; |
21 | 23 | import org.eclipse.rdf4j.model.impl.DynamicModelFactory; |
| 24 | +import org.eclipse.rdf4j.model.impl.TreeModel; |
22 | 25 | import org.eclipse.rdf4j.model.util.Models; |
| 26 | +import org.eclipse.rdf4j.model.util.RDFCollections; |
| 27 | +import org.eclipse.rdf4j.model.util.Values; |
| 28 | +import org.eclipse.rdf4j.model.vocabulary.RDF; |
23 | 29 | import org.eclipse.rdf4j.model.vocabulary.RDFS; |
24 | 30 | import org.eclipse.rdf4j.rio.RDFFormat; |
25 | 31 | import org.eclipse.rdf4j.rio.Rio; |
@@ -390,6 +396,37 @@ public void testBNodeValuesInList() throws Exception { |
390 | 396 | assertTrue(Models.isomorphic(expected, actual)); |
391 | 397 | } |
392 | 398 |
|
| 399 | + @Test |
| 400 | + public void testRdfCollectionsListNotFullyInlined() throws Exception { |
| 401 | + String namespace = "http://example.com/ns#"; |
| 402 | + IRI cities = Values.iri(namespace, "Cities"); |
| 403 | + IRI listPredicate = Values.iri(namespace, "list"); |
| 404 | + BNode listHead = vf.createBNode("n1"); |
| 405 | + |
| 406 | + Model model = new TreeModel(); |
| 407 | + model.setNamespace("ex", namespace); |
| 408 | + model.setNamespace("rdf", RDF.NAMESPACE); |
| 409 | + |
| 410 | + RDFCollections.asRDF(List.of( |
| 411 | + Values.iri(namespace, "NewYork"), |
| 412 | + Values.iri(namespace, "Rio"), |
| 413 | + Values.iri(namespace, "Tokyo")), listHead, model); |
| 414 | + model.add(cities, listPredicate, listHead); |
| 415 | + |
| 416 | + WriterConfig config = new WriterConfig(); |
| 417 | + config.set(BasicWriterSettings.INLINE_BLANK_NODES, true); |
| 418 | + config.set(BasicWriterSettings.PRETTY_PRINT, true); |
| 419 | + |
| 420 | + StringWriter stringWriter = new StringWriter(); |
| 421 | + Rio.write(model, stringWriter, RDFFormat.TURTLE, config); |
| 422 | + |
| 423 | + String expected = String.join("\n", "@prefix ex: <http://example.com/ns#> .", |
| 424 | + "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .", |
| 425 | + "", "ex:Cities ex:list (ex:NewYork ex:Rio ex:Tokyo) .", ""); |
| 426 | + |
| 427 | + assertThat(stringWriter.toString()).isEqualTo(expected); |
| 428 | + } |
| 429 | + |
393 | 430 | @Test |
394 | 431 | public void testBNodeValuesInList2() throws Exception { |
395 | 432 | String data = "" + |
|
0 commit comments