Skip to content

Commit 8fb08ad

Browse files
committed
Update testing frameworks to use rewrite 7.0.0
1 parent d81615a commit 8fb08ad

File tree

6 files changed

+19
-29
lines changed

6 files changed

+19
-29
lines changed

lombok.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# https://projectlombok.org/features/configuration
2+
config.stopBubbling = true
3+
lombok.addNullAnnotations = CUSTOM:org.openrewrite.internal.lang.NonNull:org.openrewrite.internal.lang.Nullable
4+
lombok.copyableAnnotations += org.openrewrite.internal.lang.Nullable
5+
lombok.copyableAnnotations += org.openrewrite.internal.lang.NonNull
6+
lombok.anyConstructor.addConstructorProperties=true

src/before/java/org/openrewrite/java/testing/junit5/ExampleJunitTestClass.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,21 @@
1818
import org.junit.AfterClass;
1919
import org.junit.Assert;
2020
import org.junit.Before;
21-
import org.junit.BeforeClass;
2221
import org.junit.Rule;
2322
import org.junit.Test;
24-
import org.junit.Test;
25-
import org.junit.experimental.categories.Category;
2623
import org.junit.rules.ExpectedException;
2724
import org.junit.rules.TemporaryFolder;
28-
import org.junit.rules.Timeout;
29-
import org.junit.runner.RunWith;
3025
import org.mockito.Mock;
3126
import org.mockito.MockitoAnnotations;
32-
import org.mockito.runners.MockitoJUnit44Runner;
33-
import org.mockito.runners.MockitoJUnitRunner;
34-
import org.openrewrite.java.testing.statik.UnitTest;
3527

3628
import java.io.File;
3729
import java.io.IOException;
3830
import java.util.List;
3931

4032
import static org.mockito.Mockito.*;
4133

42-
@Category(UnitTest.class)
4334
public class ExampleJunitTestClass {
4435

45-
// @Rule
46-
// public Timeout globalTimeout = new Timeout(500);
47-
4836
@Rule
4937
public TemporaryFolder folder = new TemporaryFolder();
5038

@@ -115,10 +103,7 @@ public void bar() { }
115103

116104
@Test
117105
public void aTest() {
118-
List<Integer> foo = mock(List.class);
119-
120-
when(foo.get(any())).then(invocation -> invocation.getArgumentAt(0, Integer.class));
121-
int one = foo.get(1);
122-
Assert.assertEquals(1, one);
106+
String foo = mock(String.class);
107+
when(foo.concat(any())).then(invocation -> invocation.getArgumentAt(0, String.class));
123108
}
124109
}

src/integTest/kotlin/org/openrewrite/java/testing/RunOnMavenProjectOnDisk.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class RunOnMavenProjectOnDisk {
6868

6969
val mavenParserBuilder = MavenParser.builder()
7070
.cache(pomCache)
71-
.resolveOptional(false)
7271
.mavenConfig(projectDir.resolve(".mvn/maven.config"))
7372

7473
val parser = MavenProjectParser(

src/main/java/org/openrewrite/java/testing/junit5/CleanupJUnitImports.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.openrewrite.java.testing.junit5;
1717

18+
import lombok.Value;
1819
import org.openrewrite.Cursor;
1920
import org.openrewrite.ExecutionContext;
2021
import org.openrewrite.Recipe;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ recipeList:
7272
onlyIfUsing:
7373
- org.junit.jupiter.api.Test
7474
- org.openrewrite.java.testing.junit5.UseHamcrestAssertThat
75-
- org.openrewrite.java.tesitng.junit5.UseMockitoExtension
75+
- org.openrewrite.java.testing.junit5.UseMockitoExtension
7676
- org.openrewrite.java.testing.junit5.UseTestMethodOrder
7777
- org.openrewrite.java.testing.junit5.AssertToAssertions
7878
- org.openrewrite.java.testing.junit5.CategoryToTag

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@ import org.assertj.core.api.Assertions.assertThat
1919
import org.junit.jupiter.api.Disabled
2020
import org.junit.jupiter.api.Test
2121
import org.openrewrite.*
22+
import org.openrewrite.config.Environment
2223
import org.openrewrite.java.JavaParser
2324
import org.openrewrite.java.JavaRecipeTest
2425
import org.openrewrite.maven.MavenParser
2526

2627
/**
2728
* Validates the recipes related to upgrading from Mockito 1 to Mockito 3
2829
*/
29-
@Issue("https://github.com/openrewrite/rewrite/issues/343")
30-
@Disabled
3130
class JunitMockitoUpgradeIntegrationTest : JavaRecipeTest {
3231
override val parser: JavaParser = JavaParser.fromJavaVersion()
33-
.classpath("mockito-all", "junit", "hamcrest")
34-
.build()
32+
.logCompilationWarningsAndErrors(true)
33+
.classpath("mockito-all", "junit", "hamcrest")
34+
.build()
3535

36-
override val recipe: Recipe
37-
get() = loadRecipeFromClasspath("org.openrewrite.java.testing.JUnit5Migration",
36+
override val recipe: Recipe = Environment.builder()
37+
.scanClasspath(emptyList())
38+
.build()
39+
.activateRecipes("org.openrewrite.java.testing.junit5.JUnit4to5Migration",
3840
"org.openrewrite.java.testing.mockito.Mockito1to3Migration")
3941

4042
/**
@@ -342,10 +344,7 @@ class JunitMockitoUpgradeIntegrationTest : JavaRecipeTest {
342344
val exampleJunitAfter = """
343345
package org.openrewrite.java.testing.junit5;
344346
345-
import org.junit.jupiter.api.AfterAll;
346-
import org.junit.jupiter.api.Assertions;
347-
import org.junit.jupiter.api.BeforeEach;
348-
import org.junit.jupiter.api.Test;
347+
import org.junit.jupiter.api.*;
349348
import org.junit.jupiter.api.io.TempDir;
350349
import org.mockito.Mock;
351350
import org.mockito.MockitoAnnotations;

0 commit comments

Comments
 (0)