@Test public void testDoIt_calls_afterburner_with_after_override() throws CannotCompileException, AfterBurnerImpossibleException, NotFoundException { afterBurnerMock = EasyMock.createMock(AfterBurner.class); afterBurnerMock.addOrInsertMethod((InsertableMethod) EasyMock.anyObject()); EasyMock.replay(afterBurnerMock); signatureExtractorMock = EasyMock.createMock(CtMethodJavaWriter.class); EasyMock.expect(signatureExtractorMock.invokeSuper((CtMethod) EasyMock.anyObject())).andReturn("super.foo()"); EasyMock.expect(signatureExtractorMock.createJavaSignature((CtMethod) EasyMock.anyObject())).andReturn("public void foo()"); EasyMock.replay(signatureExtractorMock); CtClass targetClassAncestor = ClassPool.getDefault().makeClass( "TargetAncestor" + TestCounter.testCounter++); targetClassAncestor.addMethod(CtNewMethod.make("public void foo() { }", targetClassAncestor)); CtClass targetClass = ClassPool.getDefault().makeClass( "Target" + TestCounter.testCounter++); targetClass.setSuperclass(targetClassAncestor); targetClass.addMethod(CtNewMethod.make("public void foo() { super.foo(); }", targetClass)); builder = new InsertableMethodBuilder(afterBurnerMock, signatureExtractorMock); CtClass classToInsertInto = targetClass; String targetMethod = "foo"; String body = ""; builder .insertIntoClass(classToInsertInto) .afterOverrideMethod(targetMethod) .withBody(body) .doIt(); EasyMock.verify(afterBurnerMock); }
public StateTargetClassSet insertIntoClass(Class<?> clazzToInsertInto) throws NotFoundException { this.classToInsertInto = ClassPool.getDefault().get( clazzToInsertInto.getName()); return new StateTargetClassSet(); }
InsertableMethodBuilder { public StateTargetClassSet insertIntoClass(Class<?> clazzToInsertInto) throws NotFoundException { this.classToInsertInto = ClassPool.getDefault().get( clazzToInsertInto.getName()); return new StateTargetClassSet(); } }
InsertableMethodBuilder { public StateTargetClassSet insertIntoClass(Class<?> clazzToInsertInto) throws NotFoundException { this.classToInsertInto = ClassPool.getDefault().get( clazzToInsertInto.getName()); return new StateTargetClassSet(); } InsertableMethodBuilder(AfterBurner afterBurner);  InsertableMethodBuilder(AfterBurner afterBurner,
            CtMethodJavaWriter signatureExtractor); }
InsertableMethodBuilder { public StateTargetClassSet insertIntoClass(Class<?> clazzToInsertInto) throws NotFoundException { this.classToInsertInto = ClassPool.getDefault().get( clazzToInsertInto.getName()); return new StateTargetClassSet(); } InsertableMethodBuilder(AfterBurner afterBurner);  InsertableMethodBuilder(AfterBurner afterBurner,
            CtMethodJavaWriter signatureExtractor); StateTargetClassSet insertIntoClass(Class<?> clazzToInsertInto); StateTargetClassSet insertIntoClass(CtClass classToInsertInto); }
InsertableMethodBuilder { public StateTargetClassSet insertIntoClass(Class<?> clazzToInsertInto) throws NotFoundException { this.classToInsertInto = ClassPool.getDefault().get( clazzToInsertInto.getName()); return new StateTargetClassSet(); } InsertableMethodBuilder(AfterBurner afterBurner);  InsertableMethodBuilder(AfterBurner afterBurner,
            CtMethodJavaWriter signatureExtractor); StateTargetClassSet insertIntoClass(Class<?> clazzToInsertInto); StateTargetClassSet insertIntoClass(CtClass classToInsertInto);  }