@Test public void testRedefinesStaticMethodInSubInterface() throws Exception { final CtInterface<?> ctInterface = (CtInterface<?>) factory.Type().get(RedefinesStaticMethodInterface.class); assertEquals( "Sub interface must have only one method in its interface", 1, ctInterface.getMethods().size()); assertEquals( "Sub interface must have 6+12(from java.lang.Object) methods in its interface and its super interfaces", 18, ctInterface.getAllMethods().size()); final CtMethod<?> getZoneIdMethod = ctInterface.getMethodsByName("getZoneId").get(0); assertFalse( "Method in the sub interface mustn't be a static method", getZoneIdMethod.getModifiers().contains(ModifierKind.STATIC)); assertEquals( "Interface of the static method must be the sub interface", RedefinesStaticMethodInterface.class, getZoneIdMethod.getDeclaringType().getActualClass()); }
@Test public void testRedefinesDefaultMethodInSubInterface() throws Exception { final CtInterface<?> ctInterface = (CtInterface<?>) factory.Type().get(RedefinesDefaultMethodInterface.class); assertEquals( "Sub interface must have only one method in its interface", 1, ctInterface.getMethods().size()); assertEquals( "Sub interface must have 6+12(from java.lang.Object) methods in its interface and its super interfaces", 18, ctInterface.getAllMethods().size()); final CtMethod<?> getZonedDateTimeMethod = ctInterface.getMethodsByName("getZonedDateTime").get(0); assertFalse( "Method in the sub interface mustn't be a default method", getZonedDateTimeMethod.isDefaultMethod()); assertEquals( "Interface of the default method must be the sub interface", RedefinesDefaultMethodInterface.class, getZonedDateTimeMethod.getDeclaringType().getActualClass()); }