Skip to content

Commit dfef7cf

Browse files
committed
refactoring: move #1128 test into non-failing section, after minor mods to make type handling correct in test itself
1 parent e23638e commit dfef7cf

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/test/java/com/fasterxml/jackson/failing/Generic1133Test.java renamed to src/test/java/com/fasterxml/jackson/databind/jsontype/Generic1128Test.java

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
package com.fasterxml.jackson.failing;
1+
package com.fasterxml.jackson.databind.jsontype;
22

33
import com.fasterxml.jackson.annotation.JsonInclude;
44
import com.fasterxml.jackson.databind.BaseMapTest;
55
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
67

7-
public class Generic1133Test extends BaseMapTest
8+
public class Generic1128Test extends BaseMapTest
89
{
910
@SuppressWarnings("rawtypes")
1011
static abstract class HObj<M extends HObj> {
1112
public long id;
13+
14+
// important: do not serialize as subtype, but only as type that
15+
// is statically recognizable here.
16+
@JsonSerialize(typing=JsonSerialize.Typing.STATIC)
1217
public M parent;
1318
}
1419

@@ -44,7 +49,6 @@ static class DevMContainer extends ContainerBase<DevM>{ }
4449
public void testIssue1128() throws Exception
4550
{
4651
ObjectMapper mapper = new ObjectMapper();
47-
// mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
4852
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
4953

5054
final DevMContainer devMContainer1 = new DevMContainer();
@@ -55,10 +59,11 @@ public void testIssue1128() throws Exception
5559
devMContainer1.entity = entity;
5660

5761
String json = mapper.writeValueAsString(devMContainer1);
58-
// String json = "{\"entity\":{\"id\":0,\"parent\":{\"id\":2,\"p1\":0},\"p1\":0,\"m1\":0}}";
59-
60-
System.out.println("serializedContainer = " + json);
62+
63+
// System.out.println("serializedContainer = " + json);
6164
final DevMContainer devMContainer = mapper.readValue(json, DevMContainer.class);
62-
System.out.println("devMContainer.getEntity().getParent().getId() = " + devMContainer.entity.parent.id);
65+
long id = devMContainer.entity.parent.id;
66+
// System.out.println("devMContainer.getEntity().getParent().getId() = " + id);
67+
assertEquals(2, id);
6368
}
6469
}

0 commit comments

Comments
 (0)