-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Streamlining
AnnotatedClass
slightly, trying to figure out #771
- Loading branch information
1 parent
7d5c50b
commit 6dcb13f
Showing
2 changed files
with
79 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/test/java/com/fasterxml/jackson/databind/mixins/MixinsWithBundlesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.fasterxml.jackson.databind.mixins; | ||
|
||
import java.lang.annotation.*; | ||
|
||
import com.fasterxml.jackson.annotation.*; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
|
||
// for [databind#771] | ||
public class MixinsWithBundlesTest extends BaseMapTest | ||
{ | ||
@Target(value={ ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD }) | ||
@Retention(value=RetentionPolicy.RUNTIME) | ||
@JacksonAnnotationsInside | ||
@JsonProperty("bar") | ||
public @interface ExposeStuff { | ||
|
||
} | ||
|
||
public abstract class FooMixin { | ||
@ExposeStuff | ||
public abstract String getStuff(); | ||
} | ||
|
||
public static class Foo { | ||
|
||
private String stuff; | ||
|
||
Foo(String stuff) { | ||
this.stuff = stuff; | ||
} | ||
|
||
public String getStuff() { | ||
return stuff; | ||
} | ||
} | ||
public void testMixinWithBundles() throws Exception | ||
{ | ||
ObjectMapper mapper = new ObjectMapper().addMixIn(Foo.class, FooMixin.class); | ||
String result = mapper.writeValueAsString(new Foo("result")); | ||
assertEquals("{\"bar\":\"result\"}", result); | ||
} | ||
} |