Skip to content

Commit 713fb1c

Browse files
committed
Update dependency handling
1 parent c962c90 commit 713fb1c

File tree

6 files changed

+24
-153
lines changed

6 files changed

+24
-153
lines changed

src/main/resources/META-INF/rewrite/assertj.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,4 @@ recipeList:
6363
groupId: org.assertj
6464
artifactId: assertj-core
6565
version: 3.x
66-
scope: test
67-
onlyIfUsing:
68-
- org.assertj.core.api.Assertions
66+
onlyIfUsing: org.assertj.core.api.Assertions

src/main/resources/META-INF/rewrite/hamcrest.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,4 @@ recipeList:
2727
groupId: org.hamcrest
2828
artifactId: hamcrest
2929
version: 2.x
30-
scope: test
31-
onlyIfUsing:
32-
- org.hamcrest.Matchers
30+
onlyIfUsing: org.hamcrest.Matchers

src/main/resources/META-INF/rewrite/junit5.yml

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -81,33 +81,27 @@ recipeList:
8181
- org.openrewrite.maven.RemoveDependency:
8282
groupId: junit
8383
artifactId: junit
84-
# - org.openrewrite.maven.ExcludeDependency:
85-
# groupId: org.junit.vintage
86-
# artifactId: junit-vintage-engine
87-
# - org.openrewrite.maven.ExcludeDependency:
88-
# groupId: junit
89-
# artifactId: junit
90-
# - org.openrewrite.maven.AddDependency:
91-
# groupId: org.junit.jupiter
92-
# artifactId: junit-jupiter-api
93-
# version: 5.x
94-
# scope: test
95-
# onlyIfUsing:
96-
# - org.junit.jupiter.api.Test
97-
# - org.openrewrite.maven.AddDependency:
98-
# groupId: org.junit.jupiter
99-
# artifactId: junit-jupiter-engine
100-
# version: 5.x
101-
# scope: test
102-
# onlyIfUsing:
103-
# - org.junit.jupiter.api.Test
104-
# - org.openrewrite.maven.AddDependency:
105-
# groupId: org.junit.jupiter
106-
# artifactId: junit-jupiter-params
107-
# version: 5.x
108-
# scope: test
109-
# onlyIfUsing:
110-
# - org.junit.jupiter.params.ParameterizedTest
84+
- org.openrewrite.maven.ExcludeDependency:
85+
groupId: org.junit.vintage
86+
artifactId: junit-vintage-engine
87+
- org.openrewrite.maven.ExcludeDependency:
88+
groupId: junit
89+
artifactId: junit
90+
- org.openrewrite.maven.AddDependency:
91+
groupId: org.junit.jupiter
92+
artifactId: junit-jupiter-api
93+
version: 5.x
94+
onlyIfUsing: org.junit.jupiter.api.Test
95+
- org.openrewrite.maven.AddDependency:
96+
groupId: org.junit.jupiter
97+
artifactId: junit-jupiter-engine
98+
version: 5.x
99+
onlyIfUsing: org.junit.jupiter.api.Test
100+
- org.openrewrite.maven.AddDependency:
101+
groupId: org.junit.jupiter
102+
artifactId: junit-jupiter-params
103+
version: 5.x
104+
onlyIfUsing: org.junit.jupiter.params.ParameterizedTest
111105

112106
---
113107
type: specs.openrewrite.org/v1beta/recipe

src/main/resources/META-INF/rewrite/mockito.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,4 @@ recipeList:
4343
groupId: org.mockito
4444
artifactId: mockito-junit-jupiter
4545
version: 3.x
46-
scope: test
47-
onlyIfUsing:
48-
- org.mockito.junit.jupiter.MockitoExtension
46+
onlyIfUsing: org.mockito.junit.jupiter.MockitoExtension

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ package org.openrewrite.java.testing.junit5
1818
import org.junit.jupiter.api.Disabled
1919
import org.junit.jupiter.api.Test
2020
import org.openrewrite.Issue
21-
import org.openrewrite.Parser
2221
import org.openrewrite.Recipe
2322
import org.openrewrite.java.JavaParser
2423
import org.openrewrite.java.JavaRecipeTest
25-
import org.openrewrite.java.tree.J
2624

