Skip to content

Commit

Permalink
Add failing test for #1186
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 13, 2016
1 parent a4ae368 commit 24de8a2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.beans.ConstructorProperties;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.*;

public class CreatorPropertiesTest extends BaseMapTest
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.fasterxml.jackson.failing;

import java.util.List;

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.module.SimpleModule;

public class AbstracTypeMapping1186Test extends BaseMapTest
{
public interface IContainer<T> {
@JsonProperty("ts")
List<T> getTs();
}

static class MyContainer<T> implements IContainer<T> {

final List<T> ts;

@JsonCreator
public MyContainer(@JsonProperty("ts") List<T> ts) {
this.ts = ts;
}

@Override
public List<T> getTs() {
return ts;
}
}

public static class MyObject {
public String msg;
}

public void testDeserializeMyContainer() throws Exception {
Module module = new SimpleModule().addAbstractTypeMapping(IContainer.class, MyContainer.class);
final ObjectMapper mapper = new ObjectMapper().registerModule(module);
String json = "{\"ts\": [ { \"msg\": \"hello\"} ] }";
final Object o = mapper.readValue(json,
mapper.getTypeFactory().constructParametricType(IContainer.class, MyObject.class));
assertEquals(MyContainer.class, o.getClass());
MyContainer<?> myc = (MyContainer<?>) o;
assertEquals(1, myc.ts.size());
Object value = myc.ts.get(0);
assertEquals(MyObject.class, value.getClass());
}
}

0 comments on commit 24de8a2

Please sign in to comment.