File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
src/test/java/com/fasterxml/jackson/databind/deser Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,22 @@ public void setXyz(int x) {
30
30
}
31
31
}
32
32
33
+ static class AliasBean2378 {
34
+ String partitionId ;
35
+ String _id ;
36
+
37
+ private AliasBean2378 (boolean bogus , String partId , String userId ) {
38
+ partitionId = partId ;
39
+ _id = userId ;
40
+ }
41
+
42
+ @ JsonCreator
43
+ public static AliasBean2378 create (@ JsonProperty ("partitionId" ) String partId ,
44
+ @ JsonProperty ("id" ) @ JsonAlias ("userId" ) String userId ) {
45
+ return new AliasBean2378 (false , partId , userId );
46
+ }
47
+ }
48
+
33
49
static class PolyWrapperForAlias {
34
50
@ JsonTypeInfo (use = JsonTypeInfo .Id .NAME ,
35
51
include = JsonTypeInfo .As .WRAPPER_ARRAY )
@@ -81,4 +97,14 @@ public void testAliasWithPolymorphic() throws Exception
81
97
assertEquals ("Bob" , bean .name );
82
98
assertEquals (17 , bean ._a );
83
99
}
100
+
101
+ // [databind#2378]
102
+ public void testAliasInFactoryMethod () throws Exception
103
+ {
104
+ AliasBean2378 bean = MAPPER .readValue (aposToQuotes (
105
+ "{'partitionId' : 'a', 'userId' : '123'}"
106
+ ), AliasBean2378 .class );
107
+ assertEquals ("a" , bean .partitionId );
108
+ assertEquals ("123" , bean ._id );
109
+ }
84
110
}
You can’t perform that action at this time.
0 commit comments