Skip to content

Commit

Permalink
Bugfix/multiple curly braces in one verification block (#603)
Browse files Browse the repository at this point in the history
* process multiple curly braces blocks in one Verification

* Apply formatter

---------

Co-authored-by: Sheng Yu <[email protected]>
Co-authored-by: Tim te Beek <[email protected]>
  • Loading branch information
3 people authored Sep 16, 2024
1 parent 251f882 commit a8e9320
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ static Optional<JMockitBlockType> getJMockitBlock(Statement s) {
J.Identifier clazz = (J.Identifier) nc.getClazz();

// JMockit block should be composed of a block within another block
if (nc.getBody() == null || (nc.getBody().getStatements().size() != 1 &&
!TypeUtils.isAssignableTo("mockit.Expectations", clazz.getType()))) {
if (nc.getBody() == null ||
(nc.getBody().getStatements().size() != 1 &&
!TypeUtils.isAssignableTo("mockit.Expectations", clazz.getType()) &&
!TypeUtils.isAssignableTo("mockit.Verifications", clazz.getType()))) {
return empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ J.Block rewriteMethodBody() {

// Account for Expectations which may contain multiple blocks
List<Statement> statementList = new ArrayList<>();
if (TypeUtils.isAssignableTo("mockit.Expectations", nc.getType())) {
if (TypeUtils.isAssignableTo("mockit.Expectations", nc.getType()) ||
TypeUtils.isAssignableTo("mockit.Verifications", nc.getType())) {
statementList.addAll(nc.getBody().getStatements());
} else {
statementList.add(expectationsBlock);
Expand Down
Loading

0 comments on commit a8e9320

Please sign in to comment.