public class ExpectedExceptionGenerator extends TestCheckGenerator
TestCheckGenerator
that generates checks for exceptions that are expected at the final
statement of a sequence. Creates a ExpectedExceptionCheck
that is returned in a RegressionChecks
collection if the exception occurs, or a ErrorRevealingChecks
collection if not.
Note that this generator is distinct from other check generators that either return regression checks or error-revealing checks.
Modifier and Type | Field and Description |
---|---|
private java.util.List<java.util.List<ThrowsClause>> |
exceptionSets
The list of lists of throws clauses for which the guard expression was satisfied.
|
Constructor and Description |
---|
ExpectedExceptionGenerator(java.util.List<java.util.List<ThrowsClause>> exceptionSets)
Creates an
ExpectedExceptionGenerator for the list of sets of expected exceptions. |
Modifier and Type | Method and Description |
---|---|
private static ClassOrInterfaceType |
findMatchingExpectedType(ClassOrInterfaceType throwableType,
java.util.List<ThrowsClause> throwsClauses)
Find the first ThrowsClause whose exception is a supertype of (or equal to)
throwableType , and return that exception type. |
TestChecks<?> |
generateTestChecks(ExecutableSequence eseq)
Generate a
TestChecks object for the executed sequence eseq based on the
criteria of this generator. |
java.util.List<java.util.List<ThrowsClause>> |
getExpected()
Returns the types of the expected exceptions.
|
private ErrorRevealingChecks |
getMissingExceptionTestChecks(int finalIndex)
Return an ErrorRevealingChecks that checks for a missing exception at the given index.
|
hasGenerator
private final java.util.List<java.util.List<ThrowsClause>> exceptionSets
public ExpectedExceptionGenerator(java.util.List<java.util.List<ThrowsClause>> exceptionSets)
ExpectedExceptionGenerator
for the list of sets of expected exceptions.exceptionSets
- a list of lists of expected exceptions to be searched when testing an
exception thrown by the operation in the final statement of the sequence. Each list of
expected exceptions must be satisfied.public TestChecks<?> generateTestChecks(ExecutableSequence eseq)
TestChecks
object for the executed sequence eseq
based on the
criteria of this generator.
Adds checks for an expected exception at the final statement of the sequence.
generateTestChecks
in class TestCheckGenerator
eseq
- the sequence for which checks are generatedprivate static ClassOrInterfaceType findMatchingExpectedType(ClassOrInterfaceType throwableType, java.util.List<ThrowsClause> throwsClauses)
throwableType
, and return that exception type.throwableType
- the type to search forthrowsClauses
- the ThrowsClause
s to search withinThrowsClause
, or null if none matchprivate ErrorRevealingChecks getMissingExceptionTestChecks(int finalIndex)
finalIndex
- the indexpublic java.util.List<java.util.List<ThrowsClause>> getExpected()