@@ -54,12 +54,20 @@ interface NonPublicBean {
54
54
public abstract int getX ();
55
55
}
56
56
57
- public interface ExtendedBean extends Bean {
57
+ public interface OtherInterface {
58
+ public boolean anyValuePresent ();
59
+ }
60
+
61
+ public interface BeanWithDefaultForOtherInterface extends Bean , OtherInterface {
58
62
public default boolean anyValuePresent () {
59
63
return getX () > 0 || getA () != null ;
60
64
}
61
65
}
62
66
67
+ public interface BeanWithInheritedDefault extends BeanWithDefaultForOtherInterface {
68
+ // in this interface, anyValuePresent() is an inherited (rather than declared) concrete method
69
+ }
70
+
63
71
/*
64
72
/**********************************************************
65
73
/* Unit tests, low level
@@ -179,10 +187,20 @@ public void testSubInterface() throws Exception
179
187
assertEquals (2 , bean .getY ());
180
188
}
181
189
182
- public void testDefaultMethods () throws Exception
190
+ public void testDefaultMethodInInterface () throws Exception
191
+ {
192
+ ObjectMapper mapper = newMrBeanMapper ();
193
+ BeanWithDefaultForOtherInterface bean = mapper .readValue ("{\" a\" :\" value\" ,\" x\" :123 }" , BeanWithDefaultForOtherInterface .class );
194
+ assertNotNull (bean );
195
+ assertEquals ("value" , bean .getA ());
196
+ assertEquals (123 , bean .getX ());
197
+ assertTrue (bean .anyValuePresent ());
198
+ }
199
+
200
+ public void testInheritedDefaultMethodInInterface () throws Exception
183
201
{
184
202
ObjectMapper mapper = newMrBeanMapper ();
185
- ExtendedBean bean = mapper .readValue ("{\" a\" :\" value\" ,\" x\" :123 }" , ExtendedBean .class );
203
+ BeanWithInheritedDefault bean = mapper .readValue ("{\" a\" :\" value\" ,\" x\" :123 }" , BeanWithInheritedDefault .class );
186
204
assertNotNull (bean );
187
205
assertEquals ("value" , bean .getA ());
188
206
assertEquals (123 , bean .getX ());
0 commit comments