@@ -16,27 +16,42 @@ public class JsonInclude1327Test
16
16
extends BaseMapTest
17
17
{
18
18
@ JsonInclude (JsonInclude .Include .NON_EMPTY )
19
- public static class Issues1327Bean {
19
+ static class Issue1327BeanEmpty {
20
20
public String myString = "stuff" ;
21
21
public List <String > myList = new ArrayList <String >();
22
22
}
23
23
24
+ static class Issue1327BeanAlways {
25
+ @ JsonInclude (JsonInclude .Include .ALWAYS )
26
+ public List <String > strings = new ArrayList <String >();
27
+ }
28
+
24
29
/*
25
30
/**********************************************************
26
31
/* Unit tests
27
32
/**********************************************************
28
33
*/
29
34
30
35
// for [databind#1327]
31
- public void testIssue1327 () throws Exception {
36
+ public void testClassDefaultsForEmpty () throws Exception {
32
37
ObjectMapper om = new ObjectMapper ();
33
38
om .setSerializationInclusion (JsonInclude .Include .NON_NULL );
34
39
35
- final Issues1327Bean input = new Issues1327Bean ();
36
- final String jsonString = om .writeValueAsString (input );
40
+ final String jsonString = om .writeValueAsString (new Issue1327BeanEmpty ());
37
41
38
42
if (jsonString .contains ("myList" )) {
39
43
fail ("Should not contain `myList`: " +jsonString );
40
44
}
41
45
}
46
+
47
+ public void testClassDefaultsForAlways () throws Exception {
48
+ ObjectMapper om = new ObjectMapper ();
49
+ om .setSerializationInclusion (JsonInclude .Include .NON_EMPTY );
50
+
51
+ final String jsonString = om .writeValueAsString (new Issue1327BeanAlways ());
52
+
53
+ if (!jsonString .contains ("myList" )) {
54
+ fail ("Should contain `myList` with Include.ALWAYS: " +jsonString );
55
+ }
56
+ }
42
57
}
0 commit comments