What version of OpenRewrite are you using?
What is the smallest, simplest way to reproduce the problem?
import org.junit.jupiter.api.function.Executable;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class SimpleExpectedExceptionTest {
public void throwsExceptionWithSpecificType() {
Executable executable = () -> {
throw new NullPointerException();
};
assertThrows(NullPointerException.class, executable);
}
}
What did you expect to see?
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class SimpleExpectedExceptionTest {
public void throwsExceptionWithSpecificType() {
ThrowingCallable executable = () -> {
throw new NullPointerException();
};
assertThatExceptionOfType(NullPointerException.class).isThrownBy(executable);
}
}
What did you see instead?
No change, as the recipe fails to match the case where the argument is a variable.
|
J executable = mi.getArguments().get(1); |
|
if (executable instanceof J.Lambda) { |
|
executable = ((J.Lambda) executable).withType(THROWING_CALLABLE_TYPE); |
|
} else if (executable instanceof J.MemberReference) { |
|
executable = ((J.MemberReference) executable).withType(THROWING_CALLABLE_TYPE); |
|
} else { |
|
executable = null; |
Additional context
As reported on
What version of OpenRewrite are you using?
What is the smallest, simplest way to reproduce the problem?
What did you expect to see?
What did you see instead?
No change, as the recipe fails to match the case where the argument is a variable.
rewrite-testing-frameworks/src/main/java/org/openrewrite/java/testing/assertj/JUnitAssertThrowsToAssertExceptionType.java
Lines 68 to 74 in 7ba17bb
Additional context
As reported on