Skip to content

Commit 527c349

Browse files
committed
Updating tests with TypeValidator validation options
1 parent b9b66c8 commit 527c349

12 files changed

+85
-78
lines changed

src/test/kotlin/org/openrewrite/java/testing/assertj/JUnitAssertArrayEqualsToAssertThatTest.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import org.openrewrite.Parser
2020
import org.openrewrite.Recipe
2121
import org.openrewrite.java.JavaParser
2222
import org.openrewrite.java.JavaRecipeTest
23+
import org.openrewrite.java.TypeValidator
2324
import org.openrewrite.java.tree.J
2425

2526
class JUnitAssertArrayEqualsToAssertThatTest : JavaRecipeTest {
@@ -102,7 +103,7 @@ class JUnitAssertArrayEqualsToAssertThatTest : JavaRecipeTest {
102103
}
103104
}
104105
""",
105-
skipEnhancedTypeValidation = true
106+
typeValidation = { methodInvocations = false; }
106107
)
107108

108109
@Test
@@ -179,7 +180,7 @@ class JUnitAssertArrayEqualsToAssertThatTest : JavaRecipeTest {
179180
}
180181
}
181182
""",
182-
skipEnhancedTypeValidation = true
183+
typeValidation = { methodInvocations = false; }
183184
)
184185

185186
@Test
@@ -216,7 +217,7 @@ class JUnitAssertArrayEqualsToAssertThatTest : JavaRecipeTest {
216217
}
217218
}
218219
""",
219-
skipEnhancedTypeValidation = true
220+
typeValidation = { methodInvocations = false; }
220221
)
221222

222223
@Test
@@ -291,7 +292,7 @@ class JUnitAssertArrayEqualsToAssertThatTest : JavaRecipeTest {
291292
}
292293
}
293294
""",
294-
skipEnhancedTypeValidation = true
295+
typeValidation = { methodInvocations = false; }
295296
)
296297

297298
@Test
@@ -328,6 +329,6 @@ class JUnitAssertArrayEqualsToAssertThatTest : JavaRecipeTest {
328329
}
329330
}
330331
""",
331-
skipEnhancedTypeValidation = true
332+
typeValidation = { methodInvocations = false; }
332333
)
333334
}

src/test/kotlin/org/openrewrite/java/testing/assertj/JUnitAssertEqualsToAssertThatTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class JUnitAssertEqualsToAssertThatTest : JavaRecipeTest {
174174
}
175175
}
176176
""",
177-
skipEnhancedTypeValidation = true
177+
typeValidation = { methodInvocations = false; }
178178
)
179179

180180
@Test
@@ -212,7 +212,7 @@ class JUnitAssertEqualsToAssertThatTest : JavaRecipeTest {
212212
}
213213
}
214214
""",
215-
skipEnhancedTypeValidation = true
215+
typeValidation = { methodInvocations = false; }
216216
)
217217

218218
@Test
@@ -287,7 +287,7 @@ class JUnitAssertEqualsToAssertThatTest : JavaRecipeTest {
287287
}
288288
}
289289
""",
290-
skipEnhancedTypeValidation = true
290+
typeValidation = { methodInvocations = false; }
291291
)
292292

293293
@Test
@@ -324,6 +324,6 @@ class JUnitAssertEqualsToAssertThatTest : JavaRecipeTest {
324324
}
325325
}
326326
""",
327-
skipEnhancedTypeValidation = true
327+
typeValidation = { methodInvocations = false; }
328328
)
329329
}

src/test/kotlin/org/openrewrite/java/testing/assertj/JUnitAssertFalseToAssertThatTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class JUnitAssertFalseToAssertThatTest : JavaRecipeTest {
100100
}
101101
}
102102
""",
103-
skipEnhancedTypeValidation = true
103+
typeValidation = { methodInvocations = false; }
104104
)
105105

106106
@Test
@@ -137,7 +137,7 @@ class JUnitAssertFalseToAssertThatTest : JavaRecipeTest {
137137
}
138138
}
139139
""",
140-
skipEnhancedTypeValidation = true
140+
typeValidation = { methodInvocations = false; }
141141
)
142142

143143
@Test
@@ -176,7 +176,7 @@ class JUnitAssertFalseToAssertThatTest : JavaRecipeTest {
176176
}
177177
}
178178
""",
179-
skipEnhancedTypeValidation = true
179+
typeValidation = { methodInvocations = false; }
180180
)
181181

