1 package com.fasterxml.jackson.failing; 2 3 import java.util.*; 4 5 import com.fasterxml.jackson.annotation.*; 6 import com.fasterxml.jackson.databind.*; 7 8 // For [databind#2305]: regression/unintentional change, but not sure if behavior 9 // should or should not be changed. 10 public class SingleArgCreator2305Test extends BaseMapTest 11 { 12 // [databind#2305] 13 static class ExportRequest2305 { 14 private final String heading; 15 private List<Format2305> fields; 16 17 @JsonCreator ExportRequest2305(@sonProperty"fields") List<Format2305> fields, @JsonProperty("heading") String heading)18 public ExportRequest2305(@JsonProperty("fields") List<Format2305> fields, 19 @JsonProperty("heading") String heading) { 20 this.fields = fields; 21 this.heading = heading; 22 } 23 getFields()24 public List<Format2305> getFields() { return fields; } getHeading()25 public String getHeading() { return heading; } 26 27 public static class Format2305 { 28 private final Object value; 29 private final String pattern; 30 private final String currency; 31 private int maxChars; 32 private Double proportion; 33 Format2305(String value)34 public Format2305(String value) { this(value, "", null); } 35 36 @JsonCreator Format2305(@sonProperty"value") Object value, @JsonProperty("pattern") String pattern, @JsonProperty("currency") String currency)37 public Format2305(@JsonProperty("value") Object value, 38 @JsonProperty("pattern") String pattern, 39 @JsonProperty("currency") String currency) { 40 this.value = (value == null ? "" : value); 41 this.currency = currency; 42 this.pattern = pattern; 43 } 44 getValue()45 public String getValue() { 46 return value == null ? null : value.toString(); 47 } 48 49 @JsonIgnore getPattern()50 public String getPattern() { 51 return pattern; 52 } 53 54 @JsonIgnore getCurrency()55 public String getCurrency() { 56 return currency; 57 } 58 getMaxChars()59 public int getMaxChars() { 60 return maxChars; 61 } 62 setMaxChars(int maxChars)63 public void setMaxChars(int maxChars) { 64 this.maxChars = maxChars; 65 } 66 getProportion()67 public Double getProportion() { 68 return proportion; 69 } 70 setProportion(Double proportion)71 public void setProportion(Double proportion) { 72 this.proportion = proportion; 73 } 74 } 75 } 76 77 /* 78 /********************************************************** 79 /* Test methods 80 /********************************************************** 81 */ 82 83 private final ObjectMapper MAPPER = objectMapper(); 84 85 // [databind#2305] testIssue2305()86 public void testIssue2305() throws Exception 87 { 88 Map<?,?> result = MAPPER.readValue("{\"heading\": \"TEST\",\"fields\":[\"field1\",\"field2\"] }", Map.class); 89 ExportRequest2305 exportReqt = MAPPER.convertValue(result, ExportRequest2305.class); 90 assertNotNull(exportReqt); 91 } 92 } 93