Skip to content

Commit 449d1aa

Browse files
committed
Add regression test for issue #182
Requirement is to not compact arrays during framing if this option is set on the JsonLdOptions instance Signed-off-by: Peter Ansell <p_ansell@yahoo.com>
1 parent b229bfa commit 449d1aa

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

core/src/test/java/com/github/jsonldjava/core/JsonLdFramingTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,22 @@ public void testFrame0001() throws IOException, JsonLdError {
2323
assertEquals(2, frame2.size());
2424
}
2525

26+
@Test
27+
public void testFrame0002() throws IOException, JsonLdError {
28+
final Object frame = JsonUtils
29+
.fromInputStream(getClass().getResourceAsStream("/custom/frame-0002-frame.jsonld"));
30+
final Object in = JsonUtils
31+
.fromInputStream(getClass().getResourceAsStream("/custom/frame-0002-in.jsonld"));
32+
33+
JsonLdOptions opts = new JsonLdOptions();
34+
opts.setCompactArrays(false);
35+
final Map<String, Object> frame2 = JsonLdProcessor.frame(in, frame, opts);
36+
37+
final Object out = JsonUtils
38+
.fromInputStream(getClass().getResourceAsStream("/custom/frame-0002-out.jsonld"));
39+
System.out.println(JsonUtils.toPrettyString(out));
40+
System.out.println(JsonUtils.toPrettyString(frame2));
41+
assertEquals(out, frame2);
42+
}
43+
2644
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://xmlns.com/foaf/0.1/"
4+
},
5+
"@type": "Person"
6+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://xmlns.com/foaf/0.1/",
4+
"member": {"@type": "@id"}
5+
},
6+
"@graph": [{
7+
"@type": "Person",
8+
"member": "_:b1"
9+
}, {
10+
"@id": "_:b1",
11+
"@type": "Group"
12+
}]
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"@context" : {
3+
"@vocab" : "http://xmlns.com/foaf/0.1/"
4+
},
5+
"@graph" : [ {
6+
"@id" : "_:b0",
7+
"@type" : "Person",
8+
"member" : [{
9+
"@id" : "_:b1",
10+
"@type" : "Group"
11+
}]
12+
} ]
13+
}

0 commit comments

Comments
 (0)