ExceptionalCheckBasedYield extends ExceptionalYield { @Override public void setExceptionType(String exceptionType) { throw new UnsupportedOperationException("Exception type can not be changed"); } ExceptionalCheckBasedYield(SymbolicValue svCausingException, String exceptionType, Class<? extends SECheck> check, Node node, MethodBehavior behavior); @Override Stream<ProgramState> statesAfterInvocation(List<SymbolicValue> invocationArguments, List<Type> invocationTypes, ProgramState programState,
    Supplier<SymbolicValue> svSupplier); @Override void setExceptionType(String exceptionType); @Nonnull @Override Type exceptionType(Sema semanticModel); Class<? extends SECheck> check(); @Override String toString(); @Override int hashCode(); @Override Set<Flow> flow(List<Integer> parameterIndices, List<Class<? extends Constraint>> domains, int maxReturnedFlows); Set<Flow> exceptionFlows(int maxReturnedFlows); @Override boolean equals(Object obj); @Override boolean generatedByCheck(SECheck check); int parameterCausingExceptionIndex();  }
@Test void exceptionType_cannot_be_changed() { final Class<? extends SECheck> seCheckClass = new SECheck() { }.getClass(); String exceptionType = "someException"; ExceptionalCheckBasedYield yield = new ExceptionalCheckBasedYield(SV_CAUSING_EXCEPTION, exceptionType, seCheckClass, null, mockMethodBehavior()); assertThrows(UnsupportedOperationException.class, () -> yield.setExceptionType("anotherException")); }
@Test void test_equals() { final Class<? extends SECheck> seCheckClass1 = new SECheck() { }.getClass(); final Class<? extends SECheck> seCheckClass2 = (new SECheck() { }).getClass(); MethodBehavior mb = mockMethodBehavior(); String mockedExceptionType1 = "SomeException"; ExceptionalCheckBasedYield yield = new ExceptionalCheckBasedYield(SV_CAUSING_EXCEPTION, mockedExceptionType1, seCheckClass1, null, mb); ExceptionalYield otherYield = new ExceptionalCheckBasedYield(SV_CAUSING_EXCEPTION, mockedExceptionType1, seCheckClass1, null, mb); assertThat(yield) .isNotEqualTo(null) .isNotEqualTo(new Object()) .isEqualTo(yield) .isEqualTo(otherYield); otherYield = new ExceptionalYield(null, mb); otherYield.setExceptionType(mockedExceptionType1); assertThat(yield).isNotEqualTo(otherYield); otherYield = new ExceptionalCheckBasedYield(new SymbolicValue(), mockedExceptionType1, seCheckClass2, null, mb); assertThat(yield).isNotEqualTo(otherYield); otherYield = new ExceptionalCheckBasedYield(SV_CAUSING_EXCEPTION, mockedExceptionType1, seCheckClass2, null, mb); assertThat(yield).isNotEqualTo(otherYield); otherYield = new ExceptionalCheckBasedYield(SV_CAUSING_EXCEPTION, "SomeOtherException", seCheckClass1, null, mb); assertThat(yield).isNotEqualTo(otherYield); }