Skip to content

Commit 944ee55

Browse files
committed
assert deserialization results
Signed-off-by: redmitry <redmitry@list.ru>
1 parent 3d192d0 commit 944ee55

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

src/test/java/org/eclipse/yasson/jsonstructure/Issue673.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public Referenceable deserialize(JsonParser jp, DeserializationContext dc, Type
124124
return new IRIReference(str.getString());
125125
}
126126
if (v instanceof JsonObject obj) {
127-
dc.deserialize(Reference.class,
127+
return dc.deserialize(Reference.class,
128128
Json.createParserFactory(Collections.EMPTY_MAP)
129129
.createParser(obj));
130130
}

src/test/java/org/eclipse/yasson/jsonstructure/JsonStructureToParserAdapterTest.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,20 @@ public void testGetValue() {
283283
}
284284
""";
285285

286-
Jsonb jsonb = JsonbBuilder.create(
287-
new JsonbConfig().withDeserializers(new Issue673.ReferenceableDeserializer()));
288-
jsonb.fromJson(json, Issue673.LocationInterface.class);
286+
Jsonb jsonb = JsonbBuilder.create();
287+
Issue673.LocationInterface result = jsonb.fromJson(json, Issue673.LocationInterface.class);
288+
289+
assertNotNull(result);
290+
assertTrue(result instanceof Issue673.Location);
291+
Issue673.Location location = (Issue673.Location) result;
292+
293+
Issue673.Referenceable refAble = location.getReference();
294+
assertNotNull(refAble);
295+
assertFalse(refAble instanceof Issue673.Reference);
296+
assertTrue(refAble instanceof Issue673.IRIReference);
297+
Issue673.IRIReference ref = (Issue673.IRIReference) refAble;
298+
299+
assertEquals("dummy reference", ref.getValue());
289300
}
290301

291302
@Test
@@ -298,9 +309,17 @@ public void testGetArray() {
298309
}
299310
""";
300311

301-
Jsonb jsonb = JsonbBuilder.create(
302-
new JsonbConfig().withDeserializers(new Issue673.ReferenceableDeserializer()));
303-
jsonb.fromJson(json, Issue673.LocationInterface.class);
312+
Jsonb jsonb = JsonbBuilder.create();
313+
Issue673.LocationInterface result = jsonb.fromJson(json, Issue673.LocationInterface.class);
314+
315+
assertNotNull(result);
316+
assertTrue(result instanceof Issue673.Location);
317+
Issue673.Location location = (Issue673.Location) result;
318+
319+
String tags = location.getTags();
320+
assertNotNull(tags);
321+
322+
assertEquals("test1, test2", tags);
304323
}
305324

306325
}

0 commit comments

Comments
 (0)