|
9 | 9 | import org.w3c.dom.Element;
|
10 | 10 |
|
11 | 11 | import com.fasterxml.jackson.annotation.*;
|
12 |
| -import com.fasterxml.jackson.annotation.JsonTypeInfo.As; |
13 | 12 | import com.fasterxml.jackson.core.*;
|
14 | 13 | import com.fasterxml.jackson.core.io.CharacterEscapes;
|
15 | 14 | import com.fasterxml.jackson.databind.*;
|
@@ -191,7 +190,8 @@ public String getId() {
|
191 | 190 | }
|
192 | 191 | }
|
193 | 192 |
|
194 |
| - @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, include = As.PROPERTY, property = "@class") |
| 193 | + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") |
| 194 | + @JsonSubTypes({ @JsonSubTypes.Type(name = "Foo", value = Foo.class) }) |
195 | 195 | interface Strategy { }
|
196 | 196 |
|
197 | 197 | static class Foo implements Strategy {
|
@@ -310,24 +310,18 @@ public void testWithCustomElements() throws Exception
|
310 | 310 | }
|
311 | 311 |
|
312 | 312 | // [databind#2475]
|
313 |
| - public void testIssue2475Filter() throws Exception { |
| 313 | + public void testIssue2475() throws Exception { |
314 | 314 | SimpleFilterProvider provider = new SimpleFilterProvider().addFilter("myFilter", new MyFilter2475());
|
315 | 315 | ObjectWriter writer = MAPPER.writer(provider);
|
316 | 316 |
|
317 |
| - writer.writeValueAsString(new Item2475(new ArrayList<String>(), "ID-1")); |
318 |
| - } |
319 |
| - |
320 |
| - // [databind#2475] |
321 |
| - public void testIssue2475Contents() throws Exception { |
322 |
| - SimpleFilterProvider provider = new SimpleFilterProvider().addFilter("myFilter", new SimpleBeanPropertyFilter() {}); |
323 |
| - ObjectWriter writer = MAPPER.writer(provider); |
324 |
| - |
325 |
| - assertEquals(aposToQuotes("{'id':'ID-1','strategy':{'foo':42},'set':[]}"), |
| 317 | + // contents don't really matter that much as verification within filter but... let's |
| 318 | + // check anyway |
| 319 | + assertEquals(aposToQuotes("{'id':'ID-1','strategy':{'type':'Foo','foo':42},'set':[]}"), |
326 | 320 | writer.writeValueAsString(new Item2475(new ArrayList<String>(), "ID-1")));
|
327 | 321 |
|
328 |
| - assertEquals(aposToQuotes("{'id':'ID-2','strategy':{'foo':42},'set':[]}"), |
| 322 | + assertEquals(aposToQuotes("{'id':'ID-2','strategy':{'type':'Foo','foo':42},'set':[]}"), |
329 | 323 | writer.writeValueAsString(new Item2475(new HashSet<String>(), "ID-2")));
|
330 |
| - } |
331 |
| - |
| 324 | + |
| 325 | + } |
332 | 326 |
|
333 | 327 | }
|
0 commit comments