Skip to content

Commit e800726

Browse files
committed
Add failing test case
1 parent e0bfe3f commit e800726

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

mrbean/src/test/java/com/fasterxml/jackson/module/mrbean/TestSimpleMaterializedInterfaces.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,20 @@ interface NonPublicBean {
5454
public abstract int getX();
5555
}
5656

57-
public interface ExtendedBean extends Bean {
57+
public interface OtherInterface {
58+
public boolean anyValuePresent();
59+
}
60+
61+
public interface BeanWithDefaultForOtherInterface extends Bean, OtherInterface {
5862
public default boolean anyValuePresent() {
5963
return getX() > 0 || getA() != null;
6064
}
6165
}
6266

67+
public interface BeanWithInheritedDefault extends BeanWithDefaultForOtherInterface {
68+
// in this interface, anyValuePresent() is an inherited (rather than declared) concrete method
69+
}
70+
6371
/*
6472
/**********************************************************
6573
/* Unit tests, low level
@@ -179,10 +187,20 @@ public void testSubInterface() throws Exception
179187
assertEquals(2, bean.getY());
180188
}
181189

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
183201
{
184202
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);
186204
assertNotNull(bean);
187205
assertEquals("value", bean.getA());
188206
assertEquals(123, bean.getX());

0 commit comments

Comments
 (0)