Class AssertStatementCreationUtility
- java.lang.Object
-
- org.apache.groovy.contracts.generation.AssertStatementCreationUtility
-
public final class AssertStatementCreationUtility extends Object
Central place to createAssertStatementinstances in groovy-contracts. Utilized to centralizeAssertionErrormessage generation.- See Also:
AssertStatement,AssertionError
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAssertStatementCreationUtility.AddAssertionCallStatementToReturnStatementVisitorReplaces a givenReturnStatementwith the appropriate assertion call statement and returns a result variable expression.static classAssertStatementCreationUtility.AddResultReturnStatementVisitorReplaces a givenReturnStatementwith the appropriate assertion call statement and returns a result variable expression.static classAssertStatementCreationUtility.ReturnStatementVisitorCollects allReturnStatementinstances from a given code block.
-
Constructor Summary
Constructors Constructor Description AssertStatementCreationUtility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddAssertionCallStatementToReturnStatement(BlockStatement statement, ReturnStatement returnStatement, Statement assertionCallStatement)static AssertStatementgetAssertionStatement(BooleanExpression booleanExpression)Reusable method for creating assert statements for the given booleanExpression.static BlockStatementgetAssertionStatements(List<BooleanExpression> booleanExpressions)Reusable method for creating assert statements for the given booleanExpression.static List<ReturnStatement>getReturnStatements(MethodNode method)Gets a list ofReturnStatementinstances from the givenMethodNode.static voidinjectResultVariableReturnStatementAndAssertionCallStatement(BlockStatement statement, ClassNode returnType, ReturnStatement returnStatement, BlockStatement assertionCallStatement)
-
-
-
Method Detail
-
getAssertionStatements
public static BlockStatement getAssertionStatements(List<BooleanExpression> booleanExpressions)
Reusable method for creating assert statements for the given booleanExpression.- Parameters:
booleanExpressions- the assertion'sBooleanExpressioninstances- Returns:
- a newly created
AssertStatement
-
getAssertionStatement
public static AssertStatement getAssertionStatement(BooleanExpression booleanExpression)
Reusable method for creating assert statements for the given booleanExpression.- Parameters:
booleanExpression- the assertion'sBooleanExpression- Returns:
- a newly created
AssertStatement
-
getReturnStatements
public static List<ReturnStatement> getReturnStatements(MethodNode method)
Gets a list ofReturnStatementinstances from the givenMethodNode.- Parameters:
method- theMethodNodethat holds the given lastStatement- Returns:
- a
ReturnStatementor 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)
-
-