From 332fe5683ce849e605549e4659d6a80ab975703d Mon Sep 17 00:00:00 2001 From: Pavel Vojtechovsky Date: Tue, 2 Aug 2022 09:38:07 +0200 Subject: [PATCH 1/3] test duplicate resource printing in json-ld embed=LAST --- .../resources/custom/frame-0012-frame.jsonld | 6 +++++ .../resources/custom/frame-0012-in.jsonld | 22 +++++++++++++++++++ .../resources/custom/frame-0012-out.jsonld | 21 ++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 core/src/test/resources/custom/frame-0012-frame.jsonld create mode 100644 core/src/test/resources/custom/frame-0012-in.jsonld create mode 100644 core/src/test/resources/custom/frame-0012-out.jsonld diff --git a/core/src/test/resources/custom/frame-0012-frame.jsonld b/core/src/test/resources/custom/frame-0012-frame.jsonld new file mode 100644 index 00000000..71bf85a4 --- /dev/null +++ b/core/src/test/resources/custom/frame-0012-frame.jsonld @@ -0,0 +1,6 @@ +{ + "@context" : { + "@vocab" : "http://www.example.net/" + }, + "@type" : "Document" +} diff --git a/core/src/test/resources/custom/frame-0012-in.jsonld b/core/src/test/resources/custom/frame-0012-in.jsonld new file mode 100644 index 00000000..97870399 --- /dev/null +++ b/core/src/test/resources/custom/frame-0012-in.jsonld @@ -0,0 +1,22 @@ +{ + "@context" : { + "@vocab" : "http://www.example.net/" + }, + "@id": "#doc", + "@type": "Document", + "content": { + "@list": [ + { + "@id": "#question", + "@type": "Question", + "label" : "Why am I here twice?" + }, + { + "@id": "#block", + "predicate": { + "@id": "#question" + } + } + ] + } +} \ No newline at end of file diff --git a/core/src/test/resources/custom/frame-0012-out.jsonld b/core/src/test/resources/custom/frame-0012-out.jsonld new file mode 100644 index 00000000..cf1d5367 --- /dev/null +++ b/core/src/test/resources/custom/frame-0012-out.jsonld @@ -0,0 +1,21 @@ +{ + "@context" : { + "@vocab" : "http://www.example.net/" + }, + "@graph" : [ { + "@id" : "#doc", + "@type" : "Document", + "content" : { + "@list" : [ { + "@id" : "#question" + }, { + "@id" : "#block", + "predicate" : { + "@id" : "#question", + "@type" : "Question", + "label" : "Why am I here twice?" + } + } ] + } + } ] +} From c2f0777a870daafaa1c3ab0d9bd0bb848f05e92e Mon Sep 17 00:00:00 2001 From: Pavel Vojtechovsky Date: Tue, 2 Aug 2022 09:39:18 +0200 Subject: [PATCH 2/3] test duplicate resource printing in json-ld embed=LAST --- .../jsonldjava/core/JsonLdFramingTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/src/test/java/com/github/jsonldjava/core/JsonLdFramingTest.java b/core/src/test/java/com/github/jsonldjava/core/JsonLdFramingTest.java index bacec894..6d44b44a 100644 --- a/core/src/test/java/com/github/jsonldjava/core/JsonLdFramingTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/JsonLdFramingTest.java @@ -195,4 +195,21 @@ public void testFrame0011() throws IOException, JsonLdError { assertEquals(out, frame2); } + @Test + public void testFrame0012() throws IOException, JsonLdError { + final Object frame = JsonUtils + .fromInputStream(getClass().getResourceAsStream("/custom/frame-0012-frame.jsonld")); + final Object in = JsonUtils + .fromInputStream(getClass().getResourceAsStream("/custom/frame-0012-in.jsonld")); + + final JsonLdOptions opts = new JsonLdOptions(); + opts.setEmbed(Embed.LAST); + final Map frame2 = JsonLdProcessor.frame(in, frame, opts); + + //TODO remove this debugging line after test is fixed + System.out.println(JsonUtils.toPrettyString(frame2)); + final Object out = JsonUtils + .fromInputStream(getClass().getResourceAsStream("/custom/frame-0012-out.jsonld")); + assertEquals(out, frame2); + } } From 121bc55c9d52c9060008ba6d176016a3200340d4 Mon Sep 17 00:00:00 2001 From: Pavel Vojtechovsky Date: Tue, 2 Aug 2022 09:40:33 +0200 Subject: [PATCH 3/3] fix --- .../test/java/com/github/jsonldjava/core/JsonLdFramingTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/test/java/com/github/jsonldjava/core/JsonLdFramingTest.java b/core/src/test/java/com/github/jsonldjava/core/JsonLdFramingTest.java index 6d44b44a..95dba1e1 100644 --- a/core/src/test/java/com/github/jsonldjava/core/JsonLdFramingTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/JsonLdFramingTest.java @@ -8,6 +8,7 @@ import org.junit.Test; +import com.github.jsonldjava.core.JsonLdConsts.Embed; import com.github.jsonldjava.utils.JsonUtils; public class JsonLdFramingTest {