Skip to content

Commit

Permalink
Include IsEqualToIgnoringMillisToIsCloseTo just before StaticImports
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Dec 22, 2024
1 parent abf7891 commit 09b6176
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/rewrite/assertj.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
"""
"""
)
);
}
Expand Down

0 comments on commit 09b6176

Please sign in to comment.