From e979bc530a86a32d63389acbedd3323185ad4ef6 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 15 Aug 2016 22:40:47 -0700 Subject: [PATCH] Add first test for #1327; passes with 2.7 --- .../databind/filter/JsonIncludeTest.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/fasterxml/jackson/databind/filter/JsonIncludeTest.java b/src/test/java/com/fasterxml/jackson/databind/filter/JsonIncludeTest.java index db1b1be3e3..e5f44ebbf5 100644 --- a/src/test/java/com/fasterxml/jackson/databind/filter/JsonIncludeTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/filter/JsonIncludeTest.java @@ -118,7 +118,13 @@ static class NonEmptyDouble { public NonEmptyDouble(double v) { value = v; } } - + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + public static class Issues1327Bean { + public String myString = "stuff"; + public List myList = new ArrayList(); + } + /* /********************************************************** /* Unit tests @@ -231,4 +237,16 @@ public void testEmptyInclusionScalars() throws IOException assertEquals("{\"i\":0}", defMapper.writeValueAsString(zero)); assertEquals("{\"i\":0}", inclMapper.writeValueAsString(zero)); } + + public void testIssue1327() throws Exception { + ObjectMapper om = new ObjectMapper(); + om.setSerializationInclusion(JsonInclude.Include.NON_NULL); + + final Issues1327Bean input = new Issues1327Bean(); + final String jsonString = om.writeValueAsString(input); + + if (jsonString.contains("myList")) { + fail("Should not contain `myList`: "+jsonString); + } + } }