1616package org .openrewrite .java .testing .assertj ;
1717
1818
19+ import org .junit .jupiter .api .Disabled ;
1920import org .junit .jupiter .api .Test ;
2021import org .openrewrite .DocumentExample ;
2122import org .openrewrite .InMemoryExecutionContext ;
23+ import org .openrewrite .Issue ;
2224import org .openrewrite .config .Environment ;
2325import org .openrewrite .java .JavaParser ;
2426import org .openrewrite .test .RecipeSpec ;
@@ -41,7 +43,47 @@ public void defaults(RecipeSpec spec) {
4143
4244 @ DocumentExample
4345 @ Test
44- void useAssertionsStaticImport () {
46+ void useStaticImports () {
47+ //language=java
48+ rewriteRun (
49+ java (
50+ """
51+ import java.util.List;
52+ import org.assertj.core.api.Assertions;
53+ import static org.assertj.core.api.Fail.fail;
54+
55+ public class Test {
56+ List<String> exampleList;
57+ void method() {
58+ Assertions.assertThat(true).isTrue();
59+ Assertions.assertThat(exampleList).hasSize(0);
60+ fail("This is a failure");
61+ }
62+ }
63+ """ ,
64+ """
65+ import java.util.List;
66+
67+ import static org.assertj.core.api.Assertions.assertThat;
68+ import static org.assertj.core.api.Assertions.fail;
69+
70+ public class Test {
71+ List<String> exampleList;
72+ void method() {
73+ assertThat(true).isTrue();
74+ assertThat(exampleList).hasSize(0);
75+ fail("This is a failure");
76+ }
77+ }
78+ """
79+ )
80+ );
81+ }
82+
83+ @ Issue ("https://github.com/openrewrite/rewrite-testing-frameworks/issues/664" )
84+ @ Test
85+ @ Disabled ("Requires changes in AssertJ to adopt `assertThatClass` and `assertThatInterface`" )
86+ void assertionsForClassTypes () {
4587 //language=java
4688 rewriteRun (
4789 java (
@@ -51,7 +93,6 @@ void useAssertionsStaticImport() {
5193 import org.assertj.core.api.AssertionsForInterfaceTypes;
5294 import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
5395 import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
54- import static org.assertj.core.api.Fail.fail;
5596
5697 public class Test {
5798 List<String> exampleList;
@@ -60,15 +101,13 @@ void method() {
60101 AssertionsForClassTypes.assertThat(true).isTrue();
61102 assertThat(true).isTrue();
62103 assertThat(exampleList).hasSize(0);
63- fail("This is a failure");
64104 }
65105 }
66106 """ ,
67107 """
68108 import java.util.List;
69109
70110 import static org.assertj.core.api.Assertions.assertThat;
71- import static org.assertj.core.api.Assertions.fail;
72111
73112 public class Test {
74113 List<String> exampleList;
@@ -77,7 +116,6 @@ void method() {
77116 assertThat(true).isTrue();
78117 assertThat(true).isTrue();
79118 assertThat(exampleList).hasSize(0);
80- fail("This is a failure");
81119 }
82120 }
83121 """
0 commit comments