diff --git a/src/main/java/org/openrewrite/java/testing/assertj/IsEqualToIgnoringMillisToIsCloseTo.java b/src/main/java/org/openrewrite/java/testing/assertj/IsEqualToIgnoringMillisToIsCloseTo.java index bd28eeedb..23a283649 100644 --- a/src/main/java/org/openrewrite/java/testing/assertj/IsEqualToIgnoringMillisToIsCloseTo.java +++ b/src/main/java/org/openrewrite/java/testing/assertj/IsEqualToIgnoringMillisToIsCloseTo.java @@ -15,14 +15,12 @@ */ package org.openrewrite.java.testing.assertj; -import java.util.Date; - import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; import org.openrewrite.java.template.RecipeDescriptor; -import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; +import java.util.Date; + import static org.assertj.core.api.Assertions.assertThat; @RecipeDescriptor( @@ -38,7 +36,6 @@ void isEqualToIgnoringMillisBefore(Date date1, Date date2) { } @AfterTemplate - @UseImportPolicy(value = STATIC_IMPORT_ALWAYS) void isCloseToAfter(Date date1, Date date2) { assertThat(date1).isCloseTo(date2, 1000L); } diff --git a/src/main/resources/META-INF/rewrite/assertj.yml b/src/main/resources/META-INF/rewrite/assertj.yml index b571cfe86..fde50d99f 100644 --- a/src/main/resources/META-INF/rewrite/assertj.yml +++ b/src/main/resources/META-INF/rewrite/assertj.yml @@ -26,6 +26,7 @@ recipeList: - org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ - org.openrewrite.java.testing.assertj.JUnitToAssertj - org.openrewrite.java.testing.testng.TestNgToAssertj + - org.openrewrite.java.testing.assertj.IsEqualToIgnoringMillisToIsCloseToTest - org.openrewrite.java.testing.assertj.StaticImports - org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertions - org.openrewrite.java.testing.assertj.SimplifyAssertJAssertions diff --git a/src/test/java/org/openrewrite/java/testing/assertj/IsEqualToIgnoringMillisToIsCloseToTest.java b/src/test/java/org/openrewrite/java/testing/assertj/IsEqualToIgnoringMillisToIsCloseToTest.java index 235d9d45e..02c8c2d8f 100644 --- a/src/test/java/org/openrewrite/java/testing/assertj/IsEqualToIgnoringMillisToIsCloseToTest.java +++ b/src/test/java/org/openrewrite/java/testing/assertj/IsEqualToIgnoringMillisToIsCloseToTest.java @@ -28,27 +28,29 @@ class IsEqualToIgnoringMillisToIsCloseToTest implements RewriteTest { void replaceDeprecation() { rewriteRun(spec -> spec.recipe(new IsEqualToIgnoringMillisToIsCloseToRecipe()), //language=java - java(""" - import java.util.Date; + java( + """ + import org.assertj.core.api.Assertions; - import static org.assertj.core.api.Assertions.assertThat; + import java.util.Date; - class A { - public void foo(Date date1, Date date2) { - assertThat(date1).isEqualToIgnoringMillis(date2); + class A { + public void foo(Date date1, Date date2) { + Assertions.assertThat(date1).isEqualToIgnoringMillis(date2); + } } - } - """, """ - import java.util.Date; + """, + """ + import org.assertj.core.api.Assertions; - import static org.assertj.core.api.Assertions.assertThat; + import java.util.Date; - class A { - public void foo(Date date1, Date date2) { - assertThat(date1).isCloseTo(date2, 1000L); + class A { + public void foo(Date date1, Date date2) { + Assertions.assertThat(date1).isCloseTo(date2, 1000L); + } } - } - """ + """ ) ); }