Skip to content

Commit

Permalink
Prevent class cast exception with assertThat argument
Browse files Browse the repository at this point in the history
Fixes #400
  • Loading branch information
timtebeek committed Sep 13, 2023
1 parent 2fdde47 commit 24742fb
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ private J.MethodInvocation simplifyMultipleAssertions(J.MethodInvocation m, Exec
return m;
}

J.MethodInvocation assertThatArg = (J.MethodInvocation) ((J.MethodInvocation) select).getArguments().get(0);
if (!(assertThatArg instanceof J.MethodInvocation)) {
Expression assertThatArgumentExpr = ((J.MethodInvocation) select).getArguments().get(0);
if (!(assertThatArgumentExpr instanceof J.MethodInvocation)) {
return m;
}
J.MethodInvocation assertThatArg = (J.MethodInvocation) assertThatArgumentExpr;

if (isZero(isEqualToArg) && checkIfRelatedToDuration(assertThatArg)) {
String formatted_template = formatTemplate("assertThat(#{any()}).%s();", m.getSimpleName(), asDescription);
Expand Down

0 comments on commit 24742fb

Please sign in to comment.