|
1 | 1 | package com.fasterxml.jackson.databind.introspect;
|
2 | 2 |
|
3 |
| -import com.fasterxml.jackson.databind.BaseMapTest; |
| 3 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 4 | + |
| 5 | +import com.fasterxml.jackson.databind.*; |
| 6 | +import com.fasterxml.jackson.databind.module.SimpleModule; |
4 | 7 |
|
5 | 8 | public class TestMixinMerging extends BaseMapTest
|
6 | 9 | {
|
| 10 | + public interface Contact { |
| 11 | + String getCity(); |
| 12 | + } |
| 13 | + |
| 14 | + static class ContactImpl implements Contact { |
| 15 | + public String getCity() { return "Seattle"; } |
| 16 | + } |
| 17 | + |
| 18 | + static class ContactMixin implements Contact { |
| 19 | + @JsonProperty |
| 20 | + public String getCity() { return null; } |
| 21 | + } |
| 22 | + |
| 23 | + public interface Person extends Contact {} |
| 24 | + |
| 25 | + static class PersonImpl extends ContactImpl implements Person {} |
| 26 | + |
| 27 | + static class PersonMixin extends ContactMixin implements Person {} |
| 28 | + |
| 29 | + /* |
| 30 | + /********************************************************** |
| 31 | + /* Unit tests |
| 32 | + /********************************************************** |
| 33 | + */ |
| 34 | + |
7 | 35 | // for [Issue#515]
|
8 | 36 | public void testDisappearingMixins515() throws Exception
|
9 | 37 | {
|
10 |
| - // TBI |
| 38 | + ObjectMapper mapper = new ObjectMapper(); |
| 39 | + mapper.disable(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS) |
| 40 | + .disable(MapperFeature.AUTO_DETECT_FIELDS) |
| 41 | + .disable(MapperFeature.AUTO_DETECT_GETTERS) |
| 42 | + .disable(MapperFeature.AUTO_DETECT_IS_GETTERS) |
| 43 | + .disable(MapperFeature.INFER_PROPERTY_MUTATORS); |
| 44 | + SimpleModule module = new SimpleModule("Test"); |
| 45 | + module.setMixInAnnotation(Person.class, PersonMixin.class); |
| 46 | + mapper.registerModule(module); |
| 47 | + |
| 48 | + assertEquals("{\"city\":\"Seattle\"}", mapper.writeValueAsString(new PersonImpl())); |
11 | 49 | }
|
12 | 50 | }
|
0 commit comments