@@ -18,8 +18,45 @@ public FascistPoint(@JsonProperty(value="x", required=true) int x,
1818 }
1919 }
2020
21- private final ObjectReader POINT_READER = objectMapper ().readerFor (FascistPoint .class );
22-
21+ // [databind#2591]
22+ static class LoginUserResponse {
23+ private String otp ;
24+
25+ private String userType ;
26+
27+ @ JsonCreator
28+ public LoginUserResponse (@ JsonProperty (value = "otp" , required = true ) String otp ,
29+ @ JsonProperty (value = "userType" , required = true ) String userType ) {
30+ this .otp = otp ;
31+ this .userType = userType ;
32+ }
33+
34+ public String getOtp () {
35+ return otp ;
36+ }
37+
38+ public void setOtp (String otp ) {
39+ this .otp = otp ;
40+ }
41+
42+ public String getUserType () {
43+ return userType ;
44+ }
45+
46+ public void setUserType (String userType ) {
47+ this .userType = userType ;
48+ }
49+ }
50+
51+ /*
52+ /**********************************************************************
53+ /* Test methods
54+ /**********************************************************************
55+ */
56+
57+ private final ObjectMapper MAPPER = newJsonMapper ();
58+ private final ObjectReader POINT_READER = MAPPER .readerFor (FascistPoint .class );
59+
2360 public void testRequiredAnnotatedParam () throws Exception
2461 {
2562 FascistPoint p ;
@@ -64,4 +101,16 @@ public void testRequiredGloballyParam() throws Exception
64101 verifyException (e , "Missing creator property 'y' (index 1)" );
65102 }
66103 }
104+
105+ // [databind#2591]
106+ public void testRequiredViaParameter2591 () throws Exception
107+ {
108+ final String input = aposToQuotes ("{'status':'OK', 'message':'Sent Successfully!'}" );
109+ try {
110+ /*LoginUserResponse resp =*/ MAPPER .readValue (input , LoginUserResponse .class );
111+ fail ("Shoud not pass" );
112+ } catch (JsonMappingException e ) {
113+ verifyException (e , "Missing required creator property 'otp'" );
114+ }
115+ }
67116}
0 commit comments