AfterBurner { public boolean checkIfMethodIsInvoked(CtMethod withinMethod, String invokedMethod) throws CannotCompileException { return new DetectMethodCallEditor(withinMethod, invokedMethod).checkIfisCallingMethod(); } AfterBurner(); void addOrInsertMethod(InsertableMethod insertableMethod); void beforeOverrideMethod(CtClass targetClass, String targetMethodName, String body); void afterOverrideMethod(CtClass targetClass, String targetMethodName, String body); void insertConstructor(InsertableConstructor insertableConstructor); CtMethod extractExistingMethod(final CtClass classToTransform,
            String methodName); boolean checkIfMethodIsInvoked(CtMethod withinMethod,
        String invokedMethod);  }
@Test public void testCheckIfMethodIsInvoked_whenItIsInvoked() throws Exception { target.addMethod(CtNewMethod.make("public void bar() { }", target)); CtMethod withinMethod = CtNewMethod.make("public void foo() { bar(); }", target); target.addMethod(withinMethod); boolean isInvoked = afterBurner.checkIfMethodIsInvoked(withinMethod, "bar"); assertTrue(isInvoked); }
@Test public void testCheckIfMethodIsInvoked_whenItIsNotInvoked() throws Exception { target.addMethod(CtNewMethod.make("public void bar() { }", target)); CtMethod withinMethod = CtNewMethod.make("public void foo() { }", target); target.addMethod(withinMethod); boolean isInvoked = afterBurner.checkIfMethodIsInvoked(withinMethod, "bar"); assertFalse(isInvoked); }