diff --git a/lombok.config b/lombok.config new file mode 100755 index 000000000..edd70b0ac --- /dev/null +++ b/lombok.config @@ -0,0 +1,6 @@ +# https://projectlombok.org/features/configuration +config.stopBubbling = true +lombok.addNullAnnotations = CUSTOM:org.openrewrite.internal.lang.NonNull:org.openrewrite.internal.lang.Nullable +lombok.copyableAnnotations += org.openrewrite.internal.lang.Nullable +lombok.copyableAnnotations += org.openrewrite.internal.lang.NonNull +lombok.anyConstructor.addConstructorProperties=true diff --git a/src/before/java/org/openrewrite/java/testing/junit5/ExampleJunitTestClass.java b/src/before/java/org/openrewrite/java/testing/junit5/ExampleJunitTestClass.java index 0258a7548..90d2f12f3 100755 --- a/src/before/java/org/openrewrite/java/testing/junit5/ExampleJunitTestClass.java +++ b/src/before/java/org/openrewrite/java/testing/junit5/ExampleJunitTestClass.java @@ -18,20 +18,12 @@ import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; -import org.junit.Test; -import org.junit.experimental.categories.Category; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; -import org.junit.rules.Timeout; -import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.mockito.runners.MockitoJUnit44Runner; -import org.mockito.runners.MockitoJUnitRunner; -import org.openrewrite.java.testing.statik.UnitTest; import java.io.File; import java.io.IOException; @@ -39,12 +31,8 @@ import static org.mockito.Mockito.*; -@Category(UnitTest.class) public class ExampleJunitTestClass { -// @Rule -// public Timeout globalTimeout = new Timeout(500); - @Rule public TemporaryFolder folder = new TemporaryFolder(); @@ -115,10 +103,7 @@ public void bar() { } @Test public void aTest() { - List foo = mock(List.class); - - when(foo.get(any())).then(invocation -> invocation.getArgumentAt(0, Integer.class)); - int one = foo.get(1); - Assert.assertEquals(1, one); + String foo = mock(String.class); + when(foo.concat(any())).then(invocation -> invocation.getArgumentAt(0, String.class)); } } diff --git a/src/integTest/kotlin/org/openrewrite/java/testing/RunOnMavenProjectOnDisk.kt b/src/integTest/kotlin/org/openrewrite/java/testing/RunOnMavenProjectOnDisk.kt index 436e3c3ee..0445d6c43 100644 --- a/src/integTest/kotlin/org/openrewrite/java/testing/RunOnMavenProjectOnDisk.kt +++ b/src/integTest/kotlin/org/openrewrite/java/testing/RunOnMavenProjectOnDisk.kt @@ -68,7 +68,6 @@ class RunOnMavenProjectOnDisk { val mavenParserBuilder = MavenParser.builder() .cache(pomCache) - .resolveOptional(false) .mavenConfig(projectDir.resolve(".mvn/maven.config")) val parser = MavenProjectParser( diff --git a/src/main/java/org/openrewrite/java/testing/junit5/CleanupJUnitImports.java b/src/main/java/org/openrewrite/java/testing/junit5/CleanupJUnitImports.java index 3339b0f10..b0688704d 100755 --- a/src/main/java/org/openrewrite/java/testing/junit5/CleanupJUnitImports.java +++ b/src/main/java/org/openrewrite/java/testing/junit5/CleanupJUnitImports.java @@ -15,6 +15,7 @@ */ package org.openrewrite.java.testing.junit5; +import lombok.Value; import org.openrewrite.Cursor; import org.openrewrite.ExecutionContext; import org.openrewrite.Recipe; diff --git a/src/main/resources/META-INF/rewrite/junit5.yml b/src/main/resources/META-INF/rewrite/junit5.yml index 917bec130..b993c6d45 100755 --- a/src/main/resources/META-INF/rewrite/junit5.yml +++ b/src/main/resources/META-INF/rewrite/junit5.yml @@ -72,7 +72,7 @@ recipeList: onlyIfUsing: - org.junit.jupiter.api.Test - org.openrewrite.java.testing.junit5.UseHamcrestAssertThat - - org.openrewrite.java.tesitng.junit5.UseMockitoExtension + - org.openrewrite.java.testing.junit5.UseMockitoExtension - org.openrewrite.java.testing.junit5.UseTestMethodOrder - org.openrewrite.java.testing.junit5.AssertToAssertions - org.openrewrite.java.testing.junit5.CategoryToTag diff --git a/src/test/kotlin/org/openrewrite/java/testing/mockito/JunitMockitoUpgradeIntegrationTest.kt b/src/test/kotlin/org/openrewrite/java/testing/mockito/JunitMockitoUpgradeIntegrationTest.kt index d25f74434..6341810ff 100755 --- a/src/test/kotlin/org/openrewrite/java/testing/mockito/JunitMockitoUpgradeIntegrationTest.kt +++ b/src/test/kotlin/org/openrewrite/java/testing/mockito/JunitMockitoUpgradeIntegrationTest.kt @@ -19,6 +19,7 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.openrewrite.* +import org.openrewrite.config.Environment import org.openrewrite.java.JavaParser import org.openrewrite.java.JavaRecipeTest import org.openrewrite.maven.MavenParser @@ -26,15 +27,16 @@ import org.openrewrite.maven.MavenParser /** * Validates the recipes related to upgrading from Mockito 1 to Mockito 3 */ -@Issue("https://github.com/openrewrite/rewrite/issues/343") -@Disabled class JunitMockitoUpgradeIntegrationTest : JavaRecipeTest { override val parser: JavaParser = JavaParser.fromJavaVersion() - .classpath("mockito-all", "junit", "hamcrest") - .build() + .logCompilationWarningsAndErrors(true) + .classpath("mockito-all", "junit", "hamcrest") + .build() - override val recipe: Recipe - get() = loadRecipeFromClasspath("org.openrewrite.java.testing.JUnit5Migration", + override val recipe: Recipe = Environment.builder() + .scanClasspath(emptyList()) + .build() + .activateRecipes("org.openrewrite.java.testing.junit5.JUnit4to5Migration", "org.openrewrite.java.testing.mockito.Mockito1to3Migration") /** @@ -342,10 +344,7 @@ class JunitMockitoUpgradeIntegrationTest : JavaRecipeTest { val exampleJunitAfter = """ package org.openrewrite.java.testing.junit5; - import org.junit.jupiter.api.AfterAll; - import org.junit.jupiter.api.Assertions; - import org.junit.jupiter.api.BeforeEach; - import org.junit.jupiter.api.Test; + import org.junit.jupiter.api.*; import org.junit.jupiter.api.io.TempDir; import org.mockito.Mock; import org.mockito.MockitoAnnotations;