Skip to content

Commit c123b33

Browse files
committed
Add a (passing) test for #1806
1 parent 2b9b927 commit c123b33

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/test/java/com/fasterxml/jackson/databind/ser/JsonValueSerializationTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,21 @@ public void serialize(Bean838 value, JsonGenerator gen,
196196
}
197197
}
198198

199+
// [databind#1806]
200+
static class Bean1806 {
201+
@JsonValue public List<Elem1806> getThings() {
202+
return Collections.singletonList(new Elem1806.Impl());
203+
}
204+
}
205+
206+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT)
207+
@JsonSubTypes(@JsonSubTypes.Type(value = Elem1806.Impl.class, name = "impl"))
208+
interface Elem1806 {
209+
final class Impl implements Elem1806 {
210+
public int value = 1;
211+
}
212+
}
213+
199214
// [databind#2822]
200215
@JsonPropertyOrder({ "description", "b" })
201216
static class A2822 {
@@ -322,6 +337,13 @@ public void testJsonValueWithCustomOverride() throws Exception
322337
assertEquals("42", mapper.writeValueAsString(INPUT));
323338
}
324339

340+
// [databind#1806]
341+
public void testCollectionViaJsonValue() throws Exception
342+
{
343+
assertEquals("[{\"impl\":{\"value\":1}}]",
344+
MAPPER.writeValueAsString(new Bean1806()));
345+
}
346+
325347
// [databind#2822]
326348
public void testFormatWithJsonValue() throws Exception
327349
{

0 commit comments

Comments
 (0)