Skip to content

Commit

Permalink
refactoring: move #1128 test into non-failing section, after minor mo…
Browse files Browse the repository at this point in the history
…ds to make type handling correct in test itself
  • Loading branch information
cowtowncoder committed Feb 26, 2016
1 parent e23638e commit dfef7cf
Showing 1 changed file with 12 additions and 7 deletions.
@@ -1,14 +1,19 @@
package com.fasterxml.jackson.failing;
package com.fasterxml.jackson.databind.jsontype;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

public class Generic1133Test extends BaseMapTest
public class Generic1128Test extends BaseMapTest
{
@SuppressWarnings("rawtypes")
static abstract class HObj<M extends HObj> {
public long id;

// important: do not serialize as subtype, but only as type that
// is statically recognizable here.
@JsonSerialize(typing=JsonSerialize.Typing.STATIC)
public M parent;
}

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

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

String json = mapper.writeValueAsString(devMContainer1);
// String json = "{\"entity\":{\"id\":0,\"parent\":{\"id\":2,\"p1\":0},\"p1\":0,\"m1\":0}}";

System.out.println("serializedContainer = " + json);

// System.out.println("serializedContainer = " + json);
final DevMContainer devMContainer = mapper.readValue(json, DevMContainer.class);
System.out.println("devMContainer.getEntity().getParent().getId() = " + devMContainer.entity.parent.id);
long id = devMContainer.entity.parent.id;
// System.out.println("devMContainer.getEntity().getParent().getId() = " + id);
assertEquals(2, id);
}
}

0 comments on commit dfef7cf

Please sign in to comment.