Skip to content

Commit 3018587

Browse files
authored
Suppress mutable execution context warnings for now (#668)
- Following openrewrite/rewrite#4879
1 parent 7c52792 commit 3018587

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

src/main/java/org/openrewrite/java/testing/hamcrest/RemoveNotMatcherVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation mi, Execution
6464
result = template.apply(getCursor(), mi.getCoordinates().replace(), mi.getArguments().get(0));
6565
}
6666

67-
ctx.putMessage(result.toString(), !logicalContext);
67+
ctx.putMessage(result.toString(), !logicalContext); // FIXME Do not store on the use execution context
6868

6969
return result;
7070
} else {
7171
if (ctx.pollMessage(mi.toString()) == null) {
72-
ctx.putMessage(mi.toString(), true);
72+
ctx.putMessage(mi.toString(), true); // FIXME Do not store on the use execution context
7373
}
7474
}
7575
return super.visitMethodInvocation(mi, ctx);

src/test/java/org/openrewrite/java/testing/hamcrest/HamcrestInstanceOfToJUnit5Test.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@
2323
import org.openrewrite.test.RewriteTest;
2424

2525
import static org.openrewrite.java.Assertions.java;
26+
import static org.openrewrite.test.TypeValidation.all;
2627

2728
class HamcrestInstanceOfToJUnit5Test implements RewriteTest {
2829
@Override
2930
public void defaults(RecipeSpec spec) {
3031
spec
3132
.parser(JavaParser.fromJavaVersion()
3233
.classpathFromResources(new InMemoryExecutionContext(), "junit-jupiter-api-5.9", "hamcrest-2.2"))
33-
.recipe(new HamcrestInstanceOfToJUnit5());
34+
.recipe(new HamcrestInstanceOfToJUnit5())
35+
.typeValidationOptions(all().immutableExecutionContext(false));
3436
}
3537

3638
@DocumentExample

src/test/java/org/openrewrite/java/testing/hamcrest/HamcrestMatcherToJUnit5Test.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.openrewrite.test.RewriteTest;
2424

2525
import static org.openrewrite.java.Assertions.java;
26+
import static org.openrewrite.test.TypeValidation.all;
2627

2728
class HamcrestMatcherToJUnit5Test implements RewriteTest {
2829
@Override
@@ -122,6 +123,7 @@ void testEquals() {
122123
void notEqualToString() {
123124
//language=java
124125
rewriteRun(
126+
spec -> spec.typeValidationOptions(all().immutableExecutionContext(false)),
125127
java(
126128
"""
127129
import org.junit.jupiter.api.Test;
@@ -464,6 +466,7 @@ void testNullValue() {
464466
void sameInstance() {
465467
//language=java
466468
rewriteRun(
469+
spec -> spec.typeValidationOptions(all().immutableExecutionContext(false)),
467470
java(
468471
"""
469472
import org.junit.jupiter.api.Test;

src/test/java/org/openrewrite/java/testing/hamcrest/MigrateHamcrestToJUnitTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.openrewrite.test.RewriteTest;
2424

2525
import static org.openrewrite.java.Assertions.java;
26+
import static org.openrewrite.test.TypeValidation.all;
2627

2728
class MigrateHamcrestToJUnitTest implements RewriteTest {
2829
@Override
@@ -38,6 +39,7 @@ public void defaults(RecipeSpec spec) {
3839
void equalToString() {
3940
//language=java
4041
rewriteRun(
42+
spec -> spec.typeValidationOptions(all().immutableExecutionContext(false)),
4143
java(
4244
"""
4345
import org.junit.jupiter.api.Test;

src/test/java/org/openrewrite/java/testing/hamcrest/RemoveNotMatcherTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@
2424

2525
import static org.openrewrite.java.Assertions.java;
2626
import static org.openrewrite.test.RewriteTest.toRecipe;
27+
import static org.openrewrite.test.TypeValidation.all;
2728

2829
class RemoveNotMatcherTest implements RewriteTest {
2930
@Override
3031
public void defaults(RecipeSpec spec) {
3132
spec
3233
.parser(JavaParser.fromJavaVersion()
3334
.classpathFromResources(new InMemoryExecutionContext(), "junit-jupiter-api-5.9", "hamcrest-2.2"))
34-
.recipe(toRecipe(RemoveNotMatcherVisitor::new));
35+
.recipe(toRecipe(RemoveNotMatcherVisitor::new))
36+
.typeValidationOptions(all().immutableExecutionContext(false));
3537
}
3638

3739
@DocumentExample
40+
@Test
3841
void nestedNotMatcher() {
3942
rewriteRun(
4043
//language=java

0 commit comments

Comments
 (0)