Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@ public void setEmbed(String embed) throws JsonLdError {
switch (embed) {
case "@always":
this.embed = Embed.ALWAYS;
break;
case "@never":
this.embed = Embed.NEVER;
break;
case "@last":
this.embed = Embed.LAST;
break;
case "@link":
this.embed = Embed.LINK;
break;
default:
throw new JsonLdError(JsonLdError.Error.INVALID_EMBED_VALUE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,21 @@ public void testFrame0007() throws IOException, JsonLdError {
.fromInputStream(getClass().getResourceAsStream("/custom/frame-0007-out.jsonld"));
assertEquals(out, frame2);
}

@Test
public void testFrame0008() throws IOException, JsonLdError {
final Object frame = JsonUtils
.fromInputStream(getClass().getResourceAsStream("/custom/frame-0008-frame.jsonld"));
final Object in = JsonUtils
.fromInputStream(getClass().getResourceAsStream("/custom/frame-0008-in.jsonld"));

JsonLdOptions opts = new JsonLdOptions();
opts.setEmbed("@always");
final Map<String, Object> frame2 = JsonLdProcessor.frame(in, frame, opts);

final Object out = JsonUtils
.fromInputStream(getClass().getResourceAsStream("/custom/frame-0008-out.jsonld"));
assertEquals(out, frame2);
}
}

7 changes: 7 additions & 0 deletions core/src/test/resources/custom/frame-0008-frame.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"@context": {
"dct": "http://purl.org/dc/terms/",
"ex": "http://example.org/vocab#"
},
"@type": "ex:Biography"
}
20 changes: 20 additions & 0 deletions core/src/test/resources/custom/frame-0008-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"@context": {
"dct": "http://purl.org/dc/terms/",
"ex": "http://example.org/vocab#"
},
"@graph": [
{
"@id": "http://lobid.org/resources/HT019277879",
"@type": "ex:Biography",
"dct:creator": {
"@id" : "https://www.wikidata.org/entity/Q115211",
"ex:name": "Harry Rowohlt"
},
"dct:subject": {
"@id" : "https://www.wikidata.org/entity/Q115211",
"ex:name": "Harry Rowohlt"
}
}
]
}
20 changes: 20 additions & 0 deletions core/src/test/resources/custom/frame-0008-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"@context": {
"dct": "http://purl.org/dc/terms/",
"ex": "http://example.org/vocab#"
},
"@graph": [
{
"@id": "http://lobid.org/resources/HT019277879",
"@type": "ex:Biography",
"dct:creator": {
"@id" : "https://www.wikidata.org/entity/Q115211",
"ex:name": "Harry Rowohlt"
},
"dct:subject": {
"@id" : "https://www.wikidata.org/entity/Q115211",
"ex:name": "Harry Rowohlt"
}
}
]
}