@@ -16,13 +16,17 @@ public abstract static class Bean
16
16
int y ;
17
17
18
18
protected Bean () { }
19
-
19
+
20
20
public abstract String getX ();
21
21
22
22
public abstract String roast (int temperature );
23
23
24
24
public String getFoo () { return "Foo!" ; }
25
25
public void setY (int value ) { y = value ; }
26
+
27
+ // also verify non-public methods
28
+ protected abstract String getZ ();
29
+ private Object customMethod () { return new Object (); }
26
30
}
27
31
28
32
public abstract static class CoffeeBean extends Bean {
@@ -45,10 +49,10 @@ public void testOverrides() throws Exception
45
49
ObjectMapper mapper = new ObjectMapper ();
46
50
mapper .registerModule (new MrBeanModule ());
47
51
48
- Bean bean = mapper .readValue ("{ \" x\" : \" abc\" , \" y\" : 13 }" , CoffeeBean .class );
52
+ Bean bean = mapper .readValue ("{ \" x\" : \" abc\" , \" y\" : 13, \" z \" : \" def \" }" , CoffeeBean .class );
49
53
verifyBean (bean );
50
54
51
- Bean bean2 = mapper .readValue ("{ \" x\" : \" abc\" , \" y\" : 13 }" , PeruvianCoffeeBean .class );
55
+ Bean bean2 = mapper .readValue ("{ \" x\" : \" abc\" , \" y\" : 13, \" z \" : \" def \" }" , PeruvianCoffeeBean .class );
52
56
verifyBean (bean2 );
53
57
}
54
58
@@ -57,6 +61,8 @@ private void verifyBean(Bean bean) {
57
61
assertEquals ("abc" , bean .getX ());
58
62
assertEquals (13 , bean .y );
59
63
assertEquals ("Foo!" , bean .getFoo ());
64
+ assertEquals ("def" , bean .getZ ());
65
+ assertNotNull (bean .customMethod ());
60
66
assertEquals ("The coffee beans are roasting at 123 degrees now, yummy" , bean .roast (123 ));
61
67
}
62
68
}
0 commit comments