From 19f3da207a96c62df911d348a661a6013fcb2e5a Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Thu, 8 Sep 2022 17:38:04 +0200 Subject: [PATCH] Suggestions for `AssertJComparableTemplates` --- .../AssertJComparableTemplates.java | 18 ++++++------------ .../AssertJComparableTemplatesTestInput.java | 14 +++++++------- .../AssertJComparableTemplatesTestOutput.java | 14 +++++++------- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplates.java index d0f15b6da40..2d63f665da4 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplates.java @@ -12,8 +12,7 @@ final class AssertJComparableTemplates { private AssertJComparableTemplates() {} - static final class AbstractComparableAssertActualIsEqualByComparingToExpected< - T extends Comparable> { + static final class AssertThatIsEqualByComparingTo> { @BeforeTemplate AbstractIntegerAssert before(T actual, T expected) { return assertThat(actual.compareTo(expected)).isEqualTo(0); @@ -26,8 +25,7 @@ AbstractIntegerAssert before(T actual, T expected) { } } - static final class AbstractComparableAssertActualIsNotEqualByComparingToExpected< - T extends Comparable> { + static final class AssertThatIsNotEqualByComparingTo> { @BeforeTemplate AbstractIntegerAssert before(T actual, T expected) { return assertThat(actual.compareTo(expected)).isNotEqualTo(0); @@ -40,8 +38,7 @@ AbstractIntegerAssert before(T actual, T expected) { } } - static final class AbstractComparableAssertActualIsLessThanExpected< - T extends Comparable> { + static final class AssertThatIsLessThan> { @BeforeTemplate AbstractIntegerAssert before(T actual, T expected) { return assertThat(actual.compareTo(expected)).isNegative(); @@ -54,8 +51,7 @@ AbstractIntegerAssert before(T actual, T expected) { } } - static final class AbstractComparableAssertActualIsLessThanOrEqualToExpected< - T extends Comparable> { + static final class AssertThatIsLessThanOrEqualTo> { @BeforeTemplate AbstractIntegerAssert before(T actual, T expected) { return assertThat(actual.compareTo(expected)).isNotPositive(); @@ -68,8 +64,7 @@ AbstractIntegerAssert before(T actual, T expected) { } } - static final class AbstractComparableAssertActualIsGreaterThanExpected< - T extends Comparable> { + static final class AssertThatIsGreaterThan> { @BeforeTemplate AbstractIntegerAssert before(T actual, T expected) { return assertThat(actual.compareTo(expected)).isPositive(); @@ -82,8 +77,7 @@ AbstractIntegerAssert before(T actual, T expected) { } } - static final class AbstractComparableAssertActualIsGreaterThanOrEqualToExpected< - T extends Comparable> { + static final class AssertThatIsGreaterThanOrEqualTo> { @BeforeTemplate AbstractIntegerAssert before(T actual, T expected) { return assertThat(actual.compareTo(expected)).isNotNegative(); diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplatesTestInput.java index 38726215c2a..9d3793f23d3 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplatesTestInput.java @@ -3,31 +3,31 @@ import static org.assertj.core.api.Assertions.assertThat; import java.math.BigDecimal; -import org.assertj.core.api.AbstractAssert; +import org.assertj.core.api.AbstractComparableAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; final class AssertJComparableTemplatesTest implements RefasterTemplateTestCase { - AbstractAssert testAbstractComparableAssertActualIsEqualByComparingToExpected() { + AbstractComparableAssert testAssertThatIsEqualByComparingTo() { return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isEqualTo(0); } - AbstractAssert testAbstractComparableAssertActualIsNotEqualByComparingToExpected() { + AbstractComparableAssert testAssertThatIsNotEqualByComparingTo() { return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isNotEqualTo(0); } - AbstractAssert testAbstractComparableAssertActualIsLessThanExpected() { + AbstractComparableAssert testAssertThatIsLessThan() { return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isNegative(); } - AbstractAssert testAbstractComparableAssertActualIsLessThanOrEqualToExpected() { + AbstractComparableAssert testAssertThatIsLessThanOrEqualTo() { return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isNotPositive(); } - AbstractAssert testAbstractComparableAssertActualIsGreaterThanExpected() { + AbstractComparableAssert testAssertThatIsGreaterThan() { return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isPositive(); } - AbstractAssert testAbstractComparableAssertActualIsGreaterThanOrEqualToExpected() { + AbstractComparableAssert testAssertThatIsGreaterThanOrEqualTo() { return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isNotNegative(); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplatesTestOutput.java index 0fd92845548..8ff2093d8d1 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplatesTestOutput.java @@ -3,31 +3,31 @@ import static org.assertj.core.api.Assertions.assertThat; import java.math.BigDecimal; -import org.assertj.core.api.AbstractAssert; +import org.assertj.core.api.AbstractComparableAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; final class AssertJComparableTemplatesTest implements RefasterTemplateTestCase { - AbstractAssert testAbstractComparableAssertActualIsEqualByComparingToExpected() { + AbstractComparableAssert testAssertThatIsEqualByComparingTo() { return assertThat(BigDecimal.ZERO).isEqualByComparingTo(BigDecimal.ONE); } - AbstractAssert testAbstractComparableAssertActualIsNotEqualByComparingToExpected() { + AbstractComparableAssert testAssertThatIsNotEqualByComparingTo() { return assertThat(BigDecimal.ZERO).isNotEqualByComparingTo(BigDecimal.ONE); } - AbstractAssert testAbstractComparableAssertActualIsLessThanExpected() { + AbstractComparableAssert testAssertThatIsLessThan() { return assertThat(BigDecimal.ZERO).isLessThan(BigDecimal.ONE); } - AbstractAssert testAbstractComparableAssertActualIsLessThanOrEqualToExpected() { + AbstractComparableAssert testAssertThatIsLessThanOrEqualTo() { return assertThat(BigDecimal.ZERO).isLessThanOrEqualTo(BigDecimal.ONE); } - AbstractAssert testAbstractComparableAssertActualIsGreaterThanExpected() { + AbstractComparableAssert testAssertThatIsGreaterThan() { return assertThat(BigDecimal.ZERO).isGreaterThan(BigDecimal.ONE); } - AbstractAssert testAbstractComparableAssertActualIsGreaterThanOrEqualToExpected() { + AbstractComparableAssert testAssertThatIsGreaterThanOrEqualTo() { return assertThat(BigDecimal.ZERO).isGreaterThanOrEqualTo(BigDecimal.ONE); } }