Class AssertStatementCreationUtility
java.lang.Object
org.apache.groovy.contracts.generation.AssertStatementCreationUtility
Central place to create
AssertStatement
instances in groovy-contracts.
Utilized to centralize AssertionError
message generation.- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Replaces a givenReturnStatement
with the appropriate assertion call statement and returns a result variable expression.static class
Replaces a givenReturnStatement
with the appropriate assertion call statement and returns a result variable expression.static class
Collects allReturnStatement
instances from a given code block. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addAssertionCallStatementToReturnStatement
(BlockStatement statement, ReturnStatement returnStatement, Statement assertionCallStatement) static AssertStatement
getAssertionStatement
(BooleanExpression booleanExpression) Reusable method for creating assert statements for the given booleanExpression.static BlockStatement
getAssertionStatements
(List<BooleanExpression> booleanExpressions) Reusable method for creating assert statements for the given booleanExpression.static List<ReturnStatement>
getReturnStatements
(MethodNode method) Gets a list ofReturnStatement
instances from the givenMethodNode
.static void
injectResultVariableReturnStatementAndAssertionCallStatement
(BlockStatement statement, ClassNode returnType, ReturnStatement returnStatement, BlockStatement assertionCallStatement)
-
Constructor Details
-
AssertStatementCreationUtility
public AssertStatementCreationUtility()
-
-
Method Details
-
getAssertionStatements
Reusable method for creating assert statements for the given booleanExpression.- Parameters:
booleanExpressions
- the assertion'sBooleanExpression
instances- Returns:
- a newly created
AssertStatement
-
getAssertionStatement
Reusable method for creating assert statements for the given booleanExpression.- Parameters:
booleanExpression
- the assertion'sBooleanExpression
- Returns:
- a newly created
AssertStatement
-
getReturnStatements
Gets a list ofReturnStatement
instances from the givenMethodNode
.- Parameters:
method
- theMethodNode
that holds the given lastStatement- Returns:
- a
ReturnStatement
or null
-
injectResultVariableReturnStatementAndAssertionCallStatement
public static void injectResultVariableReturnStatementAndAssertionCallStatement(BlockStatement statement, ClassNode returnType, ReturnStatement returnStatement, BlockStatement assertionCallStatement) -
addAssertionCallStatementToReturnStatement
public static void addAssertionCallStatementToReturnStatement(BlockStatement statement, ReturnStatement returnStatement, Statement assertionCallStatement)
-