1 package com.fasterxml.jackson.databind.mixins; 2 3 import java.lang.annotation.*; 4 5 import com.fasterxml.jackson.annotation.*; 6 7 import com.fasterxml.jackson.databind.*; 8 9 // for [databind#771] 10 public class MixinsWithBundlesTest extends BaseMapTest 11 { 12 @Target(value={ ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD }) 13 @Retention(value=RetentionPolicy.RUNTIME) 14 @JacksonAnnotationsInside 15 @JsonProperty("bar") 16 public @interface ExposeStuff { 17 18 } 19 20 public abstract class FooMixin { 21 @ExposeStuff getStuff()22 public abstract String getStuff(); 23 } 24 25 public static class Foo { 26 27 private String stuff; 28 Foo(String stuff)29 Foo(String stuff) { 30 this.stuff = stuff; 31 } 32 getStuff()33 public String getStuff() { 34 return stuff; 35 } 36 } testMixinWithBundles()37 public void testMixinWithBundles() throws Exception 38 { 39 ObjectMapper mapper = new ObjectMapper().addMixIn(Foo.class, FooMixin.class); 40 String result = mapper.writeValueAsString(new Foo("result")); 41 assertEquals("{\"bar\":\"result\"}", result); 42 } 43 } 44