@@ -137,6 +137,46 @@ public void testAbsentExclusion() throws Exception
137
137
mapper .writeValueAsString (new SimpleWrapper (null )));
138
138
}
139
139
140
+ public void testSerPropInclusionAlways () throws Exception
141
+ {
142
+ JsonInclude .Value incl =
143
+ JsonInclude .Value .construct (JsonInclude .Include .NON_ABSENT , JsonInclude .Include .ALWAYS );
144
+ ObjectMapper mapper = new ObjectMapper ();
145
+ mapper .setPropertyInclusion (incl );
146
+ assertEquals (aposToQuotes ("{'value':true}" ),
147
+ mapper .writeValueAsString (new SimpleWrapper (Boolean .TRUE )));
148
+ }
149
+
150
+ public void testSerPropInclusionNonNull () throws Exception
151
+ {
152
+ JsonInclude .Value incl =
153
+ JsonInclude .Value .construct (JsonInclude .Include .NON_ABSENT , JsonInclude .Include .NON_NULL );
154
+ ObjectMapper mapper = new ObjectMapper ();
155
+ mapper .setPropertyInclusion (incl );
156
+ assertEquals (aposToQuotes ("{'value':true}" ),
157
+ mapper .writeValueAsString (new SimpleWrapper (Boolean .TRUE )));
158
+ }
159
+
160
+ public void testSerPropInclusionNonAbsent () throws Exception
161
+ {
162
+ JsonInclude .Value incl =
163
+ JsonInclude .Value .construct (JsonInclude .Include .NON_ABSENT , JsonInclude .Include .NON_ABSENT );
164
+ ObjectMapper mapper = new ObjectMapper ();
165
+ mapper .setPropertyInclusion (incl );
166
+ assertEquals (aposToQuotes ("{'value':true}" ),
167
+ mapper .writeValueAsString (new SimpleWrapper (Boolean .TRUE )));
168
+ }
169
+
170
+ public void testSerPropInclusionNonEmpty () throws Exception
171
+ {
172
+ JsonInclude .Value incl =
173
+ JsonInclude .Value .construct (JsonInclude .Include .NON_ABSENT , JsonInclude .Include .NON_EMPTY );
174
+ ObjectMapper mapper = new ObjectMapper ();
175
+ mapper .setPropertyInclusion (incl );
176
+ assertEquals (aposToQuotes ("{'value':true}" ),
177
+ mapper .writeValueAsString (new SimpleWrapper (Boolean .TRUE )));
178
+ }
179
+
140
180
// [databind#340]
141
181
public void testPolymorphicAtomicReference () throws Exception
142
182
{
0 commit comments