182182
@Test
@@ -218,7 +218,7 @@ class JUnitAssertFalseToAssertThatTest : JavaRecipeTest {
218218
}
219219
}
220220
""",
221-
skipEnhancedTypeValidation = true
221+
typeValidation = { methodInvocations = false; }
222222
)
223223

224224
@Test
@@ -266,6 +266,6 @@ class JUnitAssertFalseToAssertThatTest : JavaRecipeTest {
266266
}
267267
}
268268
""",
269-
skipEnhancedTypeValidation = true
269+
typeValidation = { methodInvocations = false; }
270270
)
271271
}

src/test/kotlin/org/openrewrite/java/testing/assertj/JUnitAssertNotEqualsToAssertThatTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class JUnitAssertNotEqualsToAssertThatTest : JavaRecipeTest {
174174
}
175175
}
176176
""",
177-
skipEnhancedTypeValidation = true
177+
typeValidation = { methodInvocations = false; }
178178
)
179179

180180
@Test
@@ -212,7 +212,7 @@ class JUnitAssertNotEqualsToAssertThatTest : JavaRecipeTest {
212212
}
213213
}
214214
""",
215-
skipEnhancedTypeValidation = true
215+
typeValidation = { methodInvocations = false; }
216216
)
217217

218218
@Test
@@ -287,7 +287,7 @@ class JUnitAssertNotEqualsToAssertThatTest : JavaRecipeTest {
287287
}
288288
}
289289
""",
290-
skipEnhancedTypeValidation = true
290+
typeValidation = { methodInvocations = false; }
291291
)
292292

293293
@Test
@@ -324,6 +324,6 @@ class JUnitAssertNotEqualsToAssertThatTest : JavaRecipeTest {
324324
}
325325
}
326326
""",
327-
skipEnhancedTypeValidation = true
327+
typeValidation = { methodInvocations = false; }
328328
)
329329
}

src/test/kotlin/org/openrewrite/java/testing/assertj/JUnitAssertNotNullToAssertThatTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class JUnitAssertNotNullToAssertThatTest : JavaRecipeTest {
100100
}
101101
}
102102
""",
103-
skipEnhancedTypeValidation = true
103+
typeValidation = { methodInvocations = false; }
104104
)
105105

106106
@Test
@@ -175,7 +175,7 @@ class JUnitAssertNotNullToAssertThatTest : JavaRecipeTest {
175175
}
176176
}
177177
""",
178-
skipEnhancedTypeValidation = true
178+
typeValidation = { methodInvocations = false; }
179179
)
180180

181181
@Test
@@ -217,6 +217,6 @@ class JUnitAssertNotNullToAssertThatTest : JavaRecipeTest {
217217
}
218218
}
219219
""",
220-
skipEnhancedTypeValidation = true
220+
typeValidation = { methodInvocations = false; }
221221
)
222222
}

src/test/kotlin/org/openrewrite/java/testing/assertj/JUnitAssertNullToAssertThatTest.kt

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
package org.openrewrite.java.testing.assertj
1717

1818
import org.junit.jupiter.api.Test
19-
import org.openrewrite.Parser
2019
import org.openrewrite.Recipe
2120
import org.openrewrite.java.JavaParser
2221
import org.openrewrite.java.JavaRecipeTest
23-
import org.openrewrite.java.tree.J
22+
import org.openrewrite.java.TypeValidator
2423

2524
class JUnitAssertNullToAssertThatTest : JavaRecipeTest {
2625
override val parser: JavaParser = JavaParser.fromJavaVersion()
@@ -67,41 +66,43 @@ class JUnitAssertNullToAssertThatTest : JavaRecipeTest {
6766
)
6867

6968
@Test
70-
fun singleStaticMethodWithMessageString() = assertChanged(
71-
before = """
72-
import org.junit.Test;
73-
74-
import static org.junit.jupiter.api.Assertions.assertNull;
75-
76-
public class A {
77-
78-
@Test
79-
public void test() {
80-
assertNull(notification(), "Should be null");
81-
}
82-
private String notification() {
83-
return null;
84-
}
85-
}
86-
""",
87-
after = """
88-
import org.junit.Test;
89-
90-
import static org.assertj.core.api.Assertions.assertThat;
91-
92-
public class A {
93-
94-
@Test
95-
public void test() {
96-
assertThat(notification()).as("Should be null").isNull();
97-
}
98-
private String notification() {
99-
return null;
100-
}
101-
}
102-
""",
103-
skipEnhancedTypeValidation = true
104-
)
69+
fun singleStaticMethodWithMessageString() {
70+
assertChanged(
71+
before = """
72+
import org.junit.Test;
73+
74+
import static org.junit.jupiter.api.Assertions.assertNull;
75+
76+
public class A {
77+
78+
@Test
79+
public void test() {
80+
assertNull(notification(), "Should be null");
81+
}
82+
private String notification() {
83+
return null;
84+
}
85+
}
86+
""",
87+
after = """
88+
import org.junit.Test;
89+
90+
import static org.assertj.core.api.Assertions.assertThat;
91+
92+
public class A {
93+
94+
@Test
95+
public void test() {
96+
assertThat(notification()).as("Should be null").isNull();
97+
}
98+
private String notification() {
99+
return null;
100+
}
101+
}
102+
""",
103+
typeValidation = { methodInvocations = false; }
104+
)
105+
}
105106

106107
@Test
107108
fun singleStaticMethodWithMessageSupplier() = assertChanged(
@@ -175,7 +176,7 @@ class JUnitAssertNullToAssertThatTest : JavaRecipeTest {
175176
}
176177
}
177178
""",
178-
skipEnhancedTypeValidation = true
179+
typeValidation = { methodInvocations = false; }
179180
)
180181

