Skip to content

Commit

Permalink
Verify that field accesses are not collapsed incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Dec 15, 2024
1 parent 46fc2dd commit 1ac86cf
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
import org.openrewrite.test.SourceSpec;

import static org.openrewrite.java.Assertions.java;

Expand Down Expand Up @@ -317,4 +318,46 @@ void b(Node node) {
)
);
}

@Test
void ignoreDifferentFieldAccess() {
//language=java
rewriteRun(
java(
"""
class ABC {
Object a, b, c;
}
""",
SourceSpec::skip
),
java(
"""
import static org.assertj.core.api.Assertions.assertThat;
class MyTest {
void test(ABC abc) {
assertThat(abc.a).isNotNull();
assertThat(abc.b).isNotNull();
assertThat(abc.c).isNotNull();
assertThat(abc.c).isNotNull();
}
}
""",
"""
import static org.assertj.core.api.Assertions.assertThat;
class MyTest {
void test(ABC abc) {
assertThat(abc.a).isNotNull();
assertThat(abc.b).isNotNull();
assertThat(abc.c)
.isNotNull()
.isNotNull();
}
}
"""
)
);
}
}

0 comments on commit 1ac86cf

Please sign in to comment.