2725
class UpdateTestAnnotationTest : JavaRecipeTest {
2826
override val parser: JavaParser = JavaParser.fromJavaVersion()

src/test/kotlin/org/openrewrite/java/testing/mockito/JunitMockitoUpgradeIntegrationTest.kt

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -262,119 +262,4 @@ class JunitMockitoUpgradeIntegrationTest : JavaRecipeTest {
262262
public class ExampleTest { }
263263
"""
264264
)
265-
266-
@Test
267-
@Disabled("Temporarily disable this test")
268-
fun junitJupiterMavenDependenciesAreUpdated() {
269-
val javaSource = parser.parse("""
270-
package org.openrewrite.java.testing.junit5;
271-
272-
import org.junit.jupiter.api.*;
273-
274-
import java.util.List;
275-
276-
import static org.mockito.Mockito.*;
277-
278-
public class ExampleJunitTestClass {
279-
280-
@Mock
281-
List<String> mockedList;
282-
283-
public void initMocks() {
284-
MockitoAnnotations.initMocks(this);
285-
}
286-
287-
@Test
288-
void usingAnnotationBasedMock() {
289-
mockedList.add("one");
290-
mockedList.clear();
291-
verify(mockedList).add("one");
292-
verify(mockedList).clear();
293-
}
294-
}
295-
""".trimIndent())[0]
296-
val mavenSource = MavenParser.builder().build().parse(
297-
"""
298-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
299-
<modelVersion>4.0.0</modelVersion>
300-
301-
<groupId>org.openrewrite.example</groupId>
302-
<artifactId>integration-testing</artifactId>
303-
<version>1.0</version>
304-
<name>integration-testing</name>
305-
306-
<properties>
307-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
308-
<java.version>1.8</java.version>
309-
</properties>
310-
311-
<dependencies>
312-
<dependency>
313-
<groupId>junit</groupId>
314-
<artifactId>junit</artifactId>
315-
<version>4.12</version>
316-
<scope>test</scope>
317-
</dependency>
318-
<dependency>
319-
<groupId>com.googlecode.json-simple</groupId>
320-
<artifactId>json-simple</artifactId>
321-
<version>1.1.1</version>
322-
</dependency>
323-
</dependencies>
324-
</project>
325-
""".trimIndent()
326-
)[0]
327-
328-
val sources: List<SourceFile> = listOf(javaSource, mavenSource)
329-
330-
val results = recipe.run(sources, InMemoryExecutionContext { error: Throwable -> throw error })
331-
332-
val mavenResult = results.find { it.before === mavenSource }
333-
assertThat(mavenResult).isNotNull
334-
335-
assertThat(mavenResult?.after?.print()).isEqualTo(
336-
"""
337-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
338-
<modelVersion>4.0.0</modelVersion>
339-
340-
<groupId>org.openrewrite.example</groupId>
341-
<artifactId>integration-testing</artifactId>
342-
<version>1.0</version>
343-
<name>integration-testing</name>
344-
345-
<properties>
346-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
347-
<java.version>1.8</java.version>
348-
</properties>
349-
350-
<dependencies>
351-
<dependency>
352-
<groupId>com.googlecode.json-simple</groupId>
353-
<artifactId>json-simple</artifactId>
354-
<version>1.1.1</version>
355-
<exclusions>
356-
<exclusion>
357-
<groupId>junit</groupId>
358-
<artifactId>junit</artifactId>
359-
</exclusion>
360-
</exclusions>
361-
</dependency>
362-
<dependency>
363-
<groupId>org.junit.jupiter</groupId>
364-
<artifactId>junit-jupiter-api</artifactId>
365-
<version>5.7.2</version>
366-
<scope>test</scope>
367-
</dependency>
368-
<dependency>
369-
<groupId>org.junit.jupiter</groupId>
370-
<artifactId>junit-jupiter-engine</artifactId>
371-
<version>5.7.2</version>
372-
<scope>test</scope>
373-
</dependency>
374-
</dependencies>
375-
</project>
376-
""".trimIndent()
377-
)
378-
}
379-
380265
}

0 commit comments

Comments
 (0)