1 package com.fasterxml.jackson.failing; 2 3 import java.io.IOException; 4 import java.util.*; 5 6 import com.fasterxml.jackson.annotation.JsonInclude; 7 import com.fasterxml.jackson.databind.*; 8 9 public class MapInclusion1649Test extends BaseMapTest 10 { 11 @JsonInclude(value=JsonInclude.Include.NON_EMPTY, content=JsonInclude.Include.NON_EMPTY) 12 static class Bean1649 { 13 public Map<String, String> map; 14 Bean1649(String key, String value)15 public Bean1649(String key, String value) { 16 map = new LinkedHashMap<>(); 17 map.put(key, value); 18 } 19 } 20 21 /* 22 /********************************************************** 23 /* Test methods 24 /********************************************************** 25 */ 26 27 final private ObjectMapper MAPPER = objectMapper(); 28 29 // [databind#1649] testNonEmptyViaClass()30 public void testNonEmptyViaClass() throws IOException 31 { 32 // non-empty/null, include 33 assertEquals(aposToQuotes("{'map':{'a':'b'}}"), 34 MAPPER.writeValueAsString(new Bean1649("a", "b"))); 35 // null, empty, nope 36 assertEquals(aposToQuotes("{}"), 37 MAPPER.writeValueAsString(new Bean1649("a", null))); 38 assertEquals(aposToQuotes("{}"), 39 MAPPER.writeValueAsString(new Bean1649("a", ""))); 40 } 41 } 42