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