1
1
package com .fasterxml .jackson .databind .deser ;
2
2
3
- import com .fasterxml .jackson .annotation .*;
3
+ import java .util .ArrayList ;
4
+ import java .util .List ;
4
5
6
+ import com .fasterxml .jackson .annotation .*;
5
7
import com .fasterxml .jackson .databind .*;
8
+ import com .fasterxml .jackson .databind .module .SimpleModule ;
6
9
7
10
/**
8
11
* Test for [JACKSON-429]
@@ -27,6 +30,26 @@ static class NonIgnoredType
27
30
public IgnoredType ignored ;
28
31
}
29
32
33
+ // // And test for mix-in annotations
34
+
35
+ @ JsonIgnoreType
36
+ static class Person {
37
+ public String name ;
38
+ public Person () { }
39
+ public Person (String name ) {
40
+ this .name = name ;
41
+ }
42
+ }
43
+
44
+ static class PersonWrapper {
45
+ public int value = 1 ;
46
+ public Person person = new Person ("Foo" );
47
+ }
48
+
49
+ @ JsonIgnoreType
50
+ static abstract class PersonMixin {
51
+ }
52
+
30
53
/*
31
54
/**********************************************************
32
55
/* Unit tests
@@ -46,4 +69,25 @@ public void testIgnoredType() throws Exception
46
69
assertNotNull (bean );
47
70
assertEquals (9 , bean .value );
48
71
}
72
+
73
+ public void testSingleWithMixins () throws Exception {
74
+ SimpleModule module = new SimpleModule ();
75
+ module .setMixInAnnotation (Person .class , PersonMixin .class );
76
+ ObjectMapper mapper = new ObjectMapper ();
77
+ mapper .registerModule (module );
78
+ PersonWrapper input = new PersonWrapper ();
79
+ String json = mapper .writeValueAsString (input );
80
+ assertEquals ("{\" value\" :1}" , json );
81
+ }
82
+
83
+ public void testListWithMixins () throws Exception {
84
+ SimpleModule module = new SimpleModule ();
85
+ module .setMixInAnnotation (Person .class , PersonMixin .class );
86
+ ObjectMapper mapper = new ObjectMapper ();
87
+ mapper .registerModule (module );
88
+ List <Person > persons = new ArrayList <Person >();
89
+ persons .add (new Person ("Bob" ));
90
+ String json = mapper .writeValueAsString (persons );
91
+ assertEquals ("[{\" name\" :\" Bob\" }]" , json );
92
+ }
49
93
}
0 commit comments