• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.fasterxml.jackson.failing;
2 
3 import com.fasterxml.jackson.annotation.*;
4 
5 import com.fasterxml.jackson.databind.*;
6 
7 // for [databind#1401]: should allow "Any Setter" to back up otherwise
8 // problematic Creator properties?
9 public class CreatorAnySetter1401Test extends BaseMapTest
10 {
11     // for [databind#1401]
12     static class NoSetter1401 {
13         int _a;
14 
15         @JsonCreator
NoSetter1401(@sonProperty"a") int a)16         public NoSetter1401(@JsonProperty("a") int a) {
17             _a = a;
18         }
19 
20         @JsonAnySetter
any(String key, Object value)21         public void any(String key, Object value) { }
22     }
23 
24     /*
25     /**********************************************************
26     /* Test methods
27     /**********************************************************
28      */
29 
30     private final ObjectMapper MAPPER = new ObjectMapper();
31 
32     // [databind#1401]
testCreatorNoSetter()33     public void testCreatorNoSetter() throws Exception
34     {
35         NoSetter1401 b = MAPPER.readValue(aposToQuotes("{'a':1,'b':2}"),
36                 NoSetter1401.class);
37         assertEquals(1, b._a);
38 
39         NoSetter1401 b2 = MAPPER.readerForUpdating(new NoSetter1401(1))
40                 .readValue(aposToQuotes("{'a':1}"));
41         assertEquals(1, b2._a);
42     }
43 }
44