From eaf56ae04f0fabbe24ed8b5c1606251914f9710e Mon Sep 17 00:00:00 2001 From: Marius Barbulescu Date: Tue, 14 Jan 2025 00:06:45 +0100 Subject: [PATCH 1/2] add test to reproduce issue 664 --- .../assertj/AssertJBestPracticesTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/test/java/org/openrewrite/java/testing/assertj/AssertJBestPracticesTest.java b/src/test/java/org/openrewrite/java/testing/assertj/AssertJBestPracticesTest.java index 8d229935a..b8ce46fda 100644 --- a/src/test/java/org/openrewrite/java/testing/assertj/AssertJBestPracticesTest.java +++ b/src/test/java/org/openrewrite/java/testing/assertj/AssertJBestPracticesTest.java @@ -15,6 +15,7 @@ */ package org.openrewrite.java.testing.assertj; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -69,6 +70,37 @@ void test() { ); } + @Test + @Disabled("to be fixed") + @Issue("https://github.com/openrewrite/rewrite-testing-frameworks/issues/664") + void assertionsForClassTypesIsNotRemovedByAssertionsImport() { + rewriteRun( + // language=java + java( + """ + import java.util.Map; + import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + + class Test { + void test() { + assertThat(Map.of("a", 1).entrySet()).hasNoNullFieldsOrProperties(); + } + } + """, + """ + import java.util.Map; + import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + + class Test { + void test() { + assertThat(Map.of("a", 1).entrySet()).hasNoNullFieldsOrProperties(); + } + } + """ + ) + ); + } + @Test @Issue("https://github.com/openrewrite/rewrite-testing-frameworks/issues/398") void sizeIsEqualToZeroToIsEmpty() { From 15f480b2cdc6c6d869f364651ed3b92ce14c593e Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 18 Jan 2025 19:11:42 +0100 Subject: [PATCH 2/2] Assert no change is made by only passing in a before text block --- .../testing/assertj/AssertJBestPracticesTest.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/test/java/org/openrewrite/java/testing/assertj/AssertJBestPracticesTest.java b/src/test/java/org/openrewrite/java/testing/assertj/AssertJBestPracticesTest.java index b8ce46fda..43cbfc32e 100644 --- a/src/test/java/org/openrewrite/java/testing/assertj/AssertJBestPracticesTest.java +++ b/src/test/java/org/openrewrite/java/testing/assertj/AssertJBestPracticesTest.java @@ -71,7 +71,6 @@ void test() { } @Test - @Disabled("to be fixed") @Issue("https://github.com/openrewrite/rewrite-testing-frameworks/issues/664") void assertionsForClassTypesIsNotRemovedByAssertionsImport() { rewriteRun( @@ -81,16 +80,6 @@ void assertionsForClassTypesIsNotRemovedByAssertionsImport() { import java.util.Map; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; - class Test { - void test() { - assertThat(Map.of("a", 1).entrySet()).hasNoNullFieldsOrProperties(); - } - } - """, - """ - import java.util.Map; - import static org.assertj.core.api.AssertionsForClassTypes.assertThat; - class Test { void test() { assertThat(Map.of("a", 1).entrySet()).hasNoNullFieldsOrProperties();