AffectedBehaviorLocator { public CtBehavior getAffectedBehavior(ContractInfo contractInfo, CtClass affectedClass, CtBehavior contractBehavior) throws NotFoundException, CannotCompileException { if (isClassInvariant(contractBehavior) || isBeforeInvariantHelperMethod(contractBehavior)) { return null; } if (isContractConstructor(contractBehavior)) { return getAffectedConstructor(contractInfo, affectedClass, contractBehavior); } if (isContractClassInitializer(contractBehavior)) { return affectedClass.getClassInitializer(); } if (contractBehavior instanceof CtMethod) { return getAffectedMethod(contractInfo, affectedClass, contractBehavior); } throw new NotFoundException("contractBehavior " + contractBehavior.getLongName() + " is neither constructor nor method"); }  CtMethod getContractMethod(ContractInfo contract, CtMethod affectedMethod); CtBehavior getAffectedBehavior(ContractInfo contractInfo, CtClass affectedClass, CtBehavior contractBehavior);  }
@Test public void testGetAffectedBehaviorForClassInvariant() throws Exception { assertNull(locator.getAffectedBehavior(null, null, contractClass.getDeclaredMethod("invariant"))); }
@Test(expected = NotFoundException.class) public void testGetAffectedBehaviorForNonMethodOrConstructor() throws Exception { CtBehavior contractBehavior = mock(CtBehavior.class); when(contractBehavior.getName()).thenReturn("contractBehavior"); locator.getAffectedBehavior(null, null, contractBehavior); }