Skip to content

Commit 07206c0

Browse files
committed
[Bug #51] Add test reproducing the issue.
1 parent 8ad8bc0 commit 07206c0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/test/java/cz/cvut/kbss/jsonld/serialization/ContextBuildingJsonLdSerializerTest.java

+21
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ void serializationCreatesEmbeddedContextToOverrideIncompatibleTermMapping() thro
229229
instance.organization = Generator.generateOrganization();
230230

231231
final Map<String, ?> json = serializeAndRead(instance);
232+
verifyEmbeddedContext(json);
233+
}
234+
235+
private void verifyEmbeddedContext(Map<String, ?> json) {
232236
assertThat(json, hasKey(JsonLd.CONTEXT));
233237
assertInstanceOf(Map.class, json.get(JsonLd.CONTEXT));
234238
final Map<String, ?> context = (Map<String, JsonNode>) json.get(JsonLd.CONTEXT);
@@ -288,4 +292,21 @@ void serializationSerializesRootCollectionOfEnumConstantsMappedToIndividualsAsAr
288292
assertEquals(OwlPropertyType.getMappedIndividual(value.get(i)), element.get(JsonLd.ID));
289293
}
290294
}
295+
296+
/**
297+
* Bug #51
298+
*/
299+
@Test
300+
void serializationCreatesEmbeddedContextOnCorrectLevel() throws Exception {
301+
final StudyWithTitle instance = new StudyWithTitle();
302+
instance.uri = Generator.generateUri();
303+
instance.name = "Test study";
304+
instance.organization = Generator.generateOrganization();
305+
instance.organization.addEmployee(Generator.generateEmployee());
306+
instance.organization.addEmployee(Generator.generateEmployee());
307+
instance.organization.getEmployees().forEach(e -> e.setEmployer(instance.organization));
308+
309+
final Map<String, ?> json = serializeAndRead(instance);
310+
verifyEmbeddedContext(json);
311+
}
291312
}

0 commit comments

Comments
 (0)