181182
@Test
@@ -217,6 +218,6 @@ class JUnitAssertNullToAssertThatTest : JavaRecipeTest {
217218
}
218219
}
219220
""",
220-
skipEnhancedTypeValidation = true
221+
typeValidation = { methodInvocations = false; }
221222
)
222223
}

src/test/kotlin/org/openrewrite/java/testing/assertj/JUnitAssertSameToAssertThatTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class JUnitAssertSameToAssertThatTest : JavaRecipeTest {
104104
}
105105
}
106106
""",
107-
skipEnhancedTypeValidation = true
107+
typeValidation = { methodInvocations = false; }
108108
)
109109

110110
@Test
@@ -183,7 +183,7 @@ class JUnitAssertSameToAssertThatTest : JavaRecipeTest {
183183
}
184184
}
185185
""",
186-
skipEnhancedTypeValidation = true
186+
typeValidation = { methodInvocations = false; }
187187
)
188188

189189
@Test
@@ -227,6 +227,6 @@ class JUnitAssertSameToAssertThatTest : JavaRecipeTest {
227227
}
228228
}
229229
""",
230-
skipEnhancedTypeValidation = true
230+
typeValidation = { methodInvocations = false; }
231231
)
232232
}

src/test/kotlin/org/openrewrite/java/testing/assertj/JUnitAssertTrueToAssertThatTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class JUnitAssertTrueToAssertThatTest : JavaRecipeTest {
100100
}
101101
}
102102
""",
103-
skipEnhancedTypeValidation = true
103+
typeValidation = { methodInvocations = false; }
104104
)
105105

106106
@Test
@@ -137,7 +137,7 @@ class JUnitAssertTrueToAssertThatTest : JavaRecipeTest {
137137
}
138138
}
139139
""",
140-
skipEnhancedTypeValidation = true
140+
typeValidation = { methodInvocations = false; }
141141
)
142142

143143
@Test
@@ -176,7 +176,7 @@ class JUnitAssertTrueToAssertThatTest : JavaRecipeTest {
176176
}
177177
}
178178
""",
179-
skipEnhancedTypeValidation = true
179+
typeValidation = { methodInvocations = false; }
180180
)
181181

182182
@Test
@@ -218,7 +218,7 @@ class JUnitAssertTrueToAssertThatTest : JavaRecipeTest {
218218
}
219219
}
220220
""",
221-
skipEnhancedTypeValidation = true
221+
typeValidation = { methodInvocations = false; }
222222
)
223223

224224
@Test
@@ -268,7 +268,7 @@ class JUnitAssertTrueToAssertThatTest : JavaRecipeTest {
268268
}
269269
}
270270
""",
271-
skipEnhancedTypeValidation = true
271+
typeValidation = { methodInvocations = false; }
272272
)
273273

274274
}

src/test/kotlin/org/openrewrite/java/testing/junit5/CategoryToTagTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ class CategoryToTagTest : JavaRecipeTest {
160160
public class B {
161161
162162
}
163-
"""
163+
""",
164+
typeValidation = { identifiers = false; }
164165
)
165166

166167
@Test

src/test/kotlin/org/openrewrite/java/testing/junit5/JUnit5BestPracticesTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class JUnit5BestPracticesTest : JavaRecipeTest {
138138
139139
@Disabled("not ready yet") @Test public void somethingElse() {}
140140
}
141-
"""
141+
""",
142+
typeValidation = { identifiers = false; }
142143
)
143144
}

0 commit comments

Comments
 (0)