From ddbf8c7b6e0eddc5eaf7837421a338adc39bd3b6 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Tue, 15 Feb 2022 10:53:56 +0100 Subject: [PATCH] Apply suggestions --- .../refastertemplates/AssertJMapTemplates.java | 6 +++--- .../AssertJMapTemplatesTestInput.java | 5 +++-- .../AssertJMapTemplatesTestOutput.java | 8 ++++---- .../AssertJNumberTemplatesTestInput.java | 16 ++++++++++++---- .../AssertJNumberTemplatesTestOutput.java | 16 ++++++++++++---- 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJMapTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJMapTemplates.java index 5a54b59d1e..566caa3265 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJMapTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJMapTemplates.java @@ -9,7 +9,7 @@ final class AssertJMapTemplates { private AssertJMapTemplates() {} - static final class AbstractMapAssertContainsExactlyEntriesOf { + static final class AbstractMapAssertContainsExactlyInAnyOrderEntriesOf { @BeforeTemplate AbstractMapAssert before(AbstractMapAssert mapAssert, Map map) { return mapAssert.isEqualTo(map); @@ -21,7 +21,7 @@ static final class AbstractMapAssertContainsExactlyEntriesOf { } } - static final class AbstractMapAssertContainsOnly { + static final class AbstractMapAssertContainsExactlyEntriesOf { @BeforeTemplate AbstractMapAssert before(AbstractMapAssert mapAssert, K key, V value) { return mapAssert.containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(key, value)); @@ -29,7 +29,7 @@ static final class AbstractMapAssertContainsOnly { @AfterTemplate AbstractMapAssert after(AbstractMapAssert mapAssert, K key, V value) { - return mapAssert.containsOnly(Map.entry(key, value)); + return mapAssert.containsExactlyEntriesOf(ImmutableMap.of(key, value)); } } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJMapTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJMapTemplatesTestInput.java index 3739c50599..108cf330eb 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJMapTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJMapTemplatesTestInput.java @@ -6,11 +6,12 @@ import org.assertj.core.api.AbstractMapAssert; final class AssertJMapTemplatesTest implements RefasterTemplateTestCase { - AbstractMapAssert testAbstractMapAssertContainsExactlyEntriesOf() { + AbstractMapAssert + testAbstractMapAssertContainsExactlyInAnyOrderEntriesOf() { return assertThat(ImmutableMap.of(1, 2, 3, 4)).isEqualTo(ImmutableMap.of(1, 2, 3, 4)); } - AbstractMapAssert testAbstractMapAssertContainsOnly() { + AbstractMapAssert testAbstractMapAssertContainsExactlyEntriesOf() { return assertThat(ImmutableMap.of(1, 2)) .containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(1, 2)); } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJMapTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJMapTemplatesTestOutput.java index d2fd29410f..cd25377325 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJMapTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJMapTemplatesTestOutput.java @@ -3,16 +3,16 @@ import static org.assertj.core.api.Assertions.assertThat; import com.google.common.collect.ImmutableMap; -import java.util.Map; import org.assertj.core.api.AbstractMapAssert; final class AssertJMapTemplatesTest implements RefasterTemplateTestCase { - AbstractMapAssert testAbstractMapAssertContainsExactlyEntriesOf() { + AbstractMapAssert + testAbstractMapAssertContainsExactlyInAnyOrderEntriesOf() { return assertThat(ImmutableMap.of(1, 2, 3, 4)) .containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(1, 2, 3, 4)); } - AbstractMapAssert testAbstractMapAssertContainsOnly() { - return assertThat(ImmutableMap.of(1, 2)).containsOnly(Map.entry(1, 2)); + AbstractMapAssert testAbstractMapAssertContainsExactlyEntriesOf() { + return assertThat(ImmutableMap.of(1, 2)).containsExactlyEntriesOf(ImmutableMap.of(1, 2)); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJNumberTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJNumberTemplatesTestInput.java index 62e3f43e33..3e0fe743f0 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJNumberTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJNumberTemplatesTestInput.java @@ -79,16 +79,24 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase { ImmutableSet> testAssertThatIsOdd() { return ImmutableSet.of( assertThat((byte) 1 % 2).isEqualTo(1), - assertThat((Integer) 1 % 2).isEqualTo(1), + assertThat(Byte.valueOf((byte) 1) % 2).isEqualTo(1), + assertThat((int) 1 % 2).isEqualTo(1), + assertThat(Integer.valueOf(1) % 2).isEqualTo(1), assertThat((long) 1 % 2).isEqualTo(1), - assertThat((short) 1 % 2).isEqualTo(1)); + assertThat(Long.valueOf(1L) % 2).isEqualTo(1), + assertThat((short) 1 % 2).isEqualTo(1), + assertThat(Short.valueOf((short) 1) % 2).isEqualTo(1)); } ImmutableSet> testAssertThatIsEven() { return ImmutableSet.of( assertThat((byte) 1 % 2).isEqualTo(0), - assertThat((Integer) 1 % 2).isEqualTo(0), + assertThat(Byte.valueOf((byte) 1) % 2).isEqualTo(0), + assertThat((int) 1 % 2).isEqualTo(0), + assertThat(Integer.valueOf(1) % 2).isEqualTo(0), assertThat((long) 1 % 2).isEqualTo(0), - assertThat((short) 1 % 2).isEqualTo(0)); + assertThat(Long.valueOf(1L) % 2).isEqualTo(0), + assertThat((short) 1 % 2).isEqualTo(0), + assertThat(Short.valueOf((short) 1) % 2).isEqualTo(0)); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJNumberTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJNumberTemplatesTestOutput.java index b33f771d02..b8a62004e7 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJNumberTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/bugpatterns/AssertJNumberTemplatesTestOutput.java @@ -79,16 +79,24 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase { ImmutableSet> testAssertThatIsOdd() { return ImmutableSet.of( assertThat((byte) 1).isOdd(), - assertThat((Integer) 1).isOdd(), + assertThat(Byte.valueOf((byte) 1)).isOdd(), + assertThat((int) 1).isOdd(), + assertThat(Integer.valueOf(1)).isOdd(), assertThat((long) 1).isOdd(), - assertThat((short) 1).isOdd()); + assertThat(Long.valueOf(1L)).isOdd(), + assertThat((short) 1).isOdd(), + assertThat(Short.valueOf((short) 1)).isOdd()); } ImmutableSet> testAssertThatIsEven() { return ImmutableSet.of( assertThat((byte) 1).isEven(), - assertThat((Integer) 1).isEven(), + assertThat(Byte.valueOf((byte) 1)).isEven(), + assertThat((int) 1).isEven(), + assertThat(Integer.valueOf(1)).isEven(), assertThat((long) 1).isEven(), - assertThat((short) 1).isEven()); + assertThat(Long.valueOf(1L)).isEven(), + assertThat((short) 1).isEven(), + assertThat(Short.valueOf((short) 1)).isEven()); } }