AffectedBehaviorLocator { CtMethod getAffectedMethod(ContractInfo contractInfo, CtClass affectedClass, CtBehavior contractBehavior) throws NotFoundException, CannotCompileException { CtMethod affectedMethod = getAffectedMethodFromExtendedClasses(contractBehavior, affectedClass); if (affectedMethod == null) { LOGGER.warn("could not find a matching method in affected class " + affectedClass.getName() + " for method '" + contractBehavior.getName() + "' in contract class " + contractInfo.getContractClass().getName()); return null; } if (affectedMethod.getDeclaringClass().equals(affectedClass)) { return affectedMethod; } if (hasContract(affectedMethod.getDeclaringClass(), contractInfo)) { return null; } return getAffectedMethodAsDelegate(affectedClass, contractBehavior, affectedMethod); }  CtMethod getContractMethod(ContractInfo contract, CtMethod affectedMethod); CtBehavior getAffectedBehavior(ContractInfo contractInfo, CtClass affectedClass, CtBehavior contractBehavior);  }
@Test public void testGetAffectedMethodForOtherMethod() throws Exception { assertNull(locator.getAffectedMethod(contractInfo, targetClass, contractClass.getDeclaredMethod("otherMethod"))); }
@Test public void testGetAffectedMethodForContractMethod() throws Exception { assertEquals(targetClass.getDeclaredMethod("contractMethod"), locator.getAffectedMethod(contractInfo, targetClass, contractClass.getDeclaredMethod("contractMethod"))); }
@Test public void testGetAffectedMethodForIndirectContractMethod() throws Exception { RootTransformer.INSTANCE.init(); CtMethod affectedMethod = locator.getAffectedMethod(contractInfo, indirectClass, contractClass .getDeclaredMethod("contractMethod")); assertEquals(indirectClass.getDeclaredMethod("contractMethod"), affectedMethod); }