@@ -229,6 +229,10 @@ void serializationCreatesEmbeddedContextToOverrideIncompatibleTermMapping() thro
229
229
instance .organization = Generator .generateOrganization ();
230
230
231
231
final Map <String , ?> json = serializeAndRead (instance );
232
+ verifyEmbeddedContext (json );
233
+ }
234
+
235
+ private void verifyEmbeddedContext (Map <String , ?> json ) {
232
236
assertThat (json , hasKey (JsonLd .CONTEXT ));
233
237
assertInstanceOf (Map .class , json .get (JsonLd .CONTEXT ));
234
238
final Map <String , ?> context = (Map <String , JsonNode >) json .get (JsonLd .CONTEXT );
@@ -288,4 +292,21 @@ void serializationSerializesRootCollectionOfEnumConstantsMappedToIndividualsAsAr
288
292
assertEquals (OwlPropertyType .getMappedIndividual (value .get (i )), element .get (JsonLd .ID ));
289
293
}
290
294
}
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
+ }
291
312
}
0 commit comments