Skip to content

Commit bb7b024

Browse files
committed
Trim down #1654 test case
1 parent cc93b8f commit bb7b024

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/test/java/tools/jackson/databind/jsontype/NoTypeInfo1654Test.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public Value1654TypedContainer(Value1654... v) {
3737
}
3838

3939
static class Value1654UntypedContainer {
40-
@JsonDeserialize(contentUsing = Value1654Deserializer.class)
40+
//@JsonDeserialize(contentUsing = Value1654Deserializer.class)
4141
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
4242
public List<Value1654> values;
4343

@@ -49,6 +49,7 @@ public Value1654UntypedContainer(Value1654... v) {
4949
}
5050
}
5151

52+
/*
5253
static class Value1654Deserializer extends ValueDeserializer<Value1654> {
5354
@Override
5455
public Value1654 deserialize(JsonParser p, DeserializationContext ctxt) {
@@ -57,26 +58,30 @@ public Value1654 deserialize(JsonParser p, DeserializationContext ctxt) {
5758
return new Value1654(13);
5859
}
5960
}
61+
*/
6062

6163
private final ObjectMapper MAPPER = newJsonMapper();
6264

63-
// [databind#1654]
65+
// [databind#1654]: no override, default polymorphic type id
6466
@Test
65-
void noTypeElementOverride() throws Exception {
66-
// egular typed case
67+
void withoutNoTypeElementOverrideSerAndDeser() throws Exception {
68+
// regular typed case
6769
String json = MAPPER.writeValueAsString(new Value1654TypedContainer(
6870
new Value1654(1),
69-
new Value1654(2),
70-
new Value1654(3)
71+
new Value1654(2)
7172
));
73+
String typeId = Value1654.class.getName();
74+
typeId = "'@type':'" + typeId.substring(typeId.lastIndexOf('.') + 1) + "'";
75+
assertEquals(a2q("{'values':[{"+typeId+",'x':1},{"+typeId+",'x':2}]}"), json);
76+
7277
Value1654TypedContainer result = MAPPER.readValue(json, Value1654TypedContainer.class);
73-
assertEquals(3, result.values.size());
78+
assertEquals(2, result.values.size());
7479
assertEquals(2, result.values.get(1).x);
7580
}
7681

77-
// [databind#1654]
82+
// [databind#1654]: override, no polymorphic type id
7883
@Test
79-
void noTypeInfoOverrideSer() throws Exception {
84+
void withNoTypeInfoOverrideSer() throws Exception {
8085
Value1654UntypedContainer cont = new Value1654UntypedContainer(
8186
new Value1654(3),
8287
new Value1654(7)
@@ -87,7 +92,7 @@ void noTypeInfoOverrideSer() throws Exception {
8792

8893
// [databind#1654]
8994
@Test
90-
void noTypeInfoOverrideDeser() throws Exception {
95+
void withNoTypeInfoOverrideDeser() throws Exception {
9196
// and then actual failing case
9297
final String noTypeJson = a2q(
9398
"{'values':[{'x':3},{'x':7}]}"

0 commit comments

Comments
 (0)