Skip to content

Commit 572c192

Browse files
authored
Merge pull request #212 from dr0i/150-addTestForEmbeddingSameDataMultipleTimes
150 add test for embedding same data multiple times
2 parents 494dd53 + e5af222 commit 572c192

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed

core/src/main/java/com/github/jsonldjava/core/JsonLdOptions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,16 @@ public void setEmbed(String embed) throws JsonLdError {
101101
switch (embed) {
102102
case "@always":
103103
this.embed = Embed.ALWAYS;
104+
break;
104105
case "@never":
105106
this.embed = Embed.NEVER;
107+
break;
106108
case "@last":
107109
this.embed = Embed.LAST;
110+
break;
108111
case "@link":
109112
this.embed = Embed.LINK;
113+
break;
110114
default:
111115
throw new JsonLdError(JsonLdError.Error.INVALID_EMBED_VALUE);
112116
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,21 @@ public void testFrame0007() throws IOException, JsonLdError {
123123
.fromInputStream(getClass().getResourceAsStream("/custom/frame-0007-out.jsonld"));
124124
assertEquals(out, frame2);
125125
}
126+
127+
@Test
128+
public void testFrame0008() throws IOException, JsonLdError {
129+
final Object frame = JsonUtils
130+
.fromInputStream(getClass().getResourceAsStream("/custom/frame-0008-frame.jsonld"));
131+
final Object in = JsonUtils
132+
.fromInputStream(getClass().getResourceAsStream("/custom/frame-0008-in.jsonld"));
133+
134+
JsonLdOptions opts = new JsonLdOptions();
135+
opts.setEmbed("@always");
136+
final Map<String, Object> frame2 = JsonLdProcessor.frame(in, frame, opts);
137+
138+
final Object out = JsonUtils
139+
.fromInputStream(getClass().getResourceAsStream("/custom/frame-0008-out.jsonld"));
140+
assertEquals(out, frame2);
141+
}
126142
}
143+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": {
3+
"dct": "http://purl.org/dc/terms/",
4+
"ex": "http://example.org/vocab#"
5+
},
6+
"@type": "ex:Biography"
7+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"@context": {
3+
"dct": "http://purl.org/dc/terms/",
4+
"ex": "http://example.org/vocab#"
5+
},
6+
"@graph": [
7+
{
8+
"@id": "http://lobid.org/resources/HT019277879",
9+
"@type": "ex:Biography",
10+
"dct:creator": {
11+
"@id" : "https://www.wikidata.org/entity/Q115211",
12+
"ex:name": "Harry Rowohlt"
13+
},
14+
"dct:subject": {
15+
"@id" : "https://www.wikidata.org/entity/Q115211",
16+
"ex:name": "Harry Rowohlt"
17+
}
18+
}
19+
]
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"@context": {
3+
"dct": "http://purl.org/dc/terms/",
4+
"ex": "http://example.org/vocab#"
5+
},
6+
"@graph": [
7+
{
8+
"@id": "http://lobid.org/resources/HT019277879",
9+
"@type": "ex:Biography",
10+
"dct:creator": {
11+
"@id" : "https://www.wikidata.org/entity/Q115211",
12+
"ex:name": "Harry Rowohlt"
13+
},
14+
"dct:subject": {
15+
"@id" : "https://www.wikidata.org/entity/Q115211",
16+
"ex:name": "Harry Rowohlt"
17+
}
18+
}
19+
]
20+
}

0 commit comments

Comments
 (0)