From df5e97d963ee3b224d358ce27117e17c4e79260e Mon Sep 17 00:00:00 2001 From: CoolTomatos Date: Tue, 6 Sep 2022 11:58:03 +0200 Subject: [PATCH 01/16] Switch to use AbstractComparableAsserts when comparison assertions are evaluated as booleans. --- .../AssertJByteTemplates.java | 80 +++++++++++++++++++ .../AssertJComparableTemplates.java | 73 +++++++++++++++++ .../AssertJDoubleTemplates.java | 80 +++++++++++++++++++ .../AssertJFloatTemplates.java | 80 +++++++++++++++++++ .../AssertJIntegerTemplates.java | 80 +++++++++++++++++++ .../AssertJLongTemplates.java | 80 +++++++++++++++++++ .../AssertJShortTemplates.java | 80 +++++++++++++++++++ 7 files changed, 553 insertions(+) create mode 100644 error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplates.java diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJByteTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJByteTemplates.java index 220e3001e7..39425c5a8c 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJByteTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJByteTemplates.java @@ -1,11 +1,13 @@ package tech.picnic.errorprone.refastertemplates; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractByteAssert; final class AssertJByteTemplates { @@ -24,6 +26,19 @@ AbstractByteAssert after(AbstractByteAssert byteAssert, byte n) { } } + static final class AbstractByteAssertActualIsEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(byte actual, byte expected) { + return Refaster.anyOf( + assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); + } + + @AfterTemplate + AbstractByteAssert after(byte actual, byte expected) { + return assertThat(actual).isEqualTo(expected); + } + } + static final class AbstractByteAssertIsNotEqualTo { @BeforeTemplate AbstractByteAssert before(AbstractByteAssert byteAssert, byte n) { @@ -38,6 +53,19 @@ AbstractByteAssert after(AbstractByteAssert byteAssert, byte n) { } } + static final class AbstractByteAssertActualIsNotEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(byte actual, byte expected) { + return Refaster.anyOf( + assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); + } + + @AfterTemplate + AbstractByteAssert after(byte actual, byte expected) { + return assertThat(actual).isNotEqualTo(expected); + } + } + static final class AbstractByteAssertIsZero { @BeforeTemplate AbstractByteAssert before(AbstractByteAssert byteAssert) { @@ -73,4 +101,56 @@ AbstractByteAssert after(AbstractByteAssert byteAssert) { return byteAssert.isEqualTo((byte) 1); } } + + static final class AbstractByteAssertActualIsLessThanExpected { + @BeforeTemplate + AbstractBooleanAssert before(byte actual, byte expected) { + return Refaster.anyOf( + assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); + } + + @AfterTemplate + AbstractByteAssert after(byte actual, byte expected) { + return assertThat(actual).isLessThan(expected); + } + } + + static final class AbstractByteAssertActualIsLessThanOrEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(byte actual, byte expected) { + return Refaster.anyOf( + assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); + } + + @AfterTemplate + AbstractByteAssert after(byte actual, byte expected) { + return assertThat(actual).isLessThanOrEqualTo(expected); + } + } + + static final class AbstractByteAssertActualIsGreaterThanExpected { + @BeforeTemplate + AbstractBooleanAssert before(byte actual, byte expected) { + return Refaster.anyOf( + assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); + } + + @AfterTemplate + AbstractByteAssert after(byte actual, byte expected) { + return assertThat(actual).isGreaterThan(expected); + } + } + + static final class AbstractByteAssertActualIsGreaterThanOrEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(byte actual, byte expected) { + return Refaster.anyOf( + assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); + } + + @AfterTemplate + AbstractByteAssert after(byte actual, byte expected) { + return assertThat(actual).isGreaterThanOrEqualTo(expected); + } + } } 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 new file mode 100644 index 0000000000..605a2032a5 --- /dev/null +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplates.java @@ -0,0 +1,73 @@ +package tech.picnic.errorprone.refastertemplates; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.errorprone.refaster.Refaster; +import com.google.errorprone.refaster.annotation.AfterTemplate; +import com.google.errorprone.refaster.annotation.BeforeTemplate; +import org.assertj.core.api.AbstractBooleanAssert; +import org.assertj.core.api.AbstractComparableAssert; + +final class AssertJComparableTemplates { + private AssertJComparableTemplates() {} + + static final class AbstractComparableAssertActualIsLessThanExpected< + T extends Comparable> { + @BeforeTemplate + AbstractBooleanAssert before(T actual, T expected) { + return Refaster.anyOf( + assertThat(actual.compareTo(expected) < 0).isTrue(), + assertThat(actual.compareTo(expected) >= 0).isFalse()); + } + + @AfterTemplate + AbstractComparableAssert after(T actual, T expected) { + return assertThat(actual).isLessThan(expected); + } + } + + static final class AbstractComparableAssertActualIsLessThanOrEqualToExpected< + T extends Comparable> { + @BeforeTemplate + AbstractBooleanAssert before(T actual, T expected) { + return Refaster.anyOf( + assertThat(actual.compareTo(expected) <= 0).isTrue(), + assertThat(actual.compareTo(expected) > 0).isFalse()); + } + + @AfterTemplate + AbstractComparableAssert after(T actual, T expected) { + return assertThat(actual).isLessThanOrEqualTo(expected); + } + } + + static final class AbstractComparableAssertActualIsGreaterThanExpected< + T extends Comparable> { + @BeforeTemplate + AbstractBooleanAssert before(T actual, T expected) { + return Refaster.anyOf( + assertThat(actual.compareTo(expected) > 0).isTrue(), + assertThat(actual.compareTo(expected) <= 0).isFalse()); + } + + @AfterTemplate + AbstractComparableAssert after(T actual, T expected) { + return assertThat(actual).isGreaterThan(expected); + } + } + + static final class AbstractComparableAssertActualIsGreaterThanOrEqualToExpected< + T extends Comparable> { + @BeforeTemplate + AbstractBooleanAssert before(T actual, T expected) { + return Refaster.anyOf( + assertThat(actual.compareTo(expected) >= 0).isTrue(), + assertThat(actual.compareTo(expected) < 0).isFalse()); + } + + @AfterTemplate + AbstractComparableAssert after(T actual, T expected) { + return assertThat(actual).isGreaterThanOrEqualTo(expected); + } + } +} diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java index 44dc57b014..0d90a166b8 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java @@ -1,11 +1,13 @@ package tech.picnic.errorprone.refastertemplates; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractDoubleAssert; import org.assertj.core.data.Offset; @@ -45,6 +47,19 @@ AbstractDoubleAssert after(AbstractDoubleAssert doubleAssert, double n) { } } + static final class AbstractDoubleAssertActualIsEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); + } + + @AfterTemplate + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isEqualTo(expected); + } + } + static final class AbstractDoubleAssertIsNotEqualTo { @BeforeTemplate AbstractDoubleAssert before(AbstractDoubleAssert doubleAssert, double n) { @@ -59,6 +74,19 @@ AbstractDoubleAssert after(AbstractDoubleAssert doubleAssert, double n) { } } + static final class AbstractDoubleAssertActualIsNotEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); + } + + @AfterTemplate + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isNotEqualTo(expected); + } + } + static final class AbstractDoubleAssertIsZero { @BeforeTemplate AbstractDoubleAssert before(AbstractDoubleAssert doubleAssert) { @@ -94,4 +122,56 @@ AbstractDoubleAssert after(AbstractDoubleAssert doubleAssert) { return doubleAssert.isEqualTo(1); } } + + static final class AbstractDoubleAssertActualIsLessThanExpected { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); + } + + @AfterTemplate + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isLessThan(expected); + } + } + + static final class AbstractDoubleAssertActualIsLessThanOrEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); + } + + @AfterTemplate + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isLessThanOrEqualTo(expected); + } + } + + static final class AbstractDoubleAssertActualIsGreaterThanExpected { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); + } + + @AfterTemplate + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isGreaterThan(expected); + } + } + + static final class AbstractDoubleAssertActualIsGreaterThanOrEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); + } + + @AfterTemplate + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isGreaterThanOrEqualTo(expected); + } + } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplates.java index 6de54b99cb..0b2fd0603a 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplates.java @@ -1,11 +1,13 @@ package tech.picnic.errorprone.refastertemplates; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractFloatAssert; import org.assertj.core.data.Offset; @@ -45,6 +47,19 @@ AbstractFloatAssert after(AbstractFloatAssert floatAssert, float n) { } } + static final class AbstractFloatAssertActualIsEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(float actual, float expected) { + return Refaster.anyOf( + assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); + } + + @AfterTemplate + AbstractFloatAssert after(float actual, float expected) { + return assertThat(actual).isEqualTo(expected); + } + } + static final class AbstractFloatAssertIsNotEqualTo { @BeforeTemplate AbstractFloatAssert before(AbstractFloatAssert floatAssert, float n) { @@ -58,6 +73,19 @@ AbstractFloatAssert after(AbstractFloatAssert floatAssert, float n) { } } + static final class AbstractFloatAssertActualIsNotEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(float actual, float expected) { + return Refaster.anyOf( + assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); + } + + @AfterTemplate + AbstractFloatAssert after(float actual, float expected) { + return assertThat(actual).isNotEqualTo(expected); + } + } + static final class AbstractFloatAssertIsZero { @BeforeTemplate AbstractFloatAssert before(AbstractFloatAssert floatAssert) { @@ -93,4 +121,56 @@ AbstractFloatAssert after(AbstractFloatAssert floatAssert) { return floatAssert.isEqualTo(1); } } + + static final class AbstractFloatAssertActualIsLessThanExpected { + @BeforeTemplate + AbstractBooleanAssert before(float actual, float expected) { + return Refaster.anyOf( + assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); + } + + @AfterTemplate + AbstractFloatAssert after(float actual, float expected) { + return assertThat(actual).isLessThan(expected); + } + } + + static final class AbstractFloatAssertActualIsLessThanOrEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(float actual, float expected) { + return Refaster.anyOf( + assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); + } + + @AfterTemplate + AbstractFloatAssert after(float actual, float expected) { + return assertThat(actual).isLessThanOrEqualTo(expected); + } + } + + static final class AbstractFloatAssertActualIsGreaterThanExpected { + @BeforeTemplate + AbstractBooleanAssert before(float actual, float expected) { + return Refaster.anyOf( + assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); + } + + @AfterTemplate + AbstractFloatAssert after(float actual, float expected) { + return assertThat(actual).isGreaterThan(expected); + } + } + + static final class AbstractFloatAssertActualIsGreaterThanOrEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(float actual, float expected) { + return Refaster.anyOf( + assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); + } + + @AfterTemplate + AbstractFloatAssert after(float actual, float expected) { + return assertThat(actual).isGreaterThanOrEqualTo(expected); + } + } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplates.java index f46ac40564..e633edeb9e 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplates.java @@ -1,11 +1,13 @@ package tech.picnic.errorprone.refastertemplates; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractIntegerAssert; final class AssertJIntegerTemplates { @@ -24,6 +26,19 @@ AbstractIntegerAssert after(AbstractIntegerAssert intAssert, int n) { } } + static final class AbstractIntegerAssertActualIsEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(int actual, int expected) { + return Refaster.anyOf( + assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); + } + + @AfterTemplate + AbstractIntegerAssert after(int actual, int expected) { + return assertThat(actual).isEqualTo(expected); + } + } + static final class AbstractIntegerAssertIsNotEqualTo { @BeforeTemplate AbstractIntegerAssert before(AbstractIntegerAssert intAssert, int n) { @@ -37,6 +52,19 @@ AbstractIntegerAssert after(AbstractIntegerAssert intAssert, int n) { } } + static final class AbstractIntegerAssertActualIsNotEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(int actual, int expected) { + return Refaster.anyOf( + assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); + } + + @AfterTemplate + AbstractIntegerAssert after(int actual, int expected) { + return assertThat(actual).isNotEqualTo(expected); + } + } + static final class AbstractIntegerAssertIsZero { @BeforeTemplate AbstractIntegerAssert before(AbstractIntegerAssert intAssert) { @@ -72,4 +100,56 @@ AbstractIntegerAssert after(AbstractIntegerAssert intAssert) { return intAssert.isEqualTo(1); } } + + static final class AbstractIntegerAssertActualIsLessThanExpected { + @BeforeTemplate + AbstractBooleanAssert before(int actual, int expected) { + return Refaster.anyOf( + assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); + } + + @AfterTemplate + AbstractIntegerAssert after(int actual, int expected) { + return assertThat(actual).isLessThan(expected); + } + } + + static final class AbstractIntegerAssertActualIsLessThanOrEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(int actual, int expected) { + return Refaster.anyOf( + assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); + } + + @AfterTemplate + AbstractIntegerAssert after(int actual, int expected) { + return assertThat(actual).isLessThanOrEqualTo(expected); + } + } + + static final class AbstractIntegerAssertActualIsGreaterThanExpected { + @BeforeTemplate + AbstractBooleanAssert before(int actual, int expected) { + return Refaster.anyOf( + assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); + } + + @AfterTemplate + AbstractIntegerAssert after(int actual, int expected) { + return assertThat(actual).isGreaterThan(expected); + } + } + + static final class AbstractIntegerAssertActualIsGreaterThanOrEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(int actual, int expected) { + return Refaster.anyOf( + assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); + } + + @AfterTemplate + AbstractIntegerAssert after(int actual, int expected) { + return assertThat(actual).isGreaterThanOrEqualTo(expected); + } + } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJLongTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJLongTemplates.java index e992886dff..4d7d56e5dc 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJLongTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJLongTemplates.java @@ -1,11 +1,13 @@ package tech.picnic.errorprone.refastertemplates; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractLongAssert; final class AssertJLongTemplates { @@ -24,6 +26,19 @@ AbstractLongAssert after(AbstractLongAssert longAssert, long n) { } } + static final class AbstractLongAssertActualIsEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(long actual, long expected) { + return Refaster.anyOf( + assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); + } + + @AfterTemplate + AbstractLongAssert after(long actual, long expected) { + return assertThat(actual).isEqualTo(expected); + } + } + static final class AbstractLongAssertIsNotEqualTo { @BeforeTemplate AbstractLongAssert before(AbstractLongAssert longAssert, long n) { @@ -37,6 +52,19 @@ AbstractLongAssert after(AbstractLongAssert longAssert, long n) { } } + static final class AbstractLongAssertActualIsNotEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(long actual, long expected) { + return Refaster.anyOf( + assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); + } + + @AfterTemplate + AbstractLongAssert after(long actual, long expected) { + return assertThat(actual).isNotEqualTo(expected); + } + } + static final class AbstractLongAssertIsZero { @BeforeTemplate AbstractLongAssert before(AbstractLongAssert longAssert) { @@ -72,4 +100,56 @@ AbstractLongAssert after(AbstractLongAssert longAssert) { return longAssert.isEqualTo(1); } } + + static final class AbstractLongAssertActualIsLessThanExpected { + @BeforeTemplate + AbstractBooleanAssert before(long actual, long expected) { + return Refaster.anyOf( + assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); + } + + @AfterTemplate + AbstractLongAssert after(long actual, long expected) { + return assertThat(actual).isLessThan(expected); + } + } + + static final class AbstractLongAssertActualIsLessThanOrEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(long actual, long expected) { + return Refaster.anyOf( + assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); + } + + @AfterTemplate + AbstractLongAssert after(long actual, long expected) { + return assertThat(actual).isLessThanOrEqualTo(expected); + } + } + + static final class AbstractLongAssertActualIsGreaterThanExpected { + @BeforeTemplate + AbstractBooleanAssert before(long actual, long expected) { + return Refaster.anyOf( + assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); + } + + @AfterTemplate + AbstractLongAssert after(long actual, long expected) { + return assertThat(actual).isGreaterThan(expected); + } + } + + static final class AbstractLongAssertActualIsGreaterThanOrEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(long actual, long expected) { + return Refaster.anyOf( + assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); + } + + @AfterTemplate + AbstractLongAssert after(long actual, long expected) { + return assertThat(actual).isGreaterThanOrEqualTo(expected); + } + } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJShortTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJShortTemplates.java index 017f897b93..e9fd4e7651 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJShortTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJShortTemplates.java @@ -1,11 +1,13 @@ package tech.picnic.errorprone.refastertemplates; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractShortAssert; final class AssertJShortTemplates { @@ -24,6 +26,19 @@ AbstractShortAssert after(AbstractShortAssert shortAssert, short n) { } } + static final class AbstractShortAssertActualIsEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(short actual, short expected) { + return Refaster.anyOf( + assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); + } + + @AfterTemplate + AbstractShortAssert after(short actual, short expected) { + return assertThat(actual).isEqualTo(expected); + } + } + static final class AbstractShortAssertIsNotEqualTo { @BeforeTemplate AbstractShortAssert before(AbstractShortAssert shortAssert, short n) { @@ -38,6 +53,19 @@ AbstractShortAssert after(AbstractShortAssert shortAssert, short n) { } } + static final class AbstractShortAssertActualIsNotEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(short actual, short expected) { + return Refaster.anyOf( + assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); + } + + @AfterTemplate + AbstractShortAssert after(short actual, short expected) { + return assertThat(actual).isNotEqualTo(expected); + } + } + static final class AbstractShortAssertIsZero { @BeforeTemplate AbstractShortAssert before(AbstractShortAssert shortAssert) { @@ -73,4 +101,56 @@ AbstractShortAssert after(AbstractShortAssert shortAssert) { return shortAssert.isEqualTo((short) 1); } } + + static final class AbstractShortAssertActualIsLessThanExpected { + @BeforeTemplate + AbstractBooleanAssert before(short actual, short expected) { + return Refaster.anyOf( + assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); + } + + @AfterTemplate + AbstractShortAssert after(short actual, short expected) { + return assertThat(actual).isLessThan(expected); + } + } + + static final class AbstractShortAssertActualIsLessThanOrEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(short actual, short expected) { + return Refaster.anyOf( + assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); + } + + @AfterTemplate + AbstractShortAssert after(short actual, short expected) { + return assertThat(actual).isLessThanOrEqualTo(expected); + } + } + + static final class AbstractShortAssertActualIsGreaterThanExpected { + @BeforeTemplate + AbstractBooleanAssert before(short actual, short expected) { + return Refaster.anyOf( + assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); + } + + @AfterTemplate + AbstractShortAssert after(short actual, short expected) { + return assertThat(actual).isGreaterThan(expected); + } + } + + static final class AbstractShortAssertActualIsGreaterThanOrEqualToExpected { + @BeforeTemplate + AbstractBooleanAssert before(short actual, short expected) { + return Refaster.anyOf( + assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); + } + + @AfterTemplate + AbstractShortAssert after(short actual, short expected) { + return assertThat(actual).isGreaterThanOrEqualTo(expected); + } + } } From 73abd03bed37b4815f93478e8925c3c1e6aa8d5d Mon Sep 17 00:00:00 2001 From: CoolTomatos Date: Tue, 6 Sep 2022 12:19:18 +0200 Subject: [PATCH 02/16] Some test coverage. --- .../AssertJByteTemplatesTestInput.java | 32 +++++++++++++++++++ .../AssertJByteTemplatesTestOutput.java | 24 ++++++++++++++ .../AssertJDoubleTemplatesTestInput.java | 27 ++++++++++++++++ .../AssertJDoubleTemplatesTestOutput.java | 24 ++++++++++++++ .../AssertJFloatTemplatesTestInput.java | 27 ++++++++++++++++ .../AssertJFloatTemplatesTestOutput.java | 24 ++++++++++++++ 6 files changed, 158 insertions(+) diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestInput.java index f9a7b2607e..9772672657 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestInput.java @@ -5,6 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractByteAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -20,12 +21,22 @@ ImmutableSet> testAbstractByteAssertIsEqualTo() { assertThat((byte) 0).isCloseTo((byte) 1, withPercentage(0))); } + ImmutableSet> testAbstractByteAssertActualIsEqualToExpected() { + return ImmutableSet.of( + assertThat((byte) 1 == (byte) 2).isTrue(), assertThat((byte) 1 != (byte) 2).isFalse()); + } + ImmutableSet> testAbstractByteAssertIsNotEqualTo() { return ImmutableSet.of( assertThat((byte) 0).isNotCloseTo((byte) 1, offset((byte) 0)), assertThat((byte) 0).isNotCloseTo((byte) 1, withPercentage(0))); } + ImmutableSet> testAbstractByteAssertActualIsNotEqualToExpected() { + return ImmutableSet.of( + assertThat((byte) 1 != (byte) 2).isTrue(), assertThat((byte) 1 == (byte) 2).isFalse()); + } + AbstractByteAssert testAbstractByteAssertIsZero() { return assertThat((byte) 0).isZero(); } @@ -37,4 +48,25 @@ AbstractByteAssert testAbstractByteAssertIsNotZero() { AbstractByteAssert testAbstractByteAssertIsOne() { return assertThat((byte) 0).isOne(); } + + ImmutableSet> testAbstractByteAssertActualIsLessThanExpected() { + return ImmutableSet.of( + assertThat((byte) 1 < (byte) 2).isTrue(), assertThat((byte) 1 >= (byte) 2).isFalse()); + } + + ImmutableSet> testAbstractByteAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat((byte) 1 <= (byte) 2).isTrue(), assertThat((byte) 1 > (byte) 2).isFalse()); + } + + ImmutableSet> testAbstractByteAssertActualIsGreaterThanExpected() { + return ImmutableSet.of( + assertThat((byte) 1 > (byte) 2).isTrue(), assertThat((byte) 1 <= (byte) 2).isFalse()); + } + + ImmutableSet> + testAbstractByteAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat((byte) 1 >= (byte) 2).isTrue(), assertThat((byte) 1 < (byte) 2).isFalse()); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestOutput.java index ea274127a4..a2965377e4 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestOutput.java @@ -19,11 +19,19 @@ ImmutableSet> testAbstractByteAssertIsEqualTo() { assertThat((byte) 0).isEqualTo((byte) 1), assertThat((byte) 0).isEqualTo((byte) 1)); } + AbstractByteAssert testAbstractByteAssertActualIsEqualToExpected() { + return assertThat((byte) 1).isEqualTo((byte) 2); + } + ImmutableSet> testAbstractByteAssertIsNotEqualTo() { return ImmutableSet.of( assertThat((byte) 0).isNotEqualTo((byte) 1), assertThat((byte) 0).isNotEqualTo((byte) 1)); } + AbstractByteAssert testAbstractByteAssertActualIsNotEqualToExpected() { + return assertThat((byte) 1).isNotEqualTo((byte) 2); + } + AbstractByteAssert testAbstractByteAssertIsZero() { return assertThat((byte) 0).isEqualTo((byte) 0); } @@ -35,4 +43,20 @@ AbstractByteAssert testAbstractByteAssertIsNotZero() { AbstractByteAssert testAbstractByteAssertIsOne() { return assertThat((byte) 0).isEqualTo((byte) 1); } + + AbstractByteAssert testAbstractByteAssertActualIsLessThanExpected() { + return assertThat((byte) 1).isLessThan((byte) 2); + } + + AbstractByteAssert testAbstractByteAssertActualIsLessThanOrEqualToExpected() { + return assertThat((byte) 1).isLessThanOrEqualTo((byte) 2); + } + + AbstractByteAssert testAbstractByteAssertActualIsGreaterThanExpected() { + return assertThat((byte) 1).isGreaterThan((byte) 2); + } + + AbstractByteAssert testAbstractByteAssertActualIsGreaterThanOrEqualToExpected() { + return assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java index 04eb0c7206..9b688df007 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java @@ -5,6 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractDoubleAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -25,12 +26,20 @@ ImmutableSet> testAbstractDoubleAssertIsEqualTo() { assertThat(0.0).isCloseTo(1, offset(0.0)), assertThat(0.0).isCloseTo(1, withPercentage(0))); } + ImmutableSet> testAbstractDoubleAssertActualIsEqualToExpected() { + return ImmutableSet.of(assertThat(1.0 == 2.0).isTrue(), assertThat(1.0 != 2.0).isFalse()); + } + ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { return ImmutableSet.of( assertThat(0.0).isNotCloseTo(1, offset(0.0)), assertThat(0.0).isNotCloseTo(1, withPercentage(0))); } + ImmutableSet> testAbstractDoubleAssertActualIsNotEqualToExpected() { + return ImmutableSet.of(assertThat(1.0 != 2.0).isTrue(), assertThat(1.0 == 2.0).isFalse()); + } + AbstractDoubleAssert testAbstractDoubleAssertIsZero() { return assertThat(0.0).isZero(); } @@ -42,4 +51,22 @@ AbstractDoubleAssert testAbstractDoubleAssertIsNotZero() { AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return assertThat(0.0).isOne(); } + + ImmutableSet> testAbstractDoubleAssertActualIsLessThanExpected() { + return ImmutableSet.of(assertThat(1.0 < 2.0).isTrue(), assertThat(1.0 >= 2.0).isFalse()); + } + + ImmutableSet> + testAbstractDoubleAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of(assertThat(1.0 <= 2.0).isTrue(), assertThat(1.0 > 2.0).isFalse()); + } + + ImmutableSet> testAbstractDoubleAssertActualIsGreaterThanExpected() { + return ImmutableSet.of(assertThat(1.0 > 2.0).isTrue(), assertThat(1.0 <= 2.0).isFalse()); + } + + ImmutableSet> + testAbstractDoubleAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of(assertThat(1.0 >= 2.0).isTrue(), assertThat(1.0 < 2.0).isFalse()); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java index 12ec9c93be..d043ecf110 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java @@ -24,10 +24,18 @@ ImmutableSet> testAbstractDoubleAssertIsEqualTo() { return ImmutableSet.of(assertThat(0.0).isEqualTo(1), assertThat(0.0).isEqualTo(1)); } + AbstractDoubleAssert testAbstractDoubleAssertActualIsEqualToExpected() { + return assertThat(1.0).isEqualTo(2.0); + } + ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0.0).isNotEqualTo(1), assertThat(0.0).isNotEqualTo(1)); } + AbstractDoubleAssert testAbstractDoubleAssertActualIsNotEqualToExpected() { + return assertThat(1.0).isNotEqualTo(2.0); + } + AbstractDoubleAssert testAbstractDoubleAssertIsZero() { return assertThat(0.0).isEqualTo(0); } @@ -39,4 +47,20 @@ AbstractDoubleAssert testAbstractDoubleAssertIsNotZero() { AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return assertThat(0.0).isEqualTo(1); } + + AbstractDoubleAssert testAbstractDoubleAssertActualIsLessThanExpected() { + return assertThat(1.0).isLessThan(2.0); + } + + AbstractDoubleAssert testAbstractDoubleAssertActualIsLessThanOrEqualToExpected() { + return assertThat(1.0).isLessThanOrEqualTo(2.0); + } + + AbstractDoubleAssert testAbstractDoubleAssertActualIsGreaterThanExpected() { + return assertThat(1.0).isGreaterThan(2.0); + } + + AbstractDoubleAssert testAbstractDoubleAssertActualIsGreaterThanOrEqualToExpected() { + return assertThat(1.0).isGreaterThanOrEqualTo(2.0); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestInput.java index 54b4fac623..4df204f3ad 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestInput.java @@ -5,6 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractFloatAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -25,12 +26,20 @@ ImmutableSet> testAbstractFloatAssertIsEqualTo() { assertThat(0F).isCloseTo(1, offset(0F)), assertThat(0F).isCloseTo(1, withPercentage(0))); } + ImmutableSet> testAbstractFloatAssertActualIsEqualToExpected() { + return ImmutableSet.of(assertThat(1F == 2F).isTrue(), assertThat(1F != 2F).isFalse()); + } + ImmutableSet> testAbstractFloatAssertIsNotEqualTo() { return ImmutableSet.of( assertThat(0F).isNotCloseTo(1, offset(0F)), assertThat(0F).isNotCloseTo(1, withPercentage(0))); } + ImmutableSet> testAbstractFloatAssertActualIsNotEqualToExpected() { + return ImmutableSet.of(assertThat(1F != 2F).isTrue(), assertThat(1F == 2F).isFalse()); + } + AbstractFloatAssert testAbstractFloatAssertIsZero() { return assertThat(0F).isZero(); } @@ -42,4 +51,22 @@ AbstractFloatAssert testAbstractFloatAssertIsNotZero() { AbstractFloatAssert testAbstractFloatAssertIsOne() { return assertThat(0F).isOne(); } + + ImmutableSet> testAbstractFloatAssertActualIsLessThanExpected() { + return ImmutableSet.of(assertThat(1F < 2F).isTrue(), assertThat(1F >= 2F).isFalse()); + } + + ImmutableSet> + testAbstractFloatAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of(assertThat(1F <= 2F).isTrue(), assertThat(1F > 2F).isFalse()); + } + + ImmutableSet> testAbstractFloatAssertActualIsGreaterThanExpected() { + return ImmutableSet.of(assertThat(1F > 2F).isTrue(), assertThat(1F <= 2F).isFalse()); + } + + ImmutableSet> + testAbstractFloatAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of(assertThat(1F >= 2F).isTrue(), assertThat(1F < 2F).isFalse()); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestOutput.java index 40b9626372..0c1b8e8ad0 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestOutput.java @@ -24,10 +24,18 @@ ImmutableSet> testAbstractFloatAssertIsEqualTo() { return ImmutableSet.of(assertThat(0F).isEqualTo(1), assertThat(0F).isEqualTo(1)); } + AbstractFloatAssert testAbstractFloatAssertActualIsEqualToExpected() { + return assertThat(1F).isEqualTo(2F); + } + ImmutableSet> testAbstractFloatAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0F).isNotEqualTo(1), assertThat(0F).isNotEqualTo(1)); } + AbstractFloatAssert testAbstractFloatAssertActualIsNotEqualToExpected() { + return assertThat(1F).isNotEqualTo(2F); + } + AbstractFloatAssert testAbstractFloatAssertIsZero() { return assertThat(0F).isEqualTo(0); } @@ -39,4 +47,20 @@ AbstractFloatAssert testAbstractFloatAssertIsNotZero() { AbstractFloatAssert testAbstractFloatAssertIsOne() { return assertThat(0F).isEqualTo(1); } + + AbstractFloatAssert testAbstractFloatAssertActualIsLessThanExpected() { + return assertThat(1F).isLessThan(2F); + } + + AbstractFloatAssert testAbstractFloatAssertActualIsLessThanOrEqualToExpected() { + return assertThat(1F).isLessThanOrEqualTo(2F); + } + + AbstractFloatAssert testAbstractFloatAssertActualIsGreaterThanExpected() { + return assertThat(1F).isGreaterThan(2F); + } + + AbstractFloatAssert testAbstractFloatAssertActualIsGreaterThanOrEqualToExpected() { + return assertThat(1F).isGreaterThanOrEqualTo(2F); + } } From db914b6e583428b22d3eb95925a768de417e9368 Mon Sep 17 00:00:00 2001 From: CoolTomatos Date: Tue, 6 Sep 2022 12:44:23 +0200 Subject: [PATCH 03/16] Some more test coverage. --- .../RefasterTemplatesTest.java | 1 + .../AssertJComparableTemplatesTestInput.java | 35 ++++++++++++++++++ .../AssertJComparableTemplatesTestOutput.java | 37 +++++++++++++++++++ .../AssertJIntegerTemplatesTestInput.java | 27 ++++++++++++++ .../AssertJIntegerTemplatesTestOutput.java | 24 ++++++++++++ .../AssertJLongTemplatesTestInput.java | 26 +++++++++++++ .../AssertJLongTemplatesTestOutput.java | 24 ++++++++++++ .../AssertJShortTemplatesTestInput.java | 33 +++++++++++++++++ .../AssertJShortTemplatesTestOutput.java | 24 ++++++++++++ 9 files changed, 231 insertions(+) create mode 100644 error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplatesTestInput.java create mode 100644 error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplatesTestOutput.java diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.java index 7b78e49475..b0c235bdf0 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.java @@ -19,6 +19,7 @@ final class RefasterTemplatesTest { AssertJBooleanTemplates.class, AssertJByteTemplates.class, AssertJCharSequenceTemplates.class, + AssertJComparableTemplates.class, AssertJDoubleTemplates.class, AssertJEnumerableTemplates.class, AssertJFloatTemplates.class, 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 new file mode 100644 index 0000000000..d8af1e39bf --- /dev/null +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplatesTestInput.java @@ -0,0 +1,35 @@ +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.common.collect.ImmutableSet; +import java.math.BigDecimal; +import java.math.BigInteger; +import org.assertj.core.api.AbstractBooleanAssert; +import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; + +final class AssertJComparableTemplatesTest implements RefasterTemplateTestCase { + ImmutableSet> testAbstractComparableAssertActualIsLessThanExpected() { + return ImmutableSet.of( + assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) < 0).isTrue(), + assertThat(BigInteger.ZERO.compareTo(BigInteger.ONE) >= 0).isFalse()); + } + + ImmutableSet> + testAbstractComparableAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) <= 0).isTrue(), + assertThat(BigInteger.ZERO.compareTo(BigInteger.ONE) > 0).isFalse()); + } + + ImmutableSet> testAbstractComparableAssertActualIsGreaterThanExpected() { + return ImmutableSet.of( + assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) > 0).isTrue(), + assertThat(BigInteger.ZERO.compareTo(BigInteger.ONE) <= 0).isFalse()); + } + + ImmutableSet> + testAbstractComparableAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) >= 0).isTrue(), + assertThat(BigInteger.ZERO.compareTo(BigInteger.ONE) < 0).isFalse()); + } +} 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 new file mode 100644 index 0000000000..7e9f29fadc --- /dev/null +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJComparableTemplatesTestOutput.java @@ -0,0 +1,37 @@ +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.common.collect.ImmutableSet; +import java.math.BigDecimal; +import java.math.BigInteger; +import org.assertj.core.api.AbstractComparableAssert; +import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; + +final class AssertJComparableTempletesTest implements RefasterTemplateTestCase { + ImmutableSet> + testAbstractComparableAssertActualIsLessThanExpected() { + return ImmutableSet.of( + assertThat(BigDecimal.ZERO).isLessThan(BigDecimal.ONE), + assertThat(BigInteger.ZERO).isLessThan(BigInteger.ONE)); + } + + ImmutableSet> + testAbstractComparableAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat(BigDecimal.ZERO).isLessThanOrEqualTo(BigDecimal.ONE), + assertThat(BigInteger.ZERO).isLessThanOrEqualTo(BigInteger.ONE)); + } + + ImmutableSet> + testAbstractComparableAssertActualIsGreaterThanExpected() { + return ImmutableSet.of( + assertThat(BigDecimal.ZERO).isGreaterThan(BigDecimal.ONE), + assertThat(BigInteger.ZERO).isGreaterThan(BigInteger.ONE)); + } + + ImmutableSet> + testAbstractComparableAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat(BigDecimal.ZERO).isGreaterThanOrEqualTo(BigDecimal.ONE), + assertThat(BigInteger.ZERO).isGreaterThanOrEqualTo(BigInteger.ONE)); + } +} diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestInput.java index 6b4b7a38c3..a74c534f27 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestInput.java @@ -5,6 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractIntegerAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -19,11 +20,19 @@ ImmutableSet> testAbstractIntegerAssertIsEqualTo() { assertThat(0).isCloseTo(1, offset(0)), assertThat(0).isCloseTo(1, withPercentage(0))); } + ImmutableSet> testAbstractIntegerAssertActualIsEqualToExpected() { + return ImmutableSet.of(assertThat(1 == 2).isTrue(), assertThat(1 != 2).isFalse()); + } + ImmutableSet> testAbstractIntegerAssertIsNotEqualTo() { return ImmutableSet.of( assertThat(0).isNotCloseTo(1, offset(0)), assertThat(0).isNotCloseTo(1, withPercentage(0))); } + ImmutableSet> testAbstractIntegerAssertActualIsNotEqualToExpected() { + return ImmutableSet.of(assertThat(1 != 2).isTrue(), assertThat(1 == 2).isFalse()); + } + AbstractIntegerAssert testAbstractIntegerAssertIsZero() { return assertThat(0).isZero(); } @@ -35,4 +44,22 @@ AbstractIntegerAssert testAbstractIntegerAssertIsNotZero() { AbstractIntegerAssert testAbstractIntegerAssertIsOne() { return assertThat(0).isOne(); } + + ImmutableSet> testAbstractIntegerAssertActualIsLessThanExpected() { + return ImmutableSet.of(assertThat(1 < 2).isTrue(), assertThat(1 >= 2).isFalse()); + } + + ImmutableSet> + testAbstractIntegerAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of(assertThat(1 <= 2).isTrue(), assertThat(1 > 2).isFalse()); + } + + ImmutableSet> testAbstractIntegerAssertActualIsGreaterThanExpected() { + return ImmutableSet.of(assertThat(1 > 2).isTrue(), assertThat(1 <= 2).isFalse()); + } + + ImmutableSet> + testAbstractIntegerAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of(assertThat(1 >= 2).isTrue(), assertThat(1 < 2).isFalse()); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestOutput.java index 87613912ff..26a1b7ef54 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestOutput.java @@ -18,10 +18,18 @@ ImmutableSet> testAbstractIntegerAssertIsEqualTo() { return ImmutableSet.of(assertThat(0).isEqualTo(1), assertThat(0).isEqualTo(1)); } + AbstractIntegerAssert testAbstractIntegerAssertActualIsEqualToExpected() { + return assertThat(1).isEqualTo(2); + } + ImmutableSet> testAbstractIntegerAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0).isNotEqualTo(1), assertThat(0).isNotEqualTo(1)); } + AbstractIntegerAssert testAbstractIntegerAssertActualIsNotEqualToExpected() { + return assertThat(1).isNotEqualTo(2); + } + AbstractIntegerAssert testAbstractIntegerAssertIsZero() { return assertThat(0).isEqualTo(0); } @@ -33,4 +41,20 @@ AbstractIntegerAssert testAbstractIntegerAssertIsNotZero() { AbstractIntegerAssert testAbstractIntegerAssertIsOne() { return assertThat(0).isEqualTo(1); } + + AbstractIntegerAssert testAbstractIntegerAssertActualIsLessThanExpected() { + return assertThat(1).isLessThan(2); + } + + AbstractIntegerAssert testAbstractIntegerAssertActualIsLessThanOrEqualToExpected() { + return assertThat(1).isLessThanOrEqualTo(2); + } + + AbstractIntegerAssert testAbstractIntegerAssertActualIsGreaterThanExpected() { + return assertThat(1).isGreaterThan(2); + } + + AbstractIntegerAssert testAbstractIntegerAssertActualIsGreaterThanOrEqualToExpected() { + return assertThat(1).isGreaterThanOrEqualTo(2); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestInput.java index b55a52774f..42a2d08b3a 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestInput.java @@ -5,6 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractLongAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -19,12 +20,20 @@ ImmutableSet> testAbstractLongAssertIsEqualTo() { assertThat(0L).isCloseTo(1, offset(0L)), assertThat(0L).isCloseTo(1, withPercentage(0))); } + ImmutableSet> testAbstractLongAssertActualIsEqualToExpected() { + return ImmutableSet.of(assertThat(1L == 2L).isTrue(), assertThat(1L != 2L).isFalse()); + } + ImmutableSet> testAbstractLongAssertIsNotEqualTo() { return ImmutableSet.of( assertThat(0L).isNotCloseTo(1, offset(0L)), assertThat(0L).isNotCloseTo(1, withPercentage(0))); } + ImmutableSet> testAbstractLongAssertActualIsNotEqualToExpected() { + return ImmutableSet.of(assertThat(1L != 2L).isTrue(), assertThat(1L == 2L).isFalse()); + } + AbstractLongAssert testAbstractLongAssertIsZero() { return assertThat(0L).isZero(); } @@ -36,4 +45,21 @@ AbstractLongAssert testAbstractLongAssertIsNotZero() { AbstractLongAssert testAbstractLongAssertIsOne() { return assertThat(0L).isOne(); } + + ImmutableSet> testAbstractLongAssertActualIsLessThanExpected() { + return ImmutableSet.of(assertThat(1L < 2L).isTrue(), assertThat(1L >= 2L).isFalse()); + } + + ImmutableSet> testAbstractLongAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of(assertThat(1L <= 2L).isTrue(), assertThat(1L > 2L).isFalse()); + } + + ImmutableSet> testAbstractLongAssertActualIsGreaterThanExpected() { + return ImmutableSet.of(assertThat(1L > 2L).isTrue(), assertThat(1L <= 2L).isFalse()); + } + + ImmutableSet> + testAbstractLongAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of(assertThat(1L >= 2L).isTrue(), assertThat(1L < 2L).isFalse()); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestOutput.java index 1c7a851983..4e6c47582c 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestOutput.java @@ -18,10 +18,18 @@ ImmutableSet> testAbstractLongAssertIsEqualTo() { return ImmutableSet.of(assertThat(0L).isEqualTo(1), assertThat(0L).isEqualTo(1)); } + AbstractLongAssert testAbstractLongAssertActualIsEqualToExpected() { + return assertThat(1L).isEqualTo(2L); + } + ImmutableSet> testAbstractLongAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0L).isNotEqualTo(1), assertThat(0L).isNotEqualTo(1)); } + AbstractLongAssert testAbstractLongAssertActualIsNotEqualToExpected() { + return assertThat(1L).isNotEqualTo(2L); + } + AbstractLongAssert testAbstractLongAssertIsZero() { return assertThat(0L).isEqualTo(0); } @@ -33,4 +41,20 @@ AbstractLongAssert testAbstractLongAssertIsNotZero() { AbstractLongAssert testAbstractLongAssertIsOne() { return assertThat(0L).isEqualTo(1); } + + AbstractLongAssert testAbstractLongAssertActualIsLessThanExpected() { + return assertThat(1L).isLessThan(2L); + } + + AbstractLongAssert testAbstractLongAssertActualIsLessThanOrEqualToExpected() { + return assertThat(1L).isLessThanOrEqualTo(2L); + } + + AbstractLongAssert testAbstractLongAssertActualIsGreaterThanExpected() { + return assertThat(1L).isGreaterThan(2L); + } + + AbstractLongAssert testAbstractLongAssertActualIsGreaterThanOrEqualToExpected() { + return assertThat(1L).isGreaterThanOrEqualTo(2L); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestInput.java index e4fc739373..b6e175db71 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestInput.java @@ -5,6 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractShortAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -20,12 +21,22 @@ ImmutableSet> testAbstractShortAssertIsEqualTo() { assertThat((short) 0).isCloseTo((short) 1, withPercentage(0))); } + ImmutableSet> testAbstractShortAssertActualIsEqualToExpected() { + return ImmutableSet.of( + assertThat((short) 1 == (short) 2).isTrue(), assertThat((short) 1 != (short) 2).isFalse()); + } + ImmutableSet> testAbstractShortAssertIsNotEqualTo() { return ImmutableSet.of( assertThat((short) 0).isNotCloseTo((short) 1, offset((short) 0)), assertThat((short) 0).isNotCloseTo((short) 1, withPercentage(0))); } + ImmutableSet> testAbstractShortAssertActualIsNotEqualToExpected() { + return ImmutableSet.of( + assertThat((short) 1 != (short) 2).isTrue(), assertThat((short) 1 == (short) 2).isFalse()); + } + AbstractShortAssert testAbstractShortAssertIsZero() { return assertThat((short) 0).isZero(); } @@ -37,4 +48,26 @@ AbstractShortAssert testAbstractShortAssertIsNotZero() { AbstractShortAssert testAbstractShortAssertIsOne() { return assertThat((short) 0).isOne(); } + + ImmutableSet> testAbstractShortAssertActualIsLessThanExpected() { + return ImmutableSet.of( + assertThat((short) 1 < (short) 2).isTrue(), assertThat((short) 1 >= (short) 2).isFalse()); + } + + ImmutableSet> + testAbstractShortAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat((short) 1 <= (short) 2).isTrue(), assertThat((short) 1 > (short) 2).isFalse()); + } + + ImmutableSet> testAbstractShortAssertActualIsGreaterThanExpected() { + return ImmutableSet.of( + assertThat((short) 1 > (short) 2).isTrue(), assertThat((short) 1 <= (short) 2).isFalse()); + } + + ImmutableSet> + testAbstractShortAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat((short) 1 >= (short) 2).isTrue(), assertThat((short) 1 < (short) 2).isFalse()); + } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestOutput.java index 58beb71e24..cdd0d685aa 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestOutput.java @@ -19,12 +19,20 @@ ImmutableSet> testAbstractShortAssertIsEqualTo() { assertThat((short) 0).isEqualTo((short) 1), assertThat((short) 0).isEqualTo((short) 1)); } + AbstractShortAssert testAbstractShortAssertActualIsEqualToExpected() { + return assertThat((short) 1).isEqualTo((short) 2); + } + ImmutableSet> testAbstractShortAssertIsNotEqualTo() { return ImmutableSet.of( assertThat((short) 0).isNotEqualTo((short) 1), assertThat((short) 0).isNotEqualTo((short) 1)); } + AbstractShortAssert testAbstractShortAssertActualIsNotEqualToExpected() { + return assertThat((short) 1).isNotEqualTo((short) 2); + } + AbstractShortAssert testAbstractShortAssertIsZero() { return assertThat((short) 0).isEqualTo((short) 0); } @@ -36,4 +44,20 @@ AbstractShortAssert testAbstractShortAssertIsNotZero() { AbstractShortAssert testAbstractShortAssertIsOne() { return assertThat((short) 0).isEqualTo((short) 1); } + + AbstractShortAssert testAbstractShortAssertActualIsLessThanExpected() { + return assertThat((short) 1).isLessThan((short) 2); + } + + AbstractShortAssert testAbstractShortAssertActualIsLessThanOrEqualToExpected() { + return assertThat((short) 1).isLessThanOrEqualTo((short) 2); + } + + AbstractShortAssert testAbstractShortAssertActualIsGreaterThanExpected() { + return assertThat((short) 1).isGreaterThan((short) 2); + } + + AbstractShortAssert testAbstractShortAssertActualIsGreaterThanOrEqualToExpected() { + return assertThat((short) 1).isGreaterThanOrEqualTo((short) 2); + } } From 4ebbd40fd30c26f9a6ac1cce616337bad896897e Mon Sep 17 00:00:00 2001 From: CoolTomatos Date: Tue, 6 Sep 2022 14:16:20 +0200 Subject: [PATCH 04/16] Statically import the `Assertions.assertThat` method. --- .../refastertemplates/AssertJByteTemplates.java | 8 ++++++++ .../refastertemplates/AssertJComparableTemplates.java | 6 ++++++ .../refastertemplates/AssertJDoubleTemplates.java | 8 ++++++++ .../refastertemplates/AssertJFloatTemplates.java | 8 ++++++++ .../refastertemplates/AssertJIntegerTemplates.java | 8 ++++++++ .../refastertemplates/AssertJLongTemplates.java | 8 ++++++++ .../refastertemplates/AssertJShortTemplates.java | 8 ++++++++ 7 files changed, 54 insertions(+) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJByteTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJByteTemplates.java index 39425c5a8c..ad601491d9 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJByteTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJByteTemplates.java @@ -1,5 +1,6 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; @@ -7,6 +8,7 @@ import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import com.google.errorprone.refaster.annotation.UseImportPolicy; import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractByteAssert; @@ -34,6 +36,7 @@ AbstractBooleanAssert before(byte actual, byte expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractByteAssert after(byte actual, byte expected) { return assertThat(actual).isEqualTo(expected); } @@ -61,6 +64,7 @@ AbstractBooleanAssert before(byte actual, byte expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractByteAssert after(byte actual, byte expected) { return assertThat(actual).isNotEqualTo(expected); } @@ -110,6 +114,7 @@ AbstractBooleanAssert before(byte actual, byte expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractByteAssert after(byte actual, byte expected) { return assertThat(actual).isLessThan(expected); } @@ -123,6 +128,7 @@ AbstractBooleanAssert before(byte actual, byte expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractByteAssert after(byte actual, byte expected) { return assertThat(actual).isLessThanOrEqualTo(expected); } @@ -136,6 +142,7 @@ AbstractBooleanAssert before(byte actual, byte expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractByteAssert after(byte actual, byte expected) { return assertThat(actual).isGreaterThan(expected); } @@ -149,6 +156,7 @@ AbstractBooleanAssert before(byte actual, byte expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractByteAssert after(byte actual, byte expected) { return assertThat(actual).isGreaterThanOrEqualTo(expected); } 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 605a2032a5..5a81df7101 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 @@ -1,10 +1,12 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import com.google.errorprone.refaster.annotation.UseImportPolicy; import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractComparableAssert; @@ -21,6 +23,7 @@ AbstractBooleanAssert before(T actual, T expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractComparableAssert after(T actual, T expected) { return assertThat(actual).isLessThan(expected); } @@ -36,6 +39,7 @@ AbstractBooleanAssert before(T actual, T expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractComparableAssert after(T actual, T expected) { return assertThat(actual).isLessThanOrEqualTo(expected); } @@ -51,6 +55,7 @@ AbstractBooleanAssert before(T actual, T expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractComparableAssert after(T actual, T expected) { return assertThat(actual).isGreaterThan(expected); } @@ -66,6 +71,7 @@ AbstractBooleanAssert before(T actual, T expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractComparableAssert after(T actual, T expected) { return assertThat(actual).isGreaterThanOrEqualTo(expected); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java index 0d90a166b8..e03b7c25c7 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java @@ -1,5 +1,6 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; @@ -7,6 +8,7 @@ import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import com.google.errorprone.refaster.annotation.UseImportPolicy; import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractDoubleAssert; import org.assertj.core.data.Offset; @@ -55,6 +57,7 @@ AbstractBooleanAssert before(double actual, double expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractDoubleAssert after(double actual, double expected) { return assertThat(actual).isEqualTo(expected); } @@ -82,6 +85,7 @@ AbstractBooleanAssert before(double actual, double expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractDoubleAssert after(double actual, double expected) { return assertThat(actual).isNotEqualTo(expected); } @@ -131,6 +135,7 @@ AbstractBooleanAssert before(double actual, double expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractDoubleAssert after(double actual, double expected) { return assertThat(actual).isLessThan(expected); } @@ -144,6 +149,7 @@ AbstractBooleanAssert before(double actual, double expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractDoubleAssert after(double actual, double expected) { return assertThat(actual).isLessThanOrEqualTo(expected); } @@ -157,6 +163,7 @@ AbstractBooleanAssert before(double actual, double expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractDoubleAssert after(double actual, double expected) { return assertThat(actual).isGreaterThan(expected); } @@ -170,6 +177,7 @@ AbstractBooleanAssert before(double actual, double expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractDoubleAssert after(double actual, double expected) { return assertThat(actual).isGreaterThanOrEqualTo(expected); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplates.java index 0b2fd0603a..06afbc36db 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplates.java @@ -1,5 +1,6 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; @@ -7,6 +8,7 @@ import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import com.google.errorprone.refaster.annotation.UseImportPolicy; import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractFloatAssert; import org.assertj.core.data.Offset; @@ -55,6 +57,7 @@ AbstractBooleanAssert before(float actual, float expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractFloatAssert after(float actual, float expected) { return assertThat(actual).isEqualTo(expected); } @@ -81,6 +84,7 @@ AbstractBooleanAssert before(float actual, float expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractFloatAssert after(float actual, float expected) { return assertThat(actual).isNotEqualTo(expected); } @@ -130,6 +134,7 @@ AbstractBooleanAssert before(float actual, float expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractFloatAssert after(float actual, float expected) { return assertThat(actual).isLessThan(expected); } @@ -143,6 +148,7 @@ AbstractBooleanAssert before(float actual, float expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractFloatAssert after(float actual, float expected) { return assertThat(actual).isLessThanOrEqualTo(expected); } @@ -156,6 +162,7 @@ AbstractBooleanAssert before(float actual, float expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractFloatAssert after(float actual, float expected) { return assertThat(actual).isGreaterThan(expected); } @@ -169,6 +176,7 @@ AbstractBooleanAssert before(float actual, float expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractFloatAssert after(float actual, float expected) { return assertThat(actual).isGreaterThanOrEqualTo(expected); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplates.java index e633edeb9e..59aea8a756 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplates.java @@ -1,5 +1,6 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; @@ -7,6 +8,7 @@ import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import com.google.errorprone.refaster.annotation.UseImportPolicy; import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractIntegerAssert; @@ -34,6 +36,7 @@ AbstractBooleanAssert before(int actual, int expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractIntegerAssert after(int actual, int expected) { return assertThat(actual).isEqualTo(expected); } @@ -60,6 +63,7 @@ AbstractBooleanAssert before(int actual, int expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractIntegerAssert after(int actual, int expected) { return assertThat(actual).isNotEqualTo(expected); } @@ -109,6 +113,7 @@ AbstractBooleanAssert before(int actual, int expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractIntegerAssert after(int actual, int expected) { return assertThat(actual).isLessThan(expected); } @@ -122,6 +127,7 @@ AbstractBooleanAssert before(int actual, int expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractIntegerAssert after(int actual, int expected) { return assertThat(actual).isLessThanOrEqualTo(expected); } @@ -135,6 +141,7 @@ AbstractBooleanAssert before(int actual, int expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractIntegerAssert after(int actual, int expected) { return assertThat(actual).isGreaterThan(expected); } @@ -148,6 +155,7 @@ AbstractBooleanAssert before(int actual, int expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractIntegerAssert after(int actual, int expected) { return assertThat(actual).isGreaterThanOrEqualTo(expected); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJLongTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJLongTemplates.java index 4d7d56e5dc..0484ac5fab 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJLongTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJLongTemplates.java @@ -1,5 +1,6 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; @@ -7,6 +8,7 @@ import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import com.google.errorprone.refaster.annotation.UseImportPolicy; import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractLongAssert; @@ -34,6 +36,7 @@ AbstractBooleanAssert before(long actual, long expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractLongAssert after(long actual, long expected) { return assertThat(actual).isEqualTo(expected); } @@ -60,6 +63,7 @@ AbstractBooleanAssert before(long actual, long expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractLongAssert after(long actual, long expected) { return assertThat(actual).isNotEqualTo(expected); } @@ -109,6 +113,7 @@ AbstractBooleanAssert before(long actual, long expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractLongAssert after(long actual, long expected) { return assertThat(actual).isLessThan(expected); } @@ -122,6 +127,7 @@ AbstractBooleanAssert before(long actual, long expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractLongAssert after(long actual, long expected) { return assertThat(actual).isLessThanOrEqualTo(expected); } @@ -135,6 +141,7 @@ AbstractBooleanAssert before(long actual, long expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractLongAssert after(long actual, long expected) { return assertThat(actual).isGreaterThan(expected); } @@ -148,6 +155,7 @@ AbstractBooleanAssert before(long actual, long expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractLongAssert after(long actual, long expected) { return assertThat(actual).isGreaterThanOrEqualTo(expected); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJShortTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJShortTemplates.java index e9fd4e7651..83b9d482ca 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJShortTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJShortTemplates.java @@ -1,5 +1,6 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; @@ -7,6 +8,7 @@ import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import com.google.errorprone.refaster.annotation.UseImportPolicy; import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractShortAssert; @@ -34,6 +36,7 @@ AbstractBooleanAssert before(short actual, short expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractShortAssert after(short actual, short expected) { return assertThat(actual).isEqualTo(expected); } @@ -61,6 +64,7 @@ AbstractBooleanAssert before(short actual, short expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractShortAssert after(short actual, short expected) { return assertThat(actual).isNotEqualTo(expected); } @@ -110,6 +114,7 @@ AbstractBooleanAssert before(short actual, short expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractShortAssert after(short actual, short expected) { return assertThat(actual).isLessThan(expected); } @@ -123,6 +128,7 @@ AbstractBooleanAssert before(short actual, short expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractShortAssert after(short actual, short expected) { return assertThat(actual).isLessThanOrEqualTo(expected); } @@ -136,6 +142,7 @@ AbstractBooleanAssert before(short actual, short expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractShortAssert after(short actual, short expected) { return assertThat(actual).isGreaterThan(expected); } @@ -149,6 +156,7 @@ AbstractBooleanAssert before(short actual, short expected) { } @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractShortAssert after(short actual, short expected) { return assertThat(actual).isGreaterThanOrEqualTo(expected); } From ee371069d8eae8ee2b2471b55ee74583ab60f2bf Mon Sep 17 00:00:00 2001 From: CoolTomatos Date: Tue, 6 Sep 2022 14:27:46 +0200 Subject: [PATCH 05/16] Update the test output. --- .../AssertJByteTemplatesTestInput.java | 15 ++++---- .../AssertJByteTemplatesTestOutput.java | 33 ++++++++++------- .../AssertJComparableTemplatesTestInput.java | 19 +++++----- .../AssertJComparableTemplatesTestOutput.java | 21 +++++------ .../AssertJDoubleTemplatesTestInput.java | 15 ++++---- .../AssertJDoubleTemplatesTestOutput.java | 28 ++++++++------- .../AssertJFloatTemplatesTestInput.java | 16 ++++----- .../AssertJFloatTemplatesTestOutput.java | 27 +++++++------- .../AssertJIntegerTemplatesTestInput.java | 15 ++++---- .../AssertJIntegerTemplatesTestOutput.java | 28 ++++++++------- .../AssertJLongTemplatesTestInput.java | 15 ++++---- .../AssertJLongTemplatesTestOutput.java | 27 +++++++------- .../AssertJShortTemplatesTestInput.java | 16 ++++----- .../AssertJShortTemplatesTestOutput.java | 35 ++++++++++++------- 14 files changed, 166 insertions(+), 144 deletions(-) diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestInput.java index 9772672657..0a16ac2179 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestInput.java @@ -5,7 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractBooleanAssert; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractByteAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -21,7 +21,7 @@ ImmutableSet> testAbstractByteAssertIsEqualTo() { assertThat((byte) 0).isCloseTo((byte) 1, withPercentage(0))); } - ImmutableSet> testAbstractByteAssertActualIsEqualToExpected() { + ImmutableSet> testAbstractByteAssertActualIsEqualToExpected() { return ImmutableSet.of( assertThat((byte) 1 == (byte) 2).isTrue(), assertThat((byte) 1 != (byte) 2).isFalse()); } @@ -32,7 +32,7 @@ ImmutableSet> testAbstractByteAssertIsNotEqualTo() { assertThat((byte) 0).isNotCloseTo((byte) 1, withPercentage(0))); } - ImmutableSet> testAbstractByteAssertActualIsNotEqualToExpected() { + ImmutableSet> testAbstractByteAssertActualIsNotEqualToExpected() { return ImmutableSet.of( assertThat((byte) 1 != (byte) 2).isTrue(), assertThat((byte) 1 == (byte) 2).isFalse()); } @@ -49,23 +49,22 @@ AbstractByteAssert testAbstractByteAssertIsOne() { return assertThat((byte) 0).isOne(); } - ImmutableSet> testAbstractByteAssertActualIsLessThanExpected() { + ImmutableSet> testAbstractByteAssertActualIsLessThanExpected() { return ImmutableSet.of( assertThat((byte) 1 < (byte) 2).isTrue(), assertThat((byte) 1 >= (byte) 2).isFalse()); } - ImmutableSet> testAbstractByteAssertActualIsLessThanOrEqualToExpected() { + ImmutableSet> testAbstractByteAssertActualIsLessThanOrEqualToExpected() { return ImmutableSet.of( assertThat((byte) 1 <= (byte) 2).isTrue(), assertThat((byte) 1 > (byte) 2).isFalse()); } - ImmutableSet> testAbstractByteAssertActualIsGreaterThanExpected() { + ImmutableSet> testAbstractByteAssertActualIsGreaterThanExpected() { return ImmutableSet.of( assertThat((byte) 1 > (byte) 2).isTrue(), assertThat((byte) 1 <= (byte) 2).isFalse()); } - ImmutableSet> - testAbstractByteAssertActualIsGreaterThanOrEqualToExpected() { + ImmutableSet> testAbstractByteAssertActualIsGreaterThanOrEqualToExpected() { return ImmutableSet.of( assertThat((byte) 1 >= (byte) 2).isTrue(), assertThat((byte) 1 < (byte) 2).isFalse()); } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestOutput.java index a2965377e4..0aec1c12e9 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestOutput.java @@ -5,6 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractByteAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -19,8 +20,9 @@ ImmutableSet> testAbstractByteAssertIsEqualTo() { assertThat((byte) 0).isEqualTo((byte) 1), assertThat((byte) 0).isEqualTo((byte) 1)); } - AbstractByteAssert testAbstractByteAssertActualIsEqualToExpected() { - return assertThat((byte) 1).isEqualTo((byte) 2); + ImmutableSet> testAbstractByteAssertActualIsEqualToExpected() { + return ImmutableSet.of( + assertThat((byte) 1).isEqualTo((byte) 2), assertThat((byte) 1).isEqualTo((byte) 2)); } ImmutableSet> testAbstractByteAssertIsNotEqualTo() { @@ -28,8 +30,9 @@ ImmutableSet> testAbstractByteAssertIsNotEqualTo() { assertThat((byte) 0).isNotEqualTo((byte) 1), assertThat((byte) 0).isNotEqualTo((byte) 1)); } - AbstractByteAssert testAbstractByteAssertActualIsNotEqualToExpected() { - return assertThat((byte) 1).isNotEqualTo((byte) 2); + ImmutableSet> testAbstractByteAssertActualIsNotEqualToExpected() { + return ImmutableSet.of( + assertThat((byte) 1).isNotEqualTo((byte) 2), assertThat((byte) 1).isNotEqualTo((byte) 2)); } AbstractByteAssert testAbstractByteAssertIsZero() { @@ -44,19 +47,25 @@ AbstractByteAssert testAbstractByteAssertIsOne() { return assertThat((byte) 0).isEqualTo((byte) 1); } - AbstractByteAssert testAbstractByteAssertActualIsLessThanExpected() { - return assertThat((byte) 1).isLessThan((byte) 2); + ImmutableSet> testAbstractByteAssertActualIsLessThanExpected() { + return ImmutableSet.of( + assertThat((byte) 1).isLessThan((byte) 2), assertThat((byte) 1).isLessThan((byte) 2)); } - AbstractByteAssert testAbstractByteAssertActualIsLessThanOrEqualToExpected() { - return assertThat((byte) 1).isLessThanOrEqualTo((byte) 2); + ImmutableSet> testAbstractByteAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), + assertThat((byte) 1).isLessThanOrEqualTo((byte) 2)); } - AbstractByteAssert testAbstractByteAssertActualIsGreaterThanExpected() { - return assertThat((byte) 1).isGreaterThan((byte) 2); + ImmutableSet> testAbstractByteAssertActualIsGreaterThanExpected() { + return ImmutableSet.of( + assertThat((byte) 1).isGreaterThan((byte) 2), assertThat((byte) 1).isGreaterThan((byte) 2)); } - AbstractByteAssert testAbstractByteAssertActualIsGreaterThanOrEqualToExpected() { - return assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2); + ImmutableSet> testAbstractByteAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), + assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2)); } } 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 d8af1e39bf..56acb25903 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 @@ -2,34 +2,33 @@ import com.google.common.collect.ImmutableSet; import java.math.BigDecimal; -import java.math.BigInteger; -import org.assertj.core.api.AbstractBooleanAssert; +import org.assertj.core.api.AbstractAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; final class AssertJComparableTemplatesTest implements RefasterTemplateTestCase { - ImmutableSet> testAbstractComparableAssertActualIsLessThanExpected() { + ImmutableSet> testAbstractComparableAssertActualIsLessThanExpected() { return ImmutableSet.of( assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) < 0).isTrue(), - assertThat(BigInteger.ZERO.compareTo(BigInteger.ONE) >= 0).isFalse()); + assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) >= 0).isFalse()); } - ImmutableSet> + ImmutableSet> testAbstractComparableAssertActualIsLessThanOrEqualToExpected() { return ImmutableSet.of( assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) <= 0).isTrue(), - assertThat(BigInteger.ZERO.compareTo(BigInteger.ONE) > 0).isFalse()); + assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) > 0).isFalse()); } - ImmutableSet> testAbstractComparableAssertActualIsGreaterThanExpected() { + ImmutableSet> testAbstractComparableAssertActualIsGreaterThanExpected() { return ImmutableSet.of( assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) > 0).isTrue(), - assertThat(BigInteger.ZERO.compareTo(BigInteger.ONE) <= 0).isFalse()); + assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) <= 0).isFalse()); } - ImmutableSet> + ImmutableSet> testAbstractComparableAssertActualIsGreaterThanOrEqualToExpected() { return ImmutableSet.of( assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) >= 0).isTrue(), - assertThat(BigInteger.ZERO.compareTo(BigInteger.ONE) < 0).isFalse()); + assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) < 0).isFalse()); } } 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 7e9f29fadc..756daf98dd 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 @@ -2,36 +2,33 @@ import com.google.common.collect.ImmutableSet; import java.math.BigDecimal; -import java.math.BigInteger; -import org.assertj.core.api.AbstractComparableAssert; +import org.assertj.core.api.AbstractAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; final class AssertJComparableTempletesTest implements RefasterTemplateTestCase { - ImmutableSet> - testAbstractComparableAssertActualIsLessThanExpected() { + ImmutableSet> testAbstractComparableAssertActualIsLessThanExpected() { return ImmutableSet.of( assertThat(BigDecimal.ZERO).isLessThan(BigDecimal.ONE), - assertThat(BigInteger.ZERO).isLessThan(BigInteger.ONE)); + assertThat(BigDecimal.ZERO).isLessThan(BigDecimal.ONE)); } - ImmutableSet> + ImmutableSet> testAbstractComparableAssertActualIsLessThanOrEqualToExpected() { return ImmutableSet.of( assertThat(BigDecimal.ZERO).isLessThanOrEqualTo(BigDecimal.ONE), - assertThat(BigInteger.ZERO).isLessThanOrEqualTo(BigInteger.ONE)); + assertThat(BigDecimal.ZERO).isLessThanOrEqualTo(BigDecimal.ONE)); } - ImmutableSet> - testAbstractComparableAssertActualIsGreaterThanExpected() { + ImmutableSet> testAbstractComparableAssertActualIsGreaterThanExpected() { return ImmutableSet.of( assertThat(BigDecimal.ZERO).isGreaterThan(BigDecimal.ONE), - assertThat(BigInteger.ZERO).isGreaterThan(BigInteger.ONE)); + assertThat(BigDecimal.ZERO).isGreaterThan(BigDecimal.ONE)); } - ImmutableSet> + ImmutableSet> testAbstractComparableAssertActualIsGreaterThanOrEqualToExpected() { return ImmutableSet.of( assertThat(BigDecimal.ZERO).isGreaterThanOrEqualTo(BigDecimal.ONE), - assertThat(BigInteger.ZERO).isGreaterThanOrEqualTo(BigInteger.ONE)); + assertThat(BigDecimal.ZERO).isGreaterThanOrEqualTo(BigDecimal.ONE)); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java index 9b688df007..31e59ccf74 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java @@ -5,7 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractBooleanAssert; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractDoubleAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -26,7 +26,7 @@ ImmutableSet> testAbstractDoubleAssertIsEqualTo() { assertThat(0.0).isCloseTo(1, offset(0.0)), assertThat(0.0).isCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractDoubleAssertActualIsEqualToExpected() { + ImmutableSet> testAbstractDoubleAssertActualIsEqualToExpected() { return ImmutableSet.of(assertThat(1.0 == 2.0).isTrue(), assertThat(1.0 != 2.0).isFalse()); } @@ -36,7 +36,7 @@ ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { assertThat(0.0).isNotCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractDoubleAssertActualIsNotEqualToExpected() { + ImmutableSet> testAbstractDoubleAssertActualIsNotEqualToExpected() { return ImmutableSet.of(assertThat(1.0 != 2.0).isTrue(), assertThat(1.0 == 2.0).isFalse()); } @@ -52,20 +52,19 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return assertThat(0.0).isOne(); } - ImmutableSet> testAbstractDoubleAssertActualIsLessThanExpected() { + ImmutableSet> testAbstractDoubleAssertActualIsLessThanExpected() { return ImmutableSet.of(assertThat(1.0 < 2.0).isTrue(), assertThat(1.0 >= 2.0).isFalse()); } - ImmutableSet> - testAbstractDoubleAssertActualIsLessThanOrEqualToExpected() { + ImmutableSet> testAbstractDoubleAssertActualIsLessThanOrEqualToExpected() { return ImmutableSet.of(assertThat(1.0 <= 2.0).isTrue(), assertThat(1.0 > 2.0).isFalse()); } - ImmutableSet> testAbstractDoubleAssertActualIsGreaterThanExpected() { + ImmutableSet> testAbstractDoubleAssertActualIsGreaterThanExpected() { return ImmutableSet.of(assertThat(1.0 > 2.0).isTrue(), assertThat(1.0 <= 2.0).isFalse()); } - ImmutableSet> + ImmutableSet> testAbstractDoubleAssertActualIsGreaterThanOrEqualToExpected() { return ImmutableSet.of(assertThat(1.0 >= 2.0).isTrue(), assertThat(1.0 < 2.0).isFalse()); } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java index d043ecf110..8d441ecc2d 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java @@ -5,6 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractDoubleAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -24,16 +25,16 @@ ImmutableSet> testAbstractDoubleAssertIsEqualTo() { return ImmutableSet.of(assertThat(0.0).isEqualTo(1), assertThat(0.0).isEqualTo(1)); } - AbstractDoubleAssert testAbstractDoubleAssertActualIsEqualToExpected() { - return assertThat(1.0).isEqualTo(2.0); + ImmutableSet> testAbstractDoubleAssertActualIsEqualToExpected() { + return ImmutableSet.of(assertThat(1.0).isEqualTo(2.0), assertThat(1.0).isEqualTo(2.0)); } ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0.0).isNotEqualTo(1), assertThat(0.0).isNotEqualTo(1)); } - AbstractDoubleAssert testAbstractDoubleAssertActualIsNotEqualToExpected() { - return assertThat(1.0).isNotEqualTo(2.0); + ImmutableSet> testAbstractDoubleAssertActualIsNotEqualToExpected() { + return ImmutableSet.of(assertThat(1.0).isNotEqualTo(2.0), assertThat(1.0).isNotEqualTo(2.0)); } AbstractDoubleAssert testAbstractDoubleAssertIsZero() { @@ -48,19 +49,22 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return assertThat(0.0).isEqualTo(1); } - AbstractDoubleAssert testAbstractDoubleAssertActualIsLessThanExpected() { - return assertThat(1.0).isLessThan(2.0); + ImmutableSet> testAbstractDoubleAssertActualIsLessThanExpected() { + return ImmutableSet.of(assertThat(1.0).isLessThan(2.0), assertThat(1.0).isLessThan(2.0)); } - AbstractDoubleAssert testAbstractDoubleAssertActualIsLessThanOrEqualToExpected() { - return assertThat(1.0).isLessThanOrEqualTo(2.0); + ImmutableSet> testAbstractDoubleAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat(1.0).isLessThanOrEqualTo(2.0), assertThat(1.0).isLessThanOrEqualTo(2.0)); } - AbstractDoubleAssert testAbstractDoubleAssertActualIsGreaterThanExpected() { - return assertThat(1.0).isGreaterThan(2.0); + ImmutableSet> testAbstractDoubleAssertActualIsGreaterThanExpected() { + return ImmutableSet.of(assertThat(1.0).isGreaterThan(2.0), assertThat(1.0).isGreaterThan(2.0)); } - AbstractDoubleAssert testAbstractDoubleAssertActualIsGreaterThanOrEqualToExpected() { - return assertThat(1.0).isGreaterThanOrEqualTo(2.0); + ImmutableSet> + testAbstractDoubleAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat(1.0).isGreaterThanOrEqualTo(2.0), assertThat(1.0).isGreaterThanOrEqualTo(2.0)); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestInput.java index 4df204f3ad..e1d2731071 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestInput.java @@ -5,7 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractBooleanAssert; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractFloatAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -26,7 +26,7 @@ ImmutableSet> testAbstractFloatAssertIsEqualTo() { assertThat(0F).isCloseTo(1, offset(0F)), assertThat(0F).isCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractFloatAssertActualIsEqualToExpected() { + ImmutableSet> testAbstractFloatAssertActualIsEqualToExpected() { return ImmutableSet.of(assertThat(1F == 2F).isTrue(), assertThat(1F != 2F).isFalse()); } @@ -36,7 +36,7 @@ ImmutableSet> testAbstractFloatAssertIsNotEqualTo() { assertThat(0F).isNotCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractFloatAssertActualIsNotEqualToExpected() { + ImmutableSet> testAbstractFloatAssertActualIsNotEqualToExpected() { return ImmutableSet.of(assertThat(1F != 2F).isTrue(), assertThat(1F == 2F).isFalse()); } @@ -52,21 +52,19 @@ AbstractFloatAssert testAbstractFloatAssertIsOne() { return assertThat(0F).isOne(); } - ImmutableSet> testAbstractFloatAssertActualIsLessThanExpected() { + ImmutableSet> testAbstractFloatAssertActualIsLessThanExpected() { return ImmutableSet.of(assertThat(1F < 2F).isTrue(), assertThat(1F >= 2F).isFalse()); } - ImmutableSet> - testAbstractFloatAssertActualIsLessThanOrEqualToExpected() { + ImmutableSet> testAbstractFloatAssertActualIsLessThanOrEqualToExpected() { return ImmutableSet.of(assertThat(1F <= 2F).isTrue(), assertThat(1F > 2F).isFalse()); } - ImmutableSet> testAbstractFloatAssertActualIsGreaterThanExpected() { + ImmutableSet> testAbstractFloatAssertActualIsGreaterThanExpected() { return ImmutableSet.of(assertThat(1F > 2F).isTrue(), assertThat(1F <= 2F).isFalse()); } - ImmutableSet> - testAbstractFloatAssertActualIsGreaterThanOrEqualToExpected() { + ImmutableSet> testAbstractFloatAssertActualIsGreaterThanOrEqualToExpected() { return ImmutableSet.of(assertThat(1F >= 2F).isTrue(), assertThat(1F < 2F).isFalse()); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestOutput.java index 0c1b8e8ad0..c1a86f0eb4 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestOutput.java @@ -5,6 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractFloatAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -24,16 +25,16 @@ ImmutableSet> testAbstractFloatAssertIsEqualTo() { return ImmutableSet.of(assertThat(0F).isEqualTo(1), assertThat(0F).isEqualTo(1)); } - AbstractFloatAssert testAbstractFloatAssertActualIsEqualToExpected() { - return assertThat(1F).isEqualTo(2F); + ImmutableSet> testAbstractFloatAssertActualIsEqualToExpected() { + return ImmutableSet.of(assertThat(1F).isEqualTo(2F), assertThat(1F).isEqualTo(2F)); } ImmutableSet> testAbstractFloatAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0F).isNotEqualTo(1), assertThat(0F).isNotEqualTo(1)); } - AbstractFloatAssert testAbstractFloatAssertActualIsNotEqualToExpected() { - return assertThat(1F).isNotEqualTo(2F); + ImmutableSet> testAbstractFloatAssertActualIsNotEqualToExpected() { + return ImmutableSet.of(assertThat(1F).isNotEqualTo(2F), assertThat(1F).isNotEqualTo(2F)); } AbstractFloatAssert testAbstractFloatAssertIsZero() { @@ -48,19 +49,21 @@ AbstractFloatAssert testAbstractFloatAssertIsOne() { return assertThat(0F).isEqualTo(1); } - AbstractFloatAssert testAbstractFloatAssertActualIsLessThanExpected() { - return assertThat(1F).isLessThan(2F); + ImmutableSet> testAbstractFloatAssertActualIsLessThanExpected() { + return ImmutableSet.of(assertThat(1F).isLessThan(2F), assertThat(1F).isLessThan(2F)); } - AbstractFloatAssert testAbstractFloatAssertActualIsLessThanOrEqualToExpected() { - return assertThat(1F).isLessThanOrEqualTo(2F); + ImmutableSet> testAbstractFloatAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat(1F).isLessThanOrEqualTo(2F), assertThat(1F).isLessThanOrEqualTo(2F)); } - AbstractFloatAssert testAbstractFloatAssertActualIsGreaterThanExpected() { - return assertThat(1F).isGreaterThan(2F); + ImmutableSet> testAbstractFloatAssertActualIsGreaterThanExpected() { + return ImmutableSet.of(assertThat(1F).isGreaterThan(2F), assertThat(1F).isGreaterThan(2F)); } - AbstractFloatAssert testAbstractFloatAssertActualIsGreaterThanOrEqualToExpected() { - return assertThat(1F).isGreaterThanOrEqualTo(2F); + ImmutableSet> testAbstractFloatAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat(1F).isGreaterThanOrEqualTo(2F), assertThat(1F).isGreaterThanOrEqualTo(2F)); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestInput.java index a74c534f27..41d8377d76 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestInput.java @@ -5,7 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractBooleanAssert; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractIntegerAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -20,7 +20,7 @@ ImmutableSet> testAbstractIntegerAssertIsEqualTo() { assertThat(0).isCloseTo(1, offset(0)), assertThat(0).isCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractIntegerAssertActualIsEqualToExpected() { + ImmutableSet> testAbstractIntegerAssertActualIsEqualToExpected() { return ImmutableSet.of(assertThat(1 == 2).isTrue(), assertThat(1 != 2).isFalse()); } @@ -29,7 +29,7 @@ ImmutableSet> testAbstractIntegerAssertIsNotEqualTo() { assertThat(0).isNotCloseTo(1, offset(0)), assertThat(0).isNotCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractIntegerAssertActualIsNotEqualToExpected() { + ImmutableSet> testAbstractIntegerAssertActualIsNotEqualToExpected() { return ImmutableSet.of(assertThat(1 != 2).isTrue(), assertThat(1 == 2).isFalse()); } @@ -45,20 +45,19 @@ AbstractIntegerAssert testAbstractIntegerAssertIsOne() { return assertThat(0).isOne(); } - ImmutableSet> testAbstractIntegerAssertActualIsLessThanExpected() { + ImmutableSet> testAbstractIntegerAssertActualIsLessThanExpected() { return ImmutableSet.of(assertThat(1 < 2).isTrue(), assertThat(1 >= 2).isFalse()); } - ImmutableSet> - testAbstractIntegerAssertActualIsLessThanOrEqualToExpected() { + ImmutableSet> testAbstractIntegerAssertActualIsLessThanOrEqualToExpected() { return ImmutableSet.of(assertThat(1 <= 2).isTrue(), assertThat(1 > 2).isFalse()); } - ImmutableSet> testAbstractIntegerAssertActualIsGreaterThanExpected() { + ImmutableSet> testAbstractIntegerAssertActualIsGreaterThanExpected() { return ImmutableSet.of(assertThat(1 > 2).isTrue(), assertThat(1 <= 2).isFalse()); } - ImmutableSet> + ImmutableSet> testAbstractIntegerAssertActualIsGreaterThanOrEqualToExpected() { return ImmutableSet.of(assertThat(1 >= 2).isTrue(), assertThat(1 < 2).isFalse()); } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestOutput.java index 26a1b7ef54..62a034a052 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestOutput.java @@ -5,6 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractIntegerAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -18,16 +19,16 @@ ImmutableSet> testAbstractIntegerAssertIsEqualTo() { return ImmutableSet.of(assertThat(0).isEqualTo(1), assertThat(0).isEqualTo(1)); } - AbstractIntegerAssert testAbstractIntegerAssertActualIsEqualToExpected() { - return assertThat(1).isEqualTo(2); + ImmutableSet> testAbstractIntegerAssertActualIsEqualToExpected() { + return ImmutableSet.of(assertThat(1).isEqualTo(2), assertThat(1).isEqualTo(2)); } ImmutableSet> testAbstractIntegerAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0).isNotEqualTo(1), assertThat(0).isNotEqualTo(1)); } - AbstractIntegerAssert testAbstractIntegerAssertActualIsNotEqualToExpected() { - return assertThat(1).isNotEqualTo(2); + ImmutableSet> testAbstractIntegerAssertActualIsNotEqualToExpected() { + return ImmutableSet.of(assertThat(1).isNotEqualTo(2), assertThat(1).isNotEqualTo(2)); } AbstractIntegerAssert testAbstractIntegerAssertIsZero() { @@ -42,19 +43,22 @@ AbstractIntegerAssert testAbstractIntegerAssertIsOne() { return assertThat(0).isEqualTo(1); } - AbstractIntegerAssert testAbstractIntegerAssertActualIsLessThanExpected() { - return assertThat(1).isLessThan(2); + ImmutableSet> testAbstractIntegerAssertActualIsLessThanExpected() { + return ImmutableSet.of(assertThat(1).isLessThan(2), assertThat(1).isLessThan(2)); } - AbstractIntegerAssert testAbstractIntegerAssertActualIsLessThanOrEqualToExpected() { - return assertThat(1).isLessThanOrEqualTo(2); + ImmutableSet> testAbstractIntegerAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat(1).isLessThanOrEqualTo(2), assertThat(1).isLessThanOrEqualTo(2)); } - AbstractIntegerAssert testAbstractIntegerAssertActualIsGreaterThanExpected() { - return assertThat(1).isGreaterThan(2); + ImmutableSet> testAbstractIntegerAssertActualIsGreaterThanExpected() { + return ImmutableSet.of(assertThat(1).isGreaterThan(2), assertThat(1).isGreaterThan(2)); } - AbstractIntegerAssert testAbstractIntegerAssertActualIsGreaterThanOrEqualToExpected() { - return assertThat(1).isGreaterThanOrEqualTo(2); + ImmutableSet> + testAbstractIntegerAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat(1).isGreaterThanOrEqualTo(2), assertThat(1).isGreaterThanOrEqualTo(2)); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestInput.java index 42a2d08b3a..6c9fb99242 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestInput.java @@ -5,7 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractBooleanAssert; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractLongAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -20,7 +20,7 @@ ImmutableSet> testAbstractLongAssertIsEqualTo() { assertThat(0L).isCloseTo(1, offset(0L)), assertThat(0L).isCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractLongAssertActualIsEqualToExpected() { + ImmutableSet> testAbstractLongAssertActualIsEqualToExpected() { return ImmutableSet.of(assertThat(1L == 2L).isTrue(), assertThat(1L != 2L).isFalse()); } @@ -30,7 +30,7 @@ ImmutableSet> testAbstractLongAssertIsNotEqualTo() { assertThat(0L).isNotCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractLongAssertActualIsNotEqualToExpected() { + ImmutableSet> testAbstractLongAssertActualIsNotEqualToExpected() { return ImmutableSet.of(assertThat(1L != 2L).isTrue(), assertThat(1L == 2L).isFalse()); } @@ -46,20 +46,19 @@ AbstractLongAssert testAbstractLongAssertIsOne() { return assertThat(0L).isOne(); } - ImmutableSet> testAbstractLongAssertActualIsLessThanExpected() { + ImmutableSet> testAbstractLongAssertActualIsLessThanExpected() { return ImmutableSet.of(assertThat(1L < 2L).isTrue(), assertThat(1L >= 2L).isFalse()); } - ImmutableSet> testAbstractLongAssertActualIsLessThanOrEqualToExpected() { + ImmutableSet> testAbstractLongAssertActualIsLessThanOrEqualToExpected() { return ImmutableSet.of(assertThat(1L <= 2L).isTrue(), assertThat(1L > 2L).isFalse()); } - ImmutableSet> testAbstractLongAssertActualIsGreaterThanExpected() { + ImmutableSet> testAbstractLongAssertActualIsGreaterThanExpected() { return ImmutableSet.of(assertThat(1L > 2L).isTrue(), assertThat(1L <= 2L).isFalse()); } - ImmutableSet> - testAbstractLongAssertActualIsGreaterThanOrEqualToExpected() { + ImmutableSet> testAbstractLongAssertActualIsGreaterThanOrEqualToExpected() { return ImmutableSet.of(assertThat(1L >= 2L).isTrue(), assertThat(1L < 2L).isFalse()); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestOutput.java index 4e6c47582c..b8948febb0 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestOutput.java @@ -5,6 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractLongAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -18,16 +19,16 @@ ImmutableSet> testAbstractLongAssertIsEqualTo() { return ImmutableSet.of(assertThat(0L).isEqualTo(1), assertThat(0L).isEqualTo(1)); } - AbstractLongAssert testAbstractLongAssertActualIsEqualToExpected() { - return assertThat(1L).isEqualTo(2L); + ImmutableSet> testAbstractLongAssertActualIsEqualToExpected() { + return ImmutableSet.of(assertThat(1L).isEqualTo(2L), assertThat(1L).isEqualTo(2L)); } ImmutableSet> testAbstractLongAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0L).isNotEqualTo(1), assertThat(0L).isNotEqualTo(1)); } - AbstractLongAssert testAbstractLongAssertActualIsNotEqualToExpected() { - return assertThat(1L).isNotEqualTo(2L); + ImmutableSet> testAbstractLongAssertActualIsNotEqualToExpected() { + return ImmutableSet.of(assertThat(1L).isNotEqualTo(2L), assertThat(1L).isNotEqualTo(2L)); } AbstractLongAssert testAbstractLongAssertIsZero() { @@ -42,19 +43,21 @@ AbstractLongAssert testAbstractLongAssertIsOne() { return assertThat(0L).isEqualTo(1); } - AbstractLongAssert testAbstractLongAssertActualIsLessThanExpected() { - return assertThat(1L).isLessThan(2L); + ImmutableSet> testAbstractLongAssertActualIsLessThanExpected() { + return ImmutableSet.of(assertThat(1L).isLessThan(2L), assertThat(1L).isLessThan(2L)); } - AbstractLongAssert testAbstractLongAssertActualIsLessThanOrEqualToExpected() { - return assertThat(1L).isLessThanOrEqualTo(2L); + ImmutableSet> testAbstractLongAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat(1L).isLessThanOrEqualTo(2L), assertThat(1L).isLessThanOrEqualTo(2L)); } - AbstractLongAssert testAbstractLongAssertActualIsGreaterThanExpected() { - return assertThat(1L).isGreaterThan(2L); + ImmutableSet> testAbstractLongAssertActualIsGreaterThanExpected() { + return ImmutableSet.of(assertThat(1L).isGreaterThan(2L), assertThat(1L).isGreaterThan(2L)); } - AbstractLongAssert testAbstractLongAssertActualIsGreaterThanOrEqualToExpected() { - return assertThat(1L).isGreaterThanOrEqualTo(2L); + ImmutableSet> testAbstractLongAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat(1L).isGreaterThanOrEqualTo(2L), assertThat(1L).isGreaterThanOrEqualTo(2L)); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestInput.java index b6e175db71..1006be9ddb 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestInput.java @@ -5,7 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractBooleanAssert; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractShortAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -21,7 +21,7 @@ ImmutableSet> testAbstractShortAssertIsEqualTo() { assertThat((short) 0).isCloseTo((short) 1, withPercentage(0))); } - ImmutableSet> testAbstractShortAssertActualIsEqualToExpected() { + ImmutableSet> testAbstractShortAssertActualIsEqualToExpected() { return ImmutableSet.of( assertThat((short) 1 == (short) 2).isTrue(), assertThat((short) 1 != (short) 2).isFalse()); } @@ -32,7 +32,7 @@ ImmutableSet> testAbstractShortAssertIsNotEqualTo() { assertThat((short) 0).isNotCloseTo((short) 1, withPercentage(0))); } - ImmutableSet> testAbstractShortAssertActualIsNotEqualToExpected() { + ImmutableSet> testAbstractShortAssertActualIsNotEqualToExpected() { return ImmutableSet.of( assertThat((short) 1 != (short) 2).isTrue(), assertThat((short) 1 == (short) 2).isFalse()); } @@ -49,24 +49,22 @@ AbstractShortAssert testAbstractShortAssertIsOne() { return assertThat((short) 0).isOne(); } - ImmutableSet> testAbstractShortAssertActualIsLessThanExpected() { + ImmutableSet> testAbstractShortAssertActualIsLessThanExpected() { return ImmutableSet.of( assertThat((short) 1 < (short) 2).isTrue(), assertThat((short) 1 >= (short) 2).isFalse()); } - ImmutableSet> - testAbstractShortAssertActualIsLessThanOrEqualToExpected() { + ImmutableSet> testAbstractShortAssertActualIsLessThanOrEqualToExpected() { return ImmutableSet.of( assertThat((short) 1 <= (short) 2).isTrue(), assertThat((short) 1 > (short) 2).isFalse()); } - ImmutableSet> testAbstractShortAssertActualIsGreaterThanExpected() { + ImmutableSet> testAbstractShortAssertActualIsGreaterThanExpected() { return ImmutableSet.of( assertThat((short) 1 > (short) 2).isTrue(), assertThat((short) 1 <= (short) 2).isFalse()); } - ImmutableSet> - testAbstractShortAssertActualIsGreaterThanOrEqualToExpected() { + ImmutableSet> testAbstractShortAssertActualIsGreaterThanOrEqualToExpected() { return ImmutableSet.of( assertThat((short) 1 >= (short) 2).isTrue(), assertThat((short) 1 < (short) 2).isFalse()); } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestOutput.java index cdd0d685aa..2552312b45 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestOutput.java @@ -5,6 +5,7 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractShortAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -19,8 +20,9 @@ ImmutableSet> testAbstractShortAssertIsEqualTo() { assertThat((short) 0).isEqualTo((short) 1), assertThat((short) 0).isEqualTo((short) 1)); } - AbstractShortAssert testAbstractShortAssertActualIsEqualToExpected() { - return assertThat((short) 1).isEqualTo((short) 2); + ImmutableSet> testAbstractShortAssertActualIsEqualToExpected() { + return ImmutableSet.of( + assertThat((short) 1).isEqualTo((short) 2), assertThat((short) 1).isEqualTo((short) 2)); } ImmutableSet> testAbstractShortAssertIsNotEqualTo() { @@ -29,8 +31,10 @@ ImmutableSet> testAbstractShortAssertIsNotEqualTo() { assertThat((short) 0).isNotEqualTo((short) 1)); } - AbstractShortAssert testAbstractShortAssertActualIsNotEqualToExpected() { - return assertThat((short) 1).isNotEqualTo((short) 2); + ImmutableSet> testAbstractShortAssertActualIsNotEqualToExpected() { + return ImmutableSet.of( + assertThat((short) 1).isNotEqualTo((short) 2), + assertThat((short) 1).isNotEqualTo((short) 2)); } AbstractShortAssert testAbstractShortAssertIsZero() { @@ -45,19 +49,26 @@ AbstractShortAssert testAbstractShortAssertIsOne() { return assertThat((short) 0).isEqualTo((short) 1); } - AbstractShortAssert testAbstractShortAssertActualIsLessThanExpected() { - return assertThat((short) 1).isLessThan((short) 2); + ImmutableSet> testAbstractShortAssertActualIsLessThanExpected() { + return ImmutableSet.of( + assertThat((short) 1).isLessThan((short) 2), assertThat((short) 1).isLessThan((short) 2)); } - AbstractShortAssert testAbstractShortAssertActualIsLessThanOrEqualToExpected() { - return assertThat((short) 1).isLessThanOrEqualTo((short) 2); + ImmutableSet> testAbstractShortAssertActualIsLessThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat((short) 1).isLessThanOrEqualTo((short) 2), + assertThat((short) 1).isLessThanOrEqualTo((short) 2)); } - AbstractShortAssert testAbstractShortAssertActualIsGreaterThanExpected() { - return assertThat((short) 1).isGreaterThan((short) 2); + ImmutableSet> testAbstractShortAssertActualIsGreaterThanExpected() { + return ImmutableSet.of( + assertThat((short) 1).isGreaterThan((short) 2), + assertThat((short) 1).isGreaterThan((short) 2)); } - AbstractShortAssert testAbstractShortAssertActualIsGreaterThanOrEqualToExpected() { - return assertThat((short) 1).isGreaterThanOrEqualTo((short) 2); + ImmutableSet> testAbstractShortAssertActualIsGreaterThanOrEqualToExpected() { + return ImmutableSet.of( + assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), + assertThat((short) 1).isGreaterThanOrEqualTo((short) 2)); } } From df895c9624975d529454a6094e6a46034ed87786 Mon Sep 17 00:00:00 2001 From: CoolTomatos Date: Tue, 6 Sep 2022 14:56:38 +0200 Subject: [PATCH 06/16] Fixing a typo. --- .../AssertJComparableTemplatesTestInput.java | 2 ++ .../AssertJComparableTemplatesTestOutput.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) 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 56acb25903..fdbf75a9a0 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 @@ -1,3 +1,5 @@ +package tech.picnic.errorprone.refastertemplates; + import static org.assertj.core.api.Assertions.assertThat; import com.google.common.collect.ImmutableSet; 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 756daf98dd..048c0f57f0 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 @@ -1,3 +1,5 @@ +package tech.picnic.errorprone.refastertemplates; + import static org.assertj.core.api.Assertions.assertThat; import com.google.common.collect.ImmutableSet; @@ -5,7 +7,7 @@ import org.assertj.core.api.AbstractAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; -final class AssertJComparableTempletesTest implements RefasterTemplateTestCase { +final class AssertJComparableTemplatesTest implements RefasterTemplateTestCase { ImmutableSet> testAbstractComparableAssertActualIsLessThanExpected() { return ImmutableSet.of( assertThat(BigDecimal.ZERO).isLessThan(BigDecimal.ONE), From 87f32c99303ab822dc16a3dcead63f009b91969e Mon Sep 17 00:00:00 2001 From: CoolTomatos Date: Tue, 6 Sep 2022 17:21:14 +0200 Subject: [PATCH 07/16] Trying to fix the build. --- .../AssertJByteTemplates.java | 88 ------------------- .../AssertJComparableTemplates.java | 27 ++---- .../AssertJFloatTemplates.java | 88 ------------------- .../AssertJIntegerTemplates.java | 88 ------------------- .../AssertJLongTemplates.java | 88 ------------------- .../AssertJShortTemplates.java | 88 ------------------- .../AssertJByteTemplatesTestInput.java | 31 ------- .../AssertJByteTemplatesTestOutput.java | 33 ------- .../AssertJComparableTemplatesTestInput.java | 27 ++---- .../AssertJComparableTemplatesTestOutput.java | 27 ++---- .../AssertJFloatTemplatesTestInput.java | 25 ------ .../AssertJFloatTemplatesTestOutput.java | 27 ------ .../AssertJIntegerTemplatesTestInput.java | 26 ------ .../AssertJIntegerTemplatesTestOutput.java | 28 ------ .../AssertJLongTemplatesTestInput.java | 25 ------ .../AssertJLongTemplatesTestOutput.java | 27 ------ .../AssertJShortTemplatesTestInput.java | 31 ------- .../AssertJShortTemplatesTestOutput.java | 35 -------- 18 files changed, 25 insertions(+), 784 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJByteTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJByteTemplates.java index ad601491d9..220e3001e7 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJByteTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJByteTemplates.java @@ -1,15 +1,11 @@ package tech.picnic.errorprone.refastertemplates; -import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; -import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractByteAssert; final class AssertJByteTemplates { @@ -28,20 +24,6 @@ AbstractByteAssert after(AbstractByteAssert byteAssert, byte n) { } } - static final class AbstractByteAssertActualIsEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(byte actual, byte expected) { - return Refaster.anyOf( - assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractByteAssert after(byte actual, byte expected) { - return assertThat(actual).isEqualTo(expected); - } - } - static final class AbstractByteAssertIsNotEqualTo { @BeforeTemplate AbstractByteAssert before(AbstractByteAssert byteAssert, byte n) { @@ -56,20 +38,6 @@ AbstractByteAssert after(AbstractByteAssert byteAssert, byte n) { } } - static final class AbstractByteAssertActualIsNotEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(byte actual, byte expected) { - return Refaster.anyOf( - assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractByteAssert after(byte actual, byte expected) { - return assertThat(actual).isNotEqualTo(expected); - } - } - static final class AbstractByteAssertIsZero { @BeforeTemplate AbstractByteAssert before(AbstractByteAssert byteAssert) { @@ -105,60 +73,4 @@ AbstractByteAssert after(AbstractByteAssert byteAssert) { return byteAssert.isEqualTo((byte) 1); } } - - static final class AbstractByteAssertActualIsLessThanExpected { - @BeforeTemplate - AbstractBooleanAssert before(byte actual, byte expected) { - return Refaster.anyOf( - assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractByteAssert after(byte actual, byte expected) { - return assertThat(actual).isLessThan(expected); - } - } - - static final class AbstractByteAssertActualIsLessThanOrEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(byte actual, byte expected) { - return Refaster.anyOf( - assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractByteAssert after(byte actual, byte expected) { - return assertThat(actual).isLessThanOrEqualTo(expected); - } - } - - static final class AbstractByteAssertActualIsGreaterThanExpected { - @BeforeTemplate - AbstractBooleanAssert before(byte actual, byte expected) { - return Refaster.anyOf( - assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractByteAssert after(byte actual, byte expected) { - return assertThat(actual).isGreaterThan(expected); - } - } - - static final class AbstractByteAssertActualIsGreaterThanOrEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(byte actual, byte expected) { - return Refaster.anyOf( - assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractByteAssert after(byte actual, byte expected) { - return assertThat(actual).isGreaterThanOrEqualTo(expected); - } - } } 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 5a81df7101..e10eb1577d 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 @@ -3,12 +3,11 @@ import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; -import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; import com.google.errorprone.refaster.annotation.UseImportPolicy; -import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractComparableAssert; +import org.assertj.core.api.AbstractIntegerAssert; final class AssertJComparableTemplates { private AssertJComparableTemplates() {} @@ -16,10 +15,8 @@ private AssertJComparableTemplates() {} static final class AbstractComparableAssertActualIsLessThanExpected< T extends Comparable> { @BeforeTemplate - AbstractBooleanAssert before(T actual, T expected) { - return Refaster.anyOf( - assertThat(actual.compareTo(expected) < 0).isTrue(), - assertThat(actual.compareTo(expected) >= 0).isFalse()); + AbstractIntegerAssert before(T actual, T expected) { + return assertThat(actual.compareTo(expected)).isNegative(); } @AfterTemplate @@ -32,10 +29,8 @@ AbstractBooleanAssert before(T actual, T expected) { static final class AbstractComparableAssertActualIsLessThanOrEqualToExpected< T extends Comparable> { @BeforeTemplate - AbstractBooleanAssert before(T actual, T expected) { - return Refaster.anyOf( - assertThat(actual.compareTo(expected) <= 0).isTrue(), - assertThat(actual.compareTo(expected) > 0).isFalse()); + AbstractIntegerAssert before(T actual, T expected) { + return assertThat(actual.compareTo(expected)).isNotPositive(); } @AfterTemplate @@ -48,10 +43,8 @@ AbstractBooleanAssert before(T actual, T expected) { static final class AbstractComparableAssertActualIsGreaterThanExpected< T extends Comparable> { @BeforeTemplate - AbstractBooleanAssert before(T actual, T expected) { - return Refaster.anyOf( - assertThat(actual.compareTo(expected) > 0).isTrue(), - assertThat(actual.compareTo(expected) <= 0).isFalse()); + AbstractIntegerAssert before(T actual, T expected) { + return assertThat(actual.compareTo(expected)).isPositive(); } @AfterTemplate @@ -64,10 +57,8 @@ AbstractBooleanAssert before(T actual, T expected) { static final class AbstractComparableAssertActualIsGreaterThanOrEqualToExpected< T extends Comparable> { @BeforeTemplate - AbstractBooleanAssert before(T actual, T expected) { - return Refaster.anyOf( - assertThat(actual.compareTo(expected) >= 0).isTrue(), - assertThat(actual.compareTo(expected) < 0).isFalse()); + AbstractIntegerAssert before(T actual, T expected) { + return assertThat(actual.compareTo(expected)).isNotNegative(); } @AfterTemplate diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplates.java index 06afbc36db..6de54b99cb 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplates.java @@ -1,15 +1,11 @@ package tech.picnic.errorprone.refastertemplates; -import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; -import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractFloatAssert; import org.assertj.core.data.Offset; @@ -49,20 +45,6 @@ AbstractFloatAssert after(AbstractFloatAssert floatAssert, float n) { } } - static final class AbstractFloatAssertActualIsEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(float actual, float expected) { - return Refaster.anyOf( - assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractFloatAssert after(float actual, float expected) { - return assertThat(actual).isEqualTo(expected); - } - } - static final class AbstractFloatAssertIsNotEqualTo { @BeforeTemplate AbstractFloatAssert before(AbstractFloatAssert floatAssert, float n) { @@ -76,20 +58,6 @@ AbstractFloatAssert after(AbstractFloatAssert floatAssert, float n) { } } - static final class AbstractFloatAssertActualIsNotEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(float actual, float expected) { - return Refaster.anyOf( - assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractFloatAssert after(float actual, float expected) { - return assertThat(actual).isNotEqualTo(expected); - } - } - static final class AbstractFloatAssertIsZero { @BeforeTemplate AbstractFloatAssert before(AbstractFloatAssert floatAssert) { @@ -125,60 +93,4 @@ AbstractFloatAssert after(AbstractFloatAssert floatAssert) { return floatAssert.isEqualTo(1); } } - - static final class AbstractFloatAssertActualIsLessThanExpected { - @BeforeTemplate - AbstractBooleanAssert before(float actual, float expected) { - return Refaster.anyOf( - assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractFloatAssert after(float actual, float expected) { - return assertThat(actual).isLessThan(expected); - } - } - - static final class AbstractFloatAssertActualIsLessThanOrEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(float actual, float expected) { - return Refaster.anyOf( - assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractFloatAssert after(float actual, float expected) { - return assertThat(actual).isLessThanOrEqualTo(expected); - } - } - - static final class AbstractFloatAssertActualIsGreaterThanExpected { - @BeforeTemplate - AbstractBooleanAssert before(float actual, float expected) { - return Refaster.anyOf( - assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractFloatAssert after(float actual, float expected) { - return assertThat(actual).isGreaterThan(expected); - } - } - - static final class AbstractFloatAssertActualIsGreaterThanOrEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(float actual, float expected) { - return Refaster.anyOf( - assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractFloatAssert after(float actual, float expected) { - return assertThat(actual).isGreaterThanOrEqualTo(expected); - } - } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplates.java index 59aea8a756..f46ac40564 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplates.java @@ -1,15 +1,11 @@ package tech.picnic.errorprone.refastertemplates; -import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; -import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractIntegerAssert; final class AssertJIntegerTemplates { @@ -28,20 +24,6 @@ AbstractIntegerAssert after(AbstractIntegerAssert intAssert, int n) { } } - static final class AbstractIntegerAssertActualIsEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(int actual, int expected) { - return Refaster.anyOf( - assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractIntegerAssert after(int actual, int expected) { - return assertThat(actual).isEqualTo(expected); - } - } - static final class AbstractIntegerAssertIsNotEqualTo { @BeforeTemplate AbstractIntegerAssert before(AbstractIntegerAssert intAssert, int n) { @@ -55,20 +37,6 @@ AbstractIntegerAssert after(AbstractIntegerAssert intAssert, int n) { } } - static final class AbstractIntegerAssertActualIsNotEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(int actual, int expected) { - return Refaster.anyOf( - assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractIntegerAssert after(int actual, int expected) { - return assertThat(actual).isNotEqualTo(expected); - } - } - static final class AbstractIntegerAssertIsZero { @BeforeTemplate AbstractIntegerAssert before(AbstractIntegerAssert intAssert) { @@ -104,60 +72,4 @@ AbstractIntegerAssert after(AbstractIntegerAssert intAssert) { return intAssert.isEqualTo(1); } } - - static final class AbstractIntegerAssertActualIsLessThanExpected { - @BeforeTemplate - AbstractBooleanAssert before(int actual, int expected) { - return Refaster.anyOf( - assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractIntegerAssert after(int actual, int expected) { - return assertThat(actual).isLessThan(expected); - } - } - - static final class AbstractIntegerAssertActualIsLessThanOrEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(int actual, int expected) { - return Refaster.anyOf( - assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractIntegerAssert after(int actual, int expected) { - return assertThat(actual).isLessThanOrEqualTo(expected); - } - } - - static final class AbstractIntegerAssertActualIsGreaterThanExpected { - @BeforeTemplate - AbstractBooleanAssert before(int actual, int expected) { - return Refaster.anyOf( - assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractIntegerAssert after(int actual, int expected) { - return assertThat(actual).isGreaterThan(expected); - } - } - - static final class AbstractIntegerAssertActualIsGreaterThanOrEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(int actual, int expected) { - return Refaster.anyOf( - assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractIntegerAssert after(int actual, int expected) { - return assertThat(actual).isGreaterThanOrEqualTo(expected); - } - } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJLongTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJLongTemplates.java index 0484ac5fab..e992886dff 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJLongTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJLongTemplates.java @@ -1,15 +1,11 @@ package tech.picnic.errorprone.refastertemplates; -import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; -import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractLongAssert; final class AssertJLongTemplates { @@ -28,20 +24,6 @@ AbstractLongAssert after(AbstractLongAssert longAssert, long n) { } } - static final class AbstractLongAssertActualIsEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(long actual, long expected) { - return Refaster.anyOf( - assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractLongAssert after(long actual, long expected) { - return assertThat(actual).isEqualTo(expected); - } - } - static final class AbstractLongAssertIsNotEqualTo { @BeforeTemplate AbstractLongAssert before(AbstractLongAssert longAssert, long n) { @@ -55,20 +37,6 @@ AbstractLongAssert after(AbstractLongAssert longAssert, long n) { } } - static final class AbstractLongAssertActualIsNotEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(long actual, long expected) { - return Refaster.anyOf( - assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractLongAssert after(long actual, long expected) { - return assertThat(actual).isNotEqualTo(expected); - } - } - static final class AbstractLongAssertIsZero { @BeforeTemplate AbstractLongAssert before(AbstractLongAssert longAssert) { @@ -104,60 +72,4 @@ AbstractLongAssert after(AbstractLongAssert longAssert) { return longAssert.isEqualTo(1); } } - - static final class AbstractLongAssertActualIsLessThanExpected { - @BeforeTemplate - AbstractBooleanAssert before(long actual, long expected) { - return Refaster.anyOf( - assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractLongAssert after(long actual, long expected) { - return assertThat(actual).isLessThan(expected); - } - } - - static final class AbstractLongAssertActualIsLessThanOrEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(long actual, long expected) { - return Refaster.anyOf( - assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractLongAssert after(long actual, long expected) { - return assertThat(actual).isLessThanOrEqualTo(expected); - } - } - - static final class AbstractLongAssertActualIsGreaterThanExpected { - @BeforeTemplate - AbstractBooleanAssert before(long actual, long expected) { - return Refaster.anyOf( - assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractLongAssert after(long actual, long expected) { - return assertThat(actual).isGreaterThan(expected); - } - } - - static final class AbstractLongAssertActualIsGreaterThanOrEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(long actual, long expected) { - return Refaster.anyOf( - assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractLongAssert after(long actual, long expected) { - return assertThat(actual).isGreaterThanOrEqualTo(expected); - } - } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJShortTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJShortTemplates.java index 83b9d482ca..017f897b93 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJShortTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJShortTemplates.java @@ -1,15 +1,11 @@ package tech.picnic.errorprone.refastertemplates; -import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; -import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractShortAssert; final class AssertJShortTemplates { @@ -28,20 +24,6 @@ AbstractShortAssert after(AbstractShortAssert shortAssert, short n) { } } - static final class AbstractShortAssertActualIsEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(short actual, short expected) { - return Refaster.anyOf( - assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractShortAssert after(short actual, short expected) { - return assertThat(actual).isEqualTo(expected); - } - } - static final class AbstractShortAssertIsNotEqualTo { @BeforeTemplate AbstractShortAssert before(AbstractShortAssert shortAssert, short n) { @@ -56,20 +38,6 @@ AbstractShortAssert after(AbstractShortAssert shortAssert, short n) { } } - static final class AbstractShortAssertActualIsNotEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(short actual, short expected) { - return Refaster.anyOf( - assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractShortAssert after(short actual, short expected) { - return assertThat(actual).isNotEqualTo(expected); - } - } - static final class AbstractShortAssertIsZero { @BeforeTemplate AbstractShortAssert before(AbstractShortAssert shortAssert) { @@ -105,60 +73,4 @@ AbstractShortAssert after(AbstractShortAssert shortAssert) { return shortAssert.isEqualTo((short) 1); } } - - static final class AbstractShortAssertActualIsLessThanExpected { - @BeforeTemplate - AbstractBooleanAssert before(short actual, short expected) { - return Refaster.anyOf( - assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractShortAssert after(short actual, short expected) { - return assertThat(actual).isLessThan(expected); - } - } - - static final class AbstractShortAssertActualIsLessThanOrEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(short actual, short expected) { - return Refaster.anyOf( - assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractShortAssert after(short actual, short expected) { - return assertThat(actual).isLessThanOrEqualTo(expected); - } - } - - static final class AbstractShortAssertActualIsGreaterThanExpected { - @BeforeTemplate - AbstractBooleanAssert before(short actual, short expected) { - return Refaster.anyOf( - assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractShortAssert after(short actual, short expected) { - return assertThat(actual).isGreaterThan(expected); - } - } - - static final class AbstractShortAssertActualIsGreaterThanOrEqualToExpected { - @BeforeTemplate - AbstractBooleanAssert before(short actual, short expected) { - return Refaster.anyOf( - assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractShortAssert after(short actual, short expected) { - return assertThat(actual).isGreaterThanOrEqualTo(expected); - } - } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestInput.java index 0a16ac2179..f9a7b2607e 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestInput.java @@ -5,7 +5,6 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractByteAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -21,22 +20,12 @@ ImmutableSet> testAbstractByteAssertIsEqualTo() { assertThat((byte) 0).isCloseTo((byte) 1, withPercentage(0))); } - ImmutableSet> testAbstractByteAssertActualIsEqualToExpected() { - return ImmutableSet.of( - assertThat((byte) 1 == (byte) 2).isTrue(), assertThat((byte) 1 != (byte) 2).isFalse()); - } - ImmutableSet> testAbstractByteAssertIsNotEqualTo() { return ImmutableSet.of( assertThat((byte) 0).isNotCloseTo((byte) 1, offset((byte) 0)), assertThat((byte) 0).isNotCloseTo((byte) 1, withPercentage(0))); } - ImmutableSet> testAbstractByteAssertActualIsNotEqualToExpected() { - return ImmutableSet.of( - assertThat((byte) 1 != (byte) 2).isTrue(), assertThat((byte) 1 == (byte) 2).isFalse()); - } - AbstractByteAssert testAbstractByteAssertIsZero() { return assertThat((byte) 0).isZero(); } @@ -48,24 +37,4 @@ AbstractByteAssert testAbstractByteAssertIsNotZero() { AbstractByteAssert testAbstractByteAssertIsOne() { return assertThat((byte) 0).isOne(); } - - ImmutableSet> testAbstractByteAssertActualIsLessThanExpected() { - return ImmutableSet.of( - assertThat((byte) 1 < (byte) 2).isTrue(), assertThat((byte) 1 >= (byte) 2).isFalse()); - } - - ImmutableSet> testAbstractByteAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat((byte) 1 <= (byte) 2).isTrue(), assertThat((byte) 1 > (byte) 2).isFalse()); - } - - ImmutableSet> testAbstractByteAssertActualIsGreaterThanExpected() { - return ImmutableSet.of( - assertThat((byte) 1 > (byte) 2).isTrue(), assertThat((byte) 1 <= (byte) 2).isFalse()); - } - - ImmutableSet> testAbstractByteAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat((byte) 1 >= (byte) 2).isTrue(), assertThat((byte) 1 < (byte) 2).isFalse()); - } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestOutput.java index 0aec1c12e9..ea274127a4 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJByteTemplatesTestOutput.java @@ -5,7 +5,6 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractByteAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -20,21 +19,11 @@ ImmutableSet> testAbstractByteAssertIsEqualTo() { assertThat((byte) 0).isEqualTo((byte) 1), assertThat((byte) 0).isEqualTo((byte) 1)); } - ImmutableSet> testAbstractByteAssertActualIsEqualToExpected() { - return ImmutableSet.of( - assertThat((byte) 1).isEqualTo((byte) 2), assertThat((byte) 1).isEqualTo((byte) 2)); - } - ImmutableSet> testAbstractByteAssertIsNotEqualTo() { return ImmutableSet.of( assertThat((byte) 0).isNotEqualTo((byte) 1), assertThat((byte) 0).isNotEqualTo((byte) 1)); } - ImmutableSet> testAbstractByteAssertActualIsNotEqualToExpected() { - return ImmutableSet.of( - assertThat((byte) 1).isNotEqualTo((byte) 2), assertThat((byte) 1).isNotEqualTo((byte) 2)); - } - AbstractByteAssert testAbstractByteAssertIsZero() { return assertThat((byte) 0).isEqualTo((byte) 0); } @@ -46,26 +35,4 @@ AbstractByteAssert testAbstractByteAssertIsNotZero() { AbstractByteAssert testAbstractByteAssertIsOne() { return assertThat((byte) 0).isEqualTo((byte) 1); } - - ImmutableSet> testAbstractByteAssertActualIsLessThanExpected() { - return ImmutableSet.of( - assertThat((byte) 1).isLessThan((byte) 2), assertThat((byte) 1).isLessThan((byte) 2)); - } - - ImmutableSet> testAbstractByteAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), - assertThat((byte) 1).isLessThanOrEqualTo((byte) 2)); - } - - ImmutableSet> testAbstractByteAssertActualIsGreaterThanExpected() { - return ImmutableSet.of( - assertThat((byte) 1).isGreaterThan((byte) 2), assertThat((byte) 1).isGreaterThan((byte) 2)); - } - - ImmutableSet> testAbstractByteAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), - assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2)); - } } 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 fdbf75a9a0..2bb51ef449 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 @@ -2,35 +2,24 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.google.common.collect.ImmutableSet; import java.math.BigDecimal; import org.assertj.core.api.AbstractAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; final class AssertJComparableTemplatesTest implements RefasterTemplateTestCase { - ImmutableSet> testAbstractComparableAssertActualIsLessThanExpected() { - return ImmutableSet.of( - assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) < 0).isTrue(), - assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) >= 0).isFalse()); + AbstractAssert testAbstractComparableAssertActualIsLessThanExpected() { + return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isNegative(); } - ImmutableSet> - testAbstractComparableAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) <= 0).isTrue(), - assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) > 0).isFalse()); + AbstractAssert testAbstractComparableAssertActualIsLessThanOrEqualToExpected() { + return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isNotPositive(); } - ImmutableSet> testAbstractComparableAssertActualIsGreaterThanExpected() { - return ImmutableSet.of( - assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) > 0).isTrue(), - assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) <= 0).isFalse()); + AbstractAssert testAbstractComparableAssertActualIsGreaterThanExpected() { + return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isPositive(); } - ImmutableSet> - testAbstractComparableAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) >= 0).isTrue(), - assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE) < 0).isFalse()); + AbstractAssert testAbstractComparableAssertActualIsGreaterThanOrEqualToExpected() { + 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 048c0f57f0..85b41a5dee 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 @@ -2,35 +2,24 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.google.common.collect.ImmutableSet; import java.math.BigDecimal; import org.assertj.core.api.AbstractAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; final class AssertJComparableTemplatesTest implements RefasterTemplateTestCase { - ImmutableSet> testAbstractComparableAssertActualIsLessThanExpected() { - return ImmutableSet.of( - assertThat(BigDecimal.ZERO).isLessThan(BigDecimal.ONE), - assertThat(BigDecimal.ZERO).isLessThan(BigDecimal.ONE)); + AbstractAssert testAbstractComparableAssertActualIsLessThanExpected() { + return assertThat(BigDecimal.ZERO).isLessThan(BigDecimal.ONE); } - ImmutableSet> - testAbstractComparableAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat(BigDecimal.ZERO).isLessThanOrEqualTo(BigDecimal.ONE), - assertThat(BigDecimal.ZERO).isLessThanOrEqualTo(BigDecimal.ONE)); + AbstractAssert testAbstractComparableAssertActualIsLessThanOrEqualToExpected() { + return assertThat(BigDecimal.ZERO).isLessThanOrEqualTo(BigDecimal.ONE); } - ImmutableSet> testAbstractComparableAssertActualIsGreaterThanExpected() { - return ImmutableSet.of( - assertThat(BigDecimal.ZERO).isGreaterThan(BigDecimal.ONE), - assertThat(BigDecimal.ZERO).isGreaterThan(BigDecimal.ONE)); + AbstractAssert testAbstractComparableAssertActualIsGreaterThanExpected() { + return assertThat(BigDecimal.ZERO).isGreaterThan(BigDecimal.ONE); } - ImmutableSet> - testAbstractComparableAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat(BigDecimal.ZERO).isGreaterThanOrEqualTo(BigDecimal.ONE), - assertThat(BigDecimal.ZERO).isGreaterThanOrEqualTo(BigDecimal.ONE)); + AbstractAssert testAbstractComparableAssertActualIsGreaterThanOrEqualToExpected() { + return assertThat(BigDecimal.ZERO).isGreaterThanOrEqualTo(BigDecimal.ONE); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestInput.java index e1d2731071..54b4fac623 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestInput.java @@ -5,7 +5,6 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractFloatAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -26,20 +25,12 @@ ImmutableSet> testAbstractFloatAssertIsEqualTo() { assertThat(0F).isCloseTo(1, offset(0F)), assertThat(0F).isCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractFloatAssertActualIsEqualToExpected() { - return ImmutableSet.of(assertThat(1F == 2F).isTrue(), assertThat(1F != 2F).isFalse()); - } - ImmutableSet> testAbstractFloatAssertIsNotEqualTo() { return ImmutableSet.of( assertThat(0F).isNotCloseTo(1, offset(0F)), assertThat(0F).isNotCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractFloatAssertActualIsNotEqualToExpected() { - return ImmutableSet.of(assertThat(1F != 2F).isTrue(), assertThat(1F == 2F).isFalse()); - } - AbstractFloatAssert testAbstractFloatAssertIsZero() { return assertThat(0F).isZero(); } @@ -51,20 +42,4 @@ AbstractFloatAssert testAbstractFloatAssertIsNotZero() { AbstractFloatAssert testAbstractFloatAssertIsOne() { return assertThat(0F).isOne(); } - - ImmutableSet> testAbstractFloatAssertActualIsLessThanExpected() { - return ImmutableSet.of(assertThat(1F < 2F).isTrue(), assertThat(1F >= 2F).isFalse()); - } - - ImmutableSet> testAbstractFloatAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of(assertThat(1F <= 2F).isTrue(), assertThat(1F > 2F).isFalse()); - } - - ImmutableSet> testAbstractFloatAssertActualIsGreaterThanExpected() { - return ImmutableSet.of(assertThat(1F > 2F).isTrue(), assertThat(1F <= 2F).isFalse()); - } - - ImmutableSet> testAbstractFloatAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of(assertThat(1F >= 2F).isTrue(), assertThat(1F < 2F).isFalse()); - } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestOutput.java index c1a86f0eb4..40b9626372 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJFloatTemplatesTestOutput.java @@ -5,7 +5,6 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractFloatAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -25,18 +24,10 @@ ImmutableSet> testAbstractFloatAssertIsEqualTo() { return ImmutableSet.of(assertThat(0F).isEqualTo(1), assertThat(0F).isEqualTo(1)); } - ImmutableSet> testAbstractFloatAssertActualIsEqualToExpected() { - return ImmutableSet.of(assertThat(1F).isEqualTo(2F), assertThat(1F).isEqualTo(2F)); - } - ImmutableSet> testAbstractFloatAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0F).isNotEqualTo(1), assertThat(0F).isNotEqualTo(1)); } - ImmutableSet> testAbstractFloatAssertActualIsNotEqualToExpected() { - return ImmutableSet.of(assertThat(1F).isNotEqualTo(2F), assertThat(1F).isNotEqualTo(2F)); - } - AbstractFloatAssert testAbstractFloatAssertIsZero() { return assertThat(0F).isEqualTo(0); } @@ -48,22 +39,4 @@ AbstractFloatAssert testAbstractFloatAssertIsNotZero() { AbstractFloatAssert testAbstractFloatAssertIsOne() { return assertThat(0F).isEqualTo(1); } - - ImmutableSet> testAbstractFloatAssertActualIsLessThanExpected() { - return ImmutableSet.of(assertThat(1F).isLessThan(2F), assertThat(1F).isLessThan(2F)); - } - - ImmutableSet> testAbstractFloatAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat(1F).isLessThanOrEqualTo(2F), assertThat(1F).isLessThanOrEqualTo(2F)); - } - - ImmutableSet> testAbstractFloatAssertActualIsGreaterThanExpected() { - return ImmutableSet.of(assertThat(1F).isGreaterThan(2F), assertThat(1F).isGreaterThan(2F)); - } - - ImmutableSet> testAbstractFloatAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat(1F).isGreaterThanOrEqualTo(2F), assertThat(1F).isGreaterThanOrEqualTo(2F)); - } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestInput.java index 41d8377d76..6b4b7a38c3 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestInput.java @@ -5,7 +5,6 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractIntegerAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -20,19 +19,11 @@ ImmutableSet> testAbstractIntegerAssertIsEqualTo() { assertThat(0).isCloseTo(1, offset(0)), assertThat(0).isCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractIntegerAssertActualIsEqualToExpected() { - return ImmutableSet.of(assertThat(1 == 2).isTrue(), assertThat(1 != 2).isFalse()); - } - ImmutableSet> testAbstractIntegerAssertIsNotEqualTo() { return ImmutableSet.of( assertThat(0).isNotCloseTo(1, offset(0)), assertThat(0).isNotCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractIntegerAssertActualIsNotEqualToExpected() { - return ImmutableSet.of(assertThat(1 != 2).isTrue(), assertThat(1 == 2).isFalse()); - } - AbstractIntegerAssert testAbstractIntegerAssertIsZero() { return assertThat(0).isZero(); } @@ -44,21 +35,4 @@ AbstractIntegerAssert testAbstractIntegerAssertIsNotZero() { AbstractIntegerAssert testAbstractIntegerAssertIsOne() { return assertThat(0).isOne(); } - - ImmutableSet> testAbstractIntegerAssertActualIsLessThanExpected() { - return ImmutableSet.of(assertThat(1 < 2).isTrue(), assertThat(1 >= 2).isFalse()); - } - - ImmutableSet> testAbstractIntegerAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of(assertThat(1 <= 2).isTrue(), assertThat(1 > 2).isFalse()); - } - - ImmutableSet> testAbstractIntegerAssertActualIsGreaterThanExpected() { - return ImmutableSet.of(assertThat(1 > 2).isTrue(), assertThat(1 <= 2).isFalse()); - } - - ImmutableSet> - testAbstractIntegerAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of(assertThat(1 >= 2).isTrue(), assertThat(1 < 2).isFalse()); - } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestOutput.java index 62a034a052..87613912ff 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJIntegerTemplatesTestOutput.java @@ -5,7 +5,6 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractIntegerAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -19,18 +18,10 @@ ImmutableSet> testAbstractIntegerAssertIsEqualTo() { return ImmutableSet.of(assertThat(0).isEqualTo(1), assertThat(0).isEqualTo(1)); } - ImmutableSet> testAbstractIntegerAssertActualIsEqualToExpected() { - return ImmutableSet.of(assertThat(1).isEqualTo(2), assertThat(1).isEqualTo(2)); - } - ImmutableSet> testAbstractIntegerAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0).isNotEqualTo(1), assertThat(0).isNotEqualTo(1)); } - ImmutableSet> testAbstractIntegerAssertActualIsNotEqualToExpected() { - return ImmutableSet.of(assertThat(1).isNotEqualTo(2), assertThat(1).isNotEqualTo(2)); - } - AbstractIntegerAssert testAbstractIntegerAssertIsZero() { return assertThat(0).isEqualTo(0); } @@ -42,23 +33,4 @@ AbstractIntegerAssert testAbstractIntegerAssertIsNotZero() { AbstractIntegerAssert testAbstractIntegerAssertIsOne() { return assertThat(0).isEqualTo(1); } - - ImmutableSet> testAbstractIntegerAssertActualIsLessThanExpected() { - return ImmutableSet.of(assertThat(1).isLessThan(2), assertThat(1).isLessThan(2)); - } - - ImmutableSet> testAbstractIntegerAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat(1).isLessThanOrEqualTo(2), assertThat(1).isLessThanOrEqualTo(2)); - } - - ImmutableSet> testAbstractIntegerAssertActualIsGreaterThanExpected() { - return ImmutableSet.of(assertThat(1).isGreaterThan(2), assertThat(1).isGreaterThan(2)); - } - - ImmutableSet> - testAbstractIntegerAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat(1).isGreaterThanOrEqualTo(2), assertThat(1).isGreaterThanOrEqualTo(2)); - } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestInput.java index 6c9fb99242..b55a52774f 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestInput.java @@ -5,7 +5,6 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractLongAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -20,20 +19,12 @@ ImmutableSet> testAbstractLongAssertIsEqualTo() { assertThat(0L).isCloseTo(1, offset(0L)), assertThat(0L).isCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractLongAssertActualIsEqualToExpected() { - return ImmutableSet.of(assertThat(1L == 2L).isTrue(), assertThat(1L != 2L).isFalse()); - } - ImmutableSet> testAbstractLongAssertIsNotEqualTo() { return ImmutableSet.of( assertThat(0L).isNotCloseTo(1, offset(0L)), assertThat(0L).isNotCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractLongAssertActualIsNotEqualToExpected() { - return ImmutableSet.of(assertThat(1L != 2L).isTrue(), assertThat(1L == 2L).isFalse()); - } - AbstractLongAssert testAbstractLongAssertIsZero() { return assertThat(0L).isZero(); } @@ -45,20 +36,4 @@ AbstractLongAssert testAbstractLongAssertIsNotZero() { AbstractLongAssert testAbstractLongAssertIsOne() { return assertThat(0L).isOne(); } - - ImmutableSet> testAbstractLongAssertActualIsLessThanExpected() { - return ImmutableSet.of(assertThat(1L < 2L).isTrue(), assertThat(1L >= 2L).isFalse()); - } - - ImmutableSet> testAbstractLongAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of(assertThat(1L <= 2L).isTrue(), assertThat(1L > 2L).isFalse()); - } - - ImmutableSet> testAbstractLongAssertActualIsGreaterThanExpected() { - return ImmutableSet.of(assertThat(1L > 2L).isTrue(), assertThat(1L <= 2L).isFalse()); - } - - ImmutableSet> testAbstractLongAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of(assertThat(1L >= 2L).isTrue(), assertThat(1L < 2L).isFalse()); - } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestOutput.java index b8948febb0..1c7a851983 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJLongTemplatesTestOutput.java @@ -5,7 +5,6 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractLongAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -19,18 +18,10 @@ ImmutableSet> testAbstractLongAssertIsEqualTo() { return ImmutableSet.of(assertThat(0L).isEqualTo(1), assertThat(0L).isEqualTo(1)); } - ImmutableSet> testAbstractLongAssertActualIsEqualToExpected() { - return ImmutableSet.of(assertThat(1L).isEqualTo(2L), assertThat(1L).isEqualTo(2L)); - } - ImmutableSet> testAbstractLongAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0L).isNotEqualTo(1), assertThat(0L).isNotEqualTo(1)); } - ImmutableSet> testAbstractLongAssertActualIsNotEqualToExpected() { - return ImmutableSet.of(assertThat(1L).isNotEqualTo(2L), assertThat(1L).isNotEqualTo(2L)); - } - AbstractLongAssert testAbstractLongAssertIsZero() { return assertThat(0L).isEqualTo(0); } @@ -42,22 +33,4 @@ AbstractLongAssert testAbstractLongAssertIsNotZero() { AbstractLongAssert testAbstractLongAssertIsOne() { return assertThat(0L).isEqualTo(1); } - - ImmutableSet> testAbstractLongAssertActualIsLessThanExpected() { - return ImmutableSet.of(assertThat(1L).isLessThan(2L), assertThat(1L).isLessThan(2L)); - } - - ImmutableSet> testAbstractLongAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat(1L).isLessThanOrEqualTo(2L), assertThat(1L).isLessThanOrEqualTo(2L)); - } - - ImmutableSet> testAbstractLongAssertActualIsGreaterThanExpected() { - return ImmutableSet.of(assertThat(1L).isGreaterThan(2L), assertThat(1L).isGreaterThan(2L)); - } - - ImmutableSet> testAbstractLongAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat(1L).isGreaterThanOrEqualTo(2L), assertThat(1L).isGreaterThanOrEqualTo(2L)); - } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestInput.java index 1006be9ddb..e4fc739373 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestInput.java @@ -5,7 +5,6 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractShortAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -21,22 +20,12 @@ ImmutableSet> testAbstractShortAssertIsEqualTo() { assertThat((short) 0).isCloseTo((short) 1, withPercentage(0))); } - ImmutableSet> testAbstractShortAssertActualIsEqualToExpected() { - return ImmutableSet.of( - assertThat((short) 1 == (short) 2).isTrue(), assertThat((short) 1 != (short) 2).isFalse()); - } - ImmutableSet> testAbstractShortAssertIsNotEqualTo() { return ImmutableSet.of( assertThat((short) 0).isNotCloseTo((short) 1, offset((short) 0)), assertThat((short) 0).isNotCloseTo((short) 1, withPercentage(0))); } - ImmutableSet> testAbstractShortAssertActualIsNotEqualToExpected() { - return ImmutableSet.of( - assertThat((short) 1 != (short) 2).isTrue(), assertThat((short) 1 == (short) 2).isFalse()); - } - AbstractShortAssert testAbstractShortAssertIsZero() { return assertThat((short) 0).isZero(); } @@ -48,24 +37,4 @@ AbstractShortAssert testAbstractShortAssertIsNotZero() { AbstractShortAssert testAbstractShortAssertIsOne() { return assertThat((short) 0).isOne(); } - - ImmutableSet> testAbstractShortAssertActualIsLessThanExpected() { - return ImmutableSet.of( - assertThat((short) 1 < (short) 2).isTrue(), assertThat((short) 1 >= (short) 2).isFalse()); - } - - ImmutableSet> testAbstractShortAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat((short) 1 <= (short) 2).isTrue(), assertThat((short) 1 > (short) 2).isFalse()); - } - - ImmutableSet> testAbstractShortAssertActualIsGreaterThanExpected() { - return ImmutableSet.of( - assertThat((short) 1 > (short) 2).isTrue(), assertThat((short) 1 <= (short) 2).isFalse()); - } - - ImmutableSet> testAbstractShortAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat((short) 1 >= (short) 2).isTrue(), assertThat((short) 1 < (short) 2).isFalse()); - } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestOutput.java index 2552312b45..58beb71e24 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJShortTemplatesTestOutput.java @@ -5,7 +5,6 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractShortAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -20,23 +19,12 @@ ImmutableSet> testAbstractShortAssertIsEqualTo() { assertThat((short) 0).isEqualTo((short) 1), assertThat((short) 0).isEqualTo((short) 1)); } - ImmutableSet> testAbstractShortAssertActualIsEqualToExpected() { - return ImmutableSet.of( - assertThat((short) 1).isEqualTo((short) 2), assertThat((short) 1).isEqualTo((short) 2)); - } - ImmutableSet> testAbstractShortAssertIsNotEqualTo() { return ImmutableSet.of( assertThat((short) 0).isNotEqualTo((short) 1), assertThat((short) 0).isNotEqualTo((short) 1)); } - ImmutableSet> testAbstractShortAssertActualIsNotEqualToExpected() { - return ImmutableSet.of( - assertThat((short) 1).isNotEqualTo((short) 2), - assertThat((short) 1).isNotEqualTo((short) 2)); - } - AbstractShortAssert testAbstractShortAssertIsZero() { return assertThat((short) 0).isEqualTo((short) 0); } @@ -48,27 +36,4 @@ AbstractShortAssert testAbstractShortAssertIsNotZero() { AbstractShortAssert testAbstractShortAssertIsOne() { return assertThat((short) 0).isEqualTo((short) 1); } - - ImmutableSet> testAbstractShortAssertActualIsLessThanExpected() { - return ImmutableSet.of( - assertThat((short) 1).isLessThan((short) 2), assertThat((short) 1).isLessThan((short) 2)); - } - - ImmutableSet> testAbstractShortAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat((short) 1).isLessThanOrEqualTo((short) 2), - assertThat((short) 1).isLessThanOrEqualTo((short) 2)); - } - - ImmutableSet> testAbstractShortAssertActualIsGreaterThanExpected() { - return ImmutableSet.of( - assertThat((short) 1).isGreaterThan((short) 2), - assertThat((short) 1).isGreaterThan((short) 2)); - } - - ImmutableSet> testAbstractShortAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of( - assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), - assertThat((short) 1).isGreaterThanOrEqualTo((short) 2)); - } } From 7d9345a1693105de8c942278d573cb46605850d9 Mon Sep 17 00:00:00 2001 From: CoolTomatos Date: Tue, 6 Sep 2022 17:33:59 +0200 Subject: [PATCH 08/16] Covering the other primitive types. --- .../AssertJDoubleTemplatesTestInput.java | 54 ++++++++++++++++--- .../AssertJDoubleTemplatesTestOutput.java | 52 +++++++++++++++--- 2 files changed, 94 insertions(+), 12 deletions(-) diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java index 31e59ccf74..4b4d010ac5 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java @@ -27,7 +27,14 @@ ImmutableSet> testAbstractDoubleAssertIsEqualTo() { } ImmutableSet> testAbstractDoubleAssertActualIsEqualToExpected() { - return ImmutableSet.of(assertThat(1.0 == 2.0).isTrue(), assertThat(1.0 != 2.0).isFalse()); + return ImmutableSet.of( + assertThat(1.0 == 2.0).isTrue(), + assertThat(1.0 != 2.0).isFalse(), + assertThat((byte) 1 == (byte) 2).isTrue(), + assertThat(1F == 2F).isTrue(), + assertThat(1 == 2).isTrue(), + assertThat(1L == 2L).isTrue(), + assertThat((short) 1 == (short) 2).isTrue()); } ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { @@ -37,7 +44,14 @@ ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { } ImmutableSet> testAbstractDoubleAssertActualIsNotEqualToExpected() { - return ImmutableSet.of(assertThat(1.0 != 2.0).isTrue(), assertThat(1.0 == 2.0).isFalse()); + return ImmutableSet.of( + assertThat(1.0 != 2.0).isTrue(), + assertThat(1.0 == 2.0).isFalse(), + assertThat((byte) 1 != (byte) 2).isTrue(), + assertThat(1F != 2F).isTrue(), + assertThat(1 != 2).isTrue(), + assertThat(1L != 2L).isTrue(), + assertThat((short) 1 != (short) 2).isTrue()); } AbstractDoubleAssert testAbstractDoubleAssertIsZero() { @@ -53,19 +67,47 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { } ImmutableSet> testAbstractDoubleAssertActualIsLessThanExpected() { - return ImmutableSet.of(assertThat(1.0 < 2.0).isTrue(), assertThat(1.0 >= 2.0).isFalse()); + return ImmutableSet.of( + assertThat(1.0 < 2.0).isTrue(), + assertThat(1.0 >= 2.0).isFalse(), + assertThat(((byte) 1) < ((byte) 2)).isTrue(), + assertThat(1F < 2F).isTrue(), + assertThat(1 < 2).isTrue(), + assertThat(1L < 2L).isTrue(), + assertThat(((short) 1) < ((short) 2)).isTrue()); } ImmutableSet> testAbstractDoubleAssertActualIsLessThanOrEqualToExpected() { - return ImmutableSet.of(assertThat(1.0 <= 2.0).isTrue(), assertThat(1.0 > 2.0).isFalse()); + return ImmutableSet.of( + assertThat(1.0 <= 2.0).isTrue(), + assertThat(1.0 > 2.0).isFalse(), + assertThat(((byte) 1) <= ((byte) 2)).isTrue(), + assertThat(1F <= 2F).isTrue(), + assertThat(1 <= 2).isTrue(), + assertThat(1L <= 2L).isTrue(), + assertThat(((short) 1) <= ((short) 2)).isTrue()); } ImmutableSet> testAbstractDoubleAssertActualIsGreaterThanExpected() { - return ImmutableSet.of(assertThat(1.0 > 2.0).isTrue(), assertThat(1.0 <= 2.0).isFalse()); + return ImmutableSet.of( + assertThat(1.0 > 2.0).isTrue(), + assertThat(1.0 <= 2.0).isFalse(), + assertThat(((byte) 1) > ((byte) 2)).isTrue(), + assertThat(1F > 2F).isTrue(), + assertThat(1 > 2).isTrue(), + assertThat(1L > 2L).isTrue(), + assertThat(((short) 1) > ((short) 2)).isTrue()); } ImmutableSet> testAbstractDoubleAssertActualIsGreaterThanOrEqualToExpected() { - return ImmutableSet.of(assertThat(1.0 >= 2.0).isTrue(), assertThat(1.0 < 2.0).isFalse()); + return ImmutableSet.of( + assertThat(1.0 >= 2.0).isTrue(), + assertThat(1.0 < 2.0).isFalse(), + assertThat(((byte) 1) >= ((byte) 2)).isTrue(), + assertThat(1F >= 2F).isTrue(), + assertThat(1 >= 2).isTrue(), + assertThat(1L >= 2L).isTrue(), + assertThat(((short) 1) >= ((short) 2)).isTrue()); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java index 8d441ecc2d..9ecfa742a4 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java @@ -26,7 +26,14 @@ ImmutableSet> testAbstractDoubleAssertIsEqualTo() { } ImmutableSet> testAbstractDoubleAssertActualIsEqualToExpected() { - return ImmutableSet.of(assertThat(1.0).isEqualTo(2.0), assertThat(1.0).isEqualTo(2.0)); + return ImmutableSet.of( + assertThat(1.0).isEqualTo(2.0), + assertThat(1.0).isEqualTo(2.0), + assertThat((byte) 1).isEqualTo((byte) 2), + assertThat(1F).isEqualTo(2F), + assertThat(1).isEqualTo(2), + assertThat(1L).isEqualTo(2L), + assertThat((short) 1).isEqualTo((short) 2)); } ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { @@ -34,7 +41,14 @@ ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { } ImmutableSet> testAbstractDoubleAssertActualIsNotEqualToExpected() { - return ImmutableSet.of(assertThat(1.0).isNotEqualTo(2.0), assertThat(1.0).isNotEqualTo(2.0)); + return ImmutableSet.of( + assertThat(1.0).isNotEqualTo(2.0), + assertThat(1.0).isNotEqualTo(2.0), + assertThat((byte) 1).isNotEqualTo((byte) 2), + assertThat(1F).isNotEqualTo(2F), + assertThat(1).isNotEqualTo(2), + assertThat(1L).isNotEqualTo(2L), + assertThat((short) 1).isNotEqualTo((short) 2)); } AbstractDoubleAssert testAbstractDoubleAssertIsZero() { @@ -50,21 +64,47 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { } ImmutableSet> testAbstractDoubleAssertActualIsLessThanExpected() { - return ImmutableSet.of(assertThat(1.0).isLessThan(2.0), assertThat(1.0).isLessThan(2.0)); + return ImmutableSet.of( + assertThat(1.0).isLessThan(2.0), + assertThat(1.0).isLessThan(2.0), + assertThat(((byte) 1)).isLessThan(((byte) 2)), + assertThat(1F).isLessThan(2F), + assertThat(1).isLessThan(2), + assertThat(1L).isLessThan(2L), + assertThat(((short) 1)).isLessThan(((short) 2))); } ImmutableSet> testAbstractDoubleAssertActualIsLessThanOrEqualToExpected() { return ImmutableSet.of( - assertThat(1.0).isLessThanOrEqualTo(2.0), assertThat(1.0).isLessThanOrEqualTo(2.0)); + assertThat(1.0).isLessThanOrEqualTo(2.0), + assertThat(1.0).isLessThanOrEqualTo(2.0), + assertThat(((byte) 1)).isLessThanOrEqualTo(((byte) 2)), + assertThat(1F).isLessThanOrEqualTo(2F), + assertThat(1).isLessThanOrEqualTo(2), + assertThat(1L).isLessThanOrEqualTo(2L), + assertThat(((short) 1)).isLessThanOrEqualTo(((short) 2))); } ImmutableSet> testAbstractDoubleAssertActualIsGreaterThanExpected() { - return ImmutableSet.of(assertThat(1.0).isGreaterThan(2.0), assertThat(1.0).isGreaterThan(2.0)); + return ImmutableSet.of( + assertThat(1.0).isGreaterThan(2.0), + assertThat(1.0).isGreaterThan(2.0), + assertThat(((byte) 1)).isGreaterThan(((byte) 2)), + assertThat(1F).isGreaterThan(2F), + assertThat(1).isGreaterThan(2), + assertThat(1L).isGreaterThan(2L), + assertThat(((short) 1)).isGreaterThan(((short) 2))); } ImmutableSet> testAbstractDoubleAssertActualIsGreaterThanOrEqualToExpected() { return ImmutableSet.of( - assertThat(1.0).isGreaterThanOrEqualTo(2.0), assertThat(1.0).isGreaterThanOrEqualTo(2.0)); + assertThat(1.0).isGreaterThanOrEqualTo(2.0), + assertThat(1.0).isGreaterThanOrEqualTo(2.0), + assertThat(((byte) 1)).isGreaterThanOrEqualTo(((byte) 2)), + assertThat(1F).isGreaterThanOrEqualTo(2F), + assertThat(1).isGreaterThanOrEqualTo(2), + assertThat(1L).isGreaterThanOrEqualTo(2L), + assertThat(((short) 1)).isGreaterThanOrEqualTo(((short) 2))); } } From 06050feb34a0eef2c27f3aec6f7cfeb6bade629e Mon Sep 17 00:00:00 2001 From: CoolTomatos Date: Tue, 6 Sep 2022 17:41:01 +0200 Subject: [PATCH 09/16] Added two more templates. --- .../AssertJComparableTemplates.java | 28 +++++++++++++++++++ .../AssertJComparableTemplatesTestInput.java | 8 ++++++ .../AssertJComparableTemplatesTestOutput.java | 8 ++++++ 3 files changed, 44 insertions(+) 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 e10eb1577d..d0f15b6da4 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,6 +12,34 @@ final class AssertJComparableTemplates { private AssertJComparableTemplates() {} + static final class AbstractComparableAssertActualIsEqualByComparingToExpected< + T extends Comparable> { + @BeforeTemplate + AbstractIntegerAssert before(T actual, T expected) { + return assertThat(actual.compareTo(expected)).isEqualTo(0); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractComparableAssert after(T actual, T expected) { + return assertThat(actual).isEqualByComparingTo(expected); + } + } + + static final class AbstractComparableAssertActualIsNotEqualByComparingToExpected< + T extends Comparable> { + @BeforeTemplate + AbstractIntegerAssert before(T actual, T expected) { + return assertThat(actual.compareTo(expected)).isNotEqualTo(0); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractComparableAssert after(T actual, T expected) { + return assertThat(actual).isNotEqualByComparingTo(expected); + } + } + static final class AbstractComparableAssertActualIsLessThanExpected< T extends Comparable> { @BeforeTemplate 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 2bb51ef449..38726215c2 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 @@ -7,6 +7,14 @@ import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; final class AssertJComparableTemplatesTest implements RefasterTemplateTestCase { + AbstractAssert testAbstractComparableAssertActualIsEqualByComparingToExpected() { + return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isEqualTo(0); + } + + AbstractAssert testAbstractComparableAssertActualIsNotEqualByComparingToExpected() { + return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isNotEqualTo(0); + } + AbstractAssert testAbstractComparableAssertActualIsLessThanExpected() { return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isNegative(); } 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 85b41a5dee..0fd9284554 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 @@ -7,6 +7,14 @@ import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; final class AssertJComparableTemplatesTest implements RefasterTemplateTestCase { + AbstractAssert testAbstractComparableAssertActualIsEqualByComparingToExpected() { + return assertThat(BigDecimal.ZERO).isEqualByComparingTo(BigDecimal.ONE); + } + + AbstractAssert testAbstractComparableAssertActualIsNotEqualByComparingToExpected() { + return assertThat(BigDecimal.ZERO).isNotEqualByComparingTo(BigDecimal.ONE); + } + AbstractAssert testAbstractComparableAssertActualIsLessThanExpected() { return assertThat(BigDecimal.ZERO).isLessThan(BigDecimal.ONE); } From bf8e4e4d4d62704a6d5d3c8f57777612c7d44e67 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Thu, 8 Sep 2022 17:38:04 +0200 Subject: [PATCH 10/16] 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 d0f15b6da4..2d63f665da 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 38726215c2..9d3793f23d 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 0fd9284554..8ff2093d8d 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); } } From 21d3a1f5c9a9f5031bb81cdad3ca58efa51a45ca Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Thu, 8 Sep 2022 18:22:56 +0200 Subject: [PATCH 11/16] Other stuff --- .../AssertJDoubleTemplates.java | 20 ++++++++--- .../AssertJDoubleTemplatesTestInput.java | 36 +++++++++++++------ .../AssertJDoubleTemplatesTestOutput.java | 36 +++++++++++++------ 3 files changed, 68 insertions(+), 24 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java index e03b7c25c7..100de71571 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java @@ -49,7 +49,13 @@ AbstractDoubleAssert after(AbstractDoubleAssert doubleAssert, double n) { } } - static final class AbstractDoubleAssertActualIsEqualToExpected { + static final class AssertThatIsEqualTo { + @BeforeTemplate + AbstractBooleanAssert before(boolean actual, boolean expected) { + return Refaster.anyOf( + assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); + } + @BeforeTemplate AbstractBooleanAssert before(double actual, double expected) { return Refaster.anyOf( @@ -58,7 +64,7 @@ AbstractBooleanAssert before(double actual, double expected) { @AfterTemplate @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractDoubleAssert after(double actual, double expected) { + AbstractBooleanAssert after(boolean actual, boolean expected) { return assertThat(actual).isEqualTo(expected); } } @@ -77,7 +83,13 @@ AbstractDoubleAssert after(AbstractDoubleAssert doubleAssert, double n) { } } - static final class AbstractDoubleAssertActualIsNotEqualToExpected { + static final class AssertThatIsNotEqualTo { + @BeforeTemplate + AbstractBooleanAssert before(boolean actual, boolean expected) { + return Refaster.anyOf( + assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); + } + @BeforeTemplate AbstractBooleanAssert before(double actual, double expected) { return Refaster.anyOf( @@ -86,7 +98,7 @@ AbstractBooleanAssert before(double actual, double expected) { @AfterTemplate @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractDoubleAssert after(double actual, double expected) { + AbstractBooleanAssert after(boolean actual, boolean expected) { return assertThat(actual).isNotEqualTo(expected); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java index 4b4d010ac5..322092411c 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java @@ -26,15 +26,23 @@ ImmutableSet> testAbstractDoubleAssertIsEqualTo() { assertThat(0.0).isCloseTo(1, offset(0.0)), assertThat(0.0).isCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractDoubleAssertActualIsEqualToExpected() { + @SuppressWarnings("SimplifyBooleanExpression") + ImmutableSet> testAssertThatIsEqualTo() { return ImmutableSet.of( - assertThat(1.0 == 2.0).isTrue(), - assertThat(1.0 != 2.0).isFalse(), + assertThat(true == false).isTrue(), + assertThat(true != false).isFalse(), assertThat((byte) 1 == (byte) 2).isTrue(), - assertThat(1F == 2F).isTrue(), + assertThat((byte) 1 != (byte) 2).isFalse(), + assertThat((short) 1 == (short) 2).isTrue(), + assertThat((short) 1 != (short) 2).isFalse(), assertThat(1 == 2).isTrue(), + assertThat(1 != 2).isFalse(), assertThat(1L == 2L).isTrue(), - assertThat((short) 1 == (short) 2).isTrue()); + assertThat(1L != 2L).isFalse(), + assertThat(1F == 2F).isTrue(), + assertThat(1F != 2F).isFalse(), + assertThat(1.0 == 2.0).isTrue(), + assertThat(1.0 != 2.0).isFalse()); } ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { @@ -43,15 +51,23 @@ ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { assertThat(0.0).isNotCloseTo(1, withPercentage(0))); } - ImmutableSet> testAbstractDoubleAssertActualIsNotEqualToExpected() { + @SuppressWarnings("SimplifyBooleanExpression") + ImmutableSet> testAssertThatIsNotEqualTo() { return ImmutableSet.of( - assertThat(1.0 != 2.0).isTrue(), - assertThat(1.0 == 2.0).isFalse(), + assertThat(true != false).isTrue(), + assertThat(true == false).isFalse(), assertThat((byte) 1 != (byte) 2).isTrue(), - assertThat(1F != 2F).isTrue(), + assertThat((byte) 1 == (byte) 2).isFalse(), + assertThat((short) 1 != (short) 2).isTrue(), + assertThat((short) 1 == (short) 2).isFalse(), assertThat(1 != 2).isTrue(), + assertThat(1 == 2).isFalse(), assertThat(1L != 2L).isTrue(), - assertThat((short) 1 != (short) 2).isTrue()); + assertThat(1L == 2L).isFalse(), + assertThat(1F != 2F).isTrue(), + assertThat(1F == 2F).isFalse(), + assertThat(1.0 != 2.0).isTrue(), + assertThat(1.0 == 2.0).isFalse()); } AbstractDoubleAssert testAbstractDoubleAssertIsZero() { diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java index 9ecfa742a4..a5304611ba 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java @@ -25,30 +25,46 @@ ImmutableSet> testAbstractDoubleAssertIsEqualTo() { return ImmutableSet.of(assertThat(0.0).isEqualTo(1), assertThat(0.0).isEqualTo(1)); } - ImmutableSet> testAbstractDoubleAssertActualIsEqualToExpected() { + @SuppressWarnings("SimplifyBooleanExpression") + ImmutableSet> testAssertThatIsEqualTo() { return ImmutableSet.of( - assertThat(1.0).isEqualTo(2.0), - assertThat(1.0).isEqualTo(2.0), + assertThat(true).isEqualTo(false), + assertThat(true).isEqualTo(false), assertThat((byte) 1).isEqualTo((byte) 2), - assertThat(1F).isEqualTo(2F), + assertThat((byte) 1).isEqualTo((byte) 2), + assertThat((short) 1).isEqualTo((short) 2), + assertThat((short) 1).isEqualTo((short) 2), + assertThat(1).isEqualTo(2), assertThat(1).isEqualTo(2), assertThat(1L).isEqualTo(2L), - assertThat((short) 1).isEqualTo((short) 2)); + assertThat(1L).isEqualTo(2L), + assertThat(1F).isEqualTo(2F), + assertThat(1F).isEqualTo(2F), + assertThat(1.0).isEqualTo(2.0), + assertThat(1.0).isEqualTo(2.0)); } ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0.0).isNotEqualTo(1), assertThat(0.0).isNotEqualTo(1)); } - ImmutableSet> testAbstractDoubleAssertActualIsNotEqualToExpected() { + @SuppressWarnings("SimplifyBooleanExpression") + ImmutableSet> testAssertThatIsNotEqualTo() { return ImmutableSet.of( - assertThat(1.0).isNotEqualTo(2.0), - assertThat(1.0).isNotEqualTo(2.0), + assertThat(true).isNotEqualTo(false), + assertThat(true).isNotEqualTo(false), assertThat((byte) 1).isNotEqualTo((byte) 2), - assertThat(1F).isNotEqualTo(2F), + assertThat((byte) 1).isNotEqualTo((byte) 2), + assertThat((short) 1).isNotEqualTo((short) 2), + assertThat((short) 1).isNotEqualTo((short) 2), + assertThat(1).isNotEqualTo(2), assertThat(1).isNotEqualTo(2), assertThat(1L).isNotEqualTo(2L), - assertThat((short) 1).isNotEqualTo((short) 2)); + assertThat(1L).isNotEqualTo(2L), + assertThat(1F).isNotEqualTo(2F), + assertThat(1F).isNotEqualTo(2F), + assertThat(1.0).isNotEqualTo(2.0), + assertThat(1.0).isNotEqualTo(2.0)); } AbstractDoubleAssert testAbstractDoubleAssertIsZero() { From f7ee6c94bf3af58961155a227efca4a1fbed2202 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Thu, 8 Sep 2022 18:51:17 +0200 Subject: [PATCH 12/16] More test cases and renaming --- .../AssertJDoubleTemplates.java | 8 +-- .../AssertJDoubleTemplatesTestInput.java | 69 ++++++++++++------- .../AssertJDoubleTemplatesTestOutput.java | 69 ++++++++++++------- 3 files changed, 92 insertions(+), 54 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java index 100de71571..2e72fdd6d5 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java @@ -139,7 +139,7 @@ AbstractDoubleAssert after(AbstractDoubleAssert doubleAssert) { } } - static final class AbstractDoubleAssertActualIsLessThanExpected { + static final class AssertThatIsLessThan { @BeforeTemplate AbstractBooleanAssert before(double actual, double expected) { return Refaster.anyOf( @@ -153,7 +153,7 @@ AbstractDoubleAssert after(double actual, double expected) { } } - static final class AbstractDoubleAssertActualIsLessThanOrEqualToExpected { + static final class AssertThatIsLessThanOrEqualTo { @BeforeTemplate AbstractBooleanAssert before(double actual, double expected) { return Refaster.anyOf( @@ -167,7 +167,7 @@ AbstractDoubleAssert after(double actual, double expected) { } } - static final class AbstractDoubleAssertActualIsGreaterThanExpected { + static final class AssertThatIsGreaterThan { @BeforeTemplate AbstractBooleanAssert before(double actual, double expected) { return Refaster.anyOf( @@ -181,7 +181,7 @@ AbstractDoubleAssert after(double actual, double expected) { } } - static final class AbstractDoubleAssertActualIsGreaterThanOrEqualToExpected { + static final class AssertThatIsGreaterThanOrEqualTo { @BeforeTemplate AbstractBooleanAssert before(double actual, double expected) { return Refaster.anyOf( diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java index 322092411c..c33021d955 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java @@ -82,48 +82,67 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return assertThat(0.0).isOne(); } - ImmutableSet> testAbstractDoubleAssertActualIsLessThanExpected() { + ImmutableSet> testAssertThatIsLessThan() { return ImmutableSet.of( - assertThat(1.0 < 2.0).isTrue(), - assertThat(1.0 >= 2.0).isFalse(), - assertThat(((byte) 1) < ((byte) 2)).isTrue(), - assertThat(1F < 2F).isTrue(), + assertThat((byte) 1 < (byte) 2).isTrue(), + assertThat((byte) 1 >= (byte) 2).isFalse(), + assertThat((short) 1 < (short) 2).isTrue(), + assertThat((short) 1 >= (short) 2).isFalse(), assertThat(1 < 2).isTrue(), + assertThat(1 >= 2).isFalse(), assertThat(1L < 2L).isTrue(), - assertThat(((short) 1) < ((short) 2)).isTrue()); + assertThat(1L >= 2L).isFalse(), + assertThat(1F < 2F).isTrue(), + assertThat(1F >= 2F).isFalse(), + assertThat(1.0 < 2.0).isTrue(), + assertThat(1.0 >= 2.0).isFalse()); } - ImmutableSet> testAbstractDoubleAssertActualIsLessThanOrEqualToExpected() { + ImmutableSet> testAssertThatIsLessThanOrEqualTo() { return ImmutableSet.of( - assertThat(1.0 <= 2.0).isTrue(), - assertThat(1.0 > 2.0).isFalse(), - assertThat(((byte) 1) <= ((byte) 2)).isTrue(), - assertThat(1F <= 2F).isTrue(), + assertThat((byte) 1 <= (byte) 2).isTrue(), + assertThat((byte) 1 > (byte) 2).isFalse(), + assertThat((short) 1 <= (short) 2).isTrue(), + assertThat((short) 1 > (short) 2).isFalse(), assertThat(1 <= 2).isTrue(), + assertThat(1 > 2).isFalse(), assertThat(1L <= 2L).isTrue(), - assertThat(((short) 1) <= ((short) 2)).isTrue()); + assertThat(1L > 2L).isFalse(), + assertThat(1F <= 2F).isTrue(), + assertThat(1F > 2F).isFalse(), + assertThat(1.0 <= 2.0).isTrue(), + assertThat(1.0 > 2.0).isFalse()); } - ImmutableSet> testAbstractDoubleAssertActualIsGreaterThanExpected() { + ImmutableSet> testAssertThatIsGreaterThan() { return ImmutableSet.of( - assertThat(1.0 > 2.0).isTrue(), - assertThat(1.0 <= 2.0).isFalse(), - assertThat(((byte) 1) > ((byte) 2)).isTrue(), - assertThat(1F > 2F).isTrue(), + assertThat((byte) 1 > (byte) 2).isTrue(), + assertThat((byte) 1 <= (byte) 2).isFalse(), + assertThat((short) 1 > (short) 2).isTrue(), + assertThat((short) 1 <= (short) 2).isFalse(), assertThat(1 > 2).isTrue(), + assertThat(1 <= 2).isFalse(), assertThat(1L > 2L).isTrue(), - assertThat(((short) 1) > ((short) 2)).isTrue()); + assertThat(1L <= 2L).isFalse(), + assertThat(1F > 2F).isTrue(), + assertThat(1F <= 2F).isFalse(), + assertThat(1.0 > 2.0).isTrue(), + assertThat(1.0 <= 2.0).isFalse()); } - ImmutableSet> - testAbstractDoubleAssertActualIsGreaterThanOrEqualToExpected() { + ImmutableSet> testAssertThatIsGreaterThanOrEqualTo() { return ImmutableSet.of( - assertThat(1.0 >= 2.0).isTrue(), - assertThat(1.0 < 2.0).isFalse(), - assertThat(((byte) 1) >= ((byte) 2)).isTrue(), - assertThat(1F >= 2F).isTrue(), + assertThat((byte) 1 >= (byte) 2).isTrue(), + assertThat((byte) 1 < (byte) 2).isFalse(), + assertThat((short) 1 >= (short) 2).isTrue(), + assertThat((short) 1 < (short) 2).isFalse(), assertThat(1 >= 2).isTrue(), + assertThat(1 < 2).isFalse(), assertThat(1L >= 2L).isTrue(), - assertThat(((short) 1) >= ((short) 2)).isTrue()); + assertThat(1L < 2L).isFalse(), + assertThat(1F >= 2F).isTrue(), + assertThat(1F < 2F).isFalse(), + assertThat(1.0 >= 2.0).isTrue(), + assertThat(1.0 < 2.0).isFalse()); } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java index a5304611ba..2621eaebe1 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java @@ -79,48 +79,67 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return assertThat(0.0).isEqualTo(1); } - ImmutableSet> testAbstractDoubleAssertActualIsLessThanExpected() { + ImmutableSet> testAssertThatIsLessThan() { return ImmutableSet.of( - assertThat(1.0).isLessThan(2.0), - assertThat(1.0).isLessThan(2.0), - assertThat(((byte) 1)).isLessThan(((byte) 2)), - assertThat(1F).isLessThan(2F), + assertThat((byte) 1).isLessThan((byte) 2), + assertThat((byte) 1).isLessThan((byte) 2), + assertThat((short) 1).isLessThan((short) 2), + assertThat((short) 1).isLessThan((short) 2), + assertThat(1).isLessThan(2), assertThat(1).isLessThan(2), assertThat(1L).isLessThan(2L), - assertThat(((short) 1)).isLessThan(((short) 2))); + assertThat(1L).isLessThan(2L), + assertThat(1F).isLessThan(2F), + assertThat(1F).isLessThan(2F), + assertThat(1.0).isLessThan(2.0), + assertThat(1.0).isLessThan(2.0)); } - ImmutableSet> testAbstractDoubleAssertActualIsLessThanOrEqualToExpected() { + ImmutableSet> testAssertThatIsLessThanOrEqualTo() { return ImmutableSet.of( - assertThat(1.0).isLessThanOrEqualTo(2.0), - assertThat(1.0).isLessThanOrEqualTo(2.0), - assertThat(((byte) 1)).isLessThanOrEqualTo(((byte) 2)), - assertThat(1F).isLessThanOrEqualTo(2F), + assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), + assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), + assertThat((short) 1).isLessThanOrEqualTo((short) 2), + assertThat((short) 1).isLessThanOrEqualTo((short) 2), + assertThat(1).isLessThanOrEqualTo(2), assertThat(1).isLessThanOrEqualTo(2), assertThat(1L).isLessThanOrEqualTo(2L), - assertThat(((short) 1)).isLessThanOrEqualTo(((short) 2))); + assertThat(1L).isLessThanOrEqualTo(2L), + assertThat(1F).isLessThanOrEqualTo(2F), + assertThat(1F).isLessThanOrEqualTo(2F), + assertThat(1.0).isLessThanOrEqualTo(2.0), + assertThat(1.0).isLessThanOrEqualTo(2.0)); } - ImmutableSet> testAbstractDoubleAssertActualIsGreaterThanExpected() { + ImmutableSet> testAssertThatIsGreaterThan() { return ImmutableSet.of( - assertThat(1.0).isGreaterThan(2.0), - assertThat(1.0).isGreaterThan(2.0), - assertThat(((byte) 1)).isGreaterThan(((byte) 2)), - assertThat(1F).isGreaterThan(2F), + assertThat((byte) 1).isGreaterThan((byte) 2), + assertThat((byte) 1).isGreaterThan((byte) 2), + assertThat((short) 1).isGreaterThan((short) 2), + assertThat((short) 1).isGreaterThan((short) 2), + assertThat(1).isGreaterThan(2), assertThat(1).isGreaterThan(2), assertThat(1L).isGreaterThan(2L), - assertThat(((short) 1)).isGreaterThan(((short) 2))); + assertThat(1L).isGreaterThan(2L), + assertThat(1F).isGreaterThan(2F), + assertThat(1F).isGreaterThan(2F), + assertThat(1.0).isGreaterThan(2.0), + assertThat(1.0).isGreaterThan(2.0)); } - ImmutableSet> - testAbstractDoubleAssertActualIsGreaterThanOrEqualToExpected() { + ImmutableSet> testAssertThatIsGreaterThanOrEqualTo() { return ImmutableSet.of( - assertThat(1.0).isGreaterThanOrEqualTo(2.0), - assertThat(1.0).isGreaterThanOrEqualTo(2.0), - assertThat(((byte) 1)).isGreaterThanOrEqualTo(((byte) 2)), - assertThat(1F).isGreaterThanOrEqualTo(2F), + assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), + assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), + assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), + assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), + assertThat(1).isGreaterThanOrEqualTo(2), assertThat(1).isGreaterThanOrEqualTo(2), assertThat(1L).isGreaterThanOrEqualTo(2L), - assertThat(((short) 1)).isGreaterThanOrEqualTo(((short) 2))); + assertThat(1L).isGreaterThanOrEqualTo(2L), + assertThat(1F).isGreaterThanOrEqualTo(2F), + assertThat(1F).isGreaterThanOrEqualTo(2F), + assertThat(1.0).isGreaterThanOrEqualTo(2.0), + assertThat(1.0).isGreaterThanOrEqualTo(2.0)); } } From 43126628f5a7068cd0422b2da4787c3f11169d63 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Thu, 8 Sep 2022 21:11:47 +0200 Subject: [PATCH 13/16] More tests, some sorting, flag issues --- .../AssertJDoubleTemplatesTestInput.java | 12 ++++++++++++ .../AssertJDoubleTemplatesTestOutput.java | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java index c33021d955..680f527a9f 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java @@ -33,6 +33,8 @@ ImmutableSet> testAbstractDoubleAssertIsEqualTo() { assertThat(true != false).isFalse(), assertThat((byte) 1 == (byte) 2).isTrue(), assertThat((byte) 1 != (byte) 2).isFalse(), + assertThat((char) 1 == (char) 2).isTrue(), + assertThat((char) 1 != (char) 2).isFalse(), assertThat((short) 1 == (short) 2).isTrue(), assertThat((short) 1 != (short) 2).isFalse(), assertThat(1 == 2).isTrue(), @@ -58,6 +60,8 @@ ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { assertThat(true == false).isFalse(), assertThat((byte) 1 != (byte) 2).isTrue(), assertThat((byte) 1 == (byte) 2).isFalse(), + assertThat((char) 1 != (char) 2).isTrue(), + assertThat((char) 1 == (char) 2).isFalse(), assertThat((short) 1 != (short) 2).isTrue(), assertThat((short) 1 == (short) 2).isFalse(), assertThat(1 != 2).isTrue(), @@ -86,6 +90,8 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return ImmutableSet.of( assertThat((byte) 1 < (byte) 2).isTrue(), assertThat((byte) 1 >= (byte) 2).isFalse(), + assertThat((char) 1 < (char) 2).isTrue(), + assertThat((char) 1 >= (char) 2).isFalse(), assertThat((short) 1 < (short) 2).isTrue(), assertThat((short) 1 >= (short) 2).isFalse(), assertThat(1 < 2).isTrue(), @@ -102,6 +108,8 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return ImmutableSet.of( assertThat((byte) 1 <= (byte) 2).isTrue(), assertThat((byte) 1 > (byte) 2).isFalse(), + assertThat((char) 1 <= (char) 2).isTrue(), + assertThat((char) 1 > (char) 2).isFalse(), assertThat((short) 1 <= (short) 2).isTrue(), assertThat((short) 1 > (short) 2).isFalse(), assertThat(1 <= 2).isTrue(), @@ -118,6 +126,8 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return ImmutableSet.of( assertThat((byte) 1 > (byte) 2).isTrue(), assertThat((byte) 1 <= (byte) 2).isFalse(), + assertThat((char) 1 > (char) 2).isTrue(), + assertThat((char) 1 <= (char) 2).isFalse(), assertThat((short) 1 > (short) 2).isTrue(), assertThat((short) 1 <= (short) 2).isFalse(), assertThat(1 > 2).isTrue(), @@ -134,6 +144,8 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return ImmutableSet.of( assertThat((byte) 1 >= (byte) 2).isTrue(), assertThat((byte) 1 < (byte) 2).isFalse(), + assertThat((char) 1 >= (char) 2).isTrue(), + assertThat((char) 1 < (char) 2).isFalse(), assertThat((short) 1 >= (short) 2).isTrue(), assertThat((short) 1 < (short) 2).isFalse(), assertThat(1 >= 2).isTrue(), diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java index 2621eaebe1..097d22de9b 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java @@ -32,6 +32,8 @@ ImmutableSet> testAbstractDoubleAssertIsEqualTo() { assertThat(true).isEqualTo(false), assertThat((byte) 1).isEqualTo((byte) 2), assertThat((byte) 1).isEqualTo((byte) 2), + assertThat((char) 1).isEqualTo((char) 2), + assertThat((char) 1).isEqualTo((char) 2), assertThat((short) 1).isEqualTo((short) 2), assertThat((short) 1).isEqualTo((short) 2), assertThat(1).isEqualTo(2), @@ -55,6 +57,8 @@ ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { assertThat(true).isNotEqualTo(false), assertThat((byte) 1).isNotEqualTo((byte) 2), assertThat((byte) 1).isNotEqualTo((byte) 2), + assertThat((char) 1).isNotEqualTo((char) 2), + assertThat((char) 1).isNotEqualTo((char) 2), assertThat((short) 1).isNotEqualTo((short) 2), assertThat((short) 1).isNotEqualTo((short) 2), assertThat(1).isNotEqualTo(2), @@ -83,6 +87,8 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return ImmutableSet.of( assertThat((byte) 1).isLessThan((byte) 2), assertThat((byte) 1).isLessThan((byte) 2), + assertThat((char) 1).isLessThan((char) 2), + assertThat((char) 1).isLessThan((char) 2), assertThat((short) 1).isLessThan((short) 2), assertThat((short) 1).isLessThan((short) 2), assertThat(1).isLessThan(2), @@ -99,6 +105,8 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return ImmutableSet.of( assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), + assertThat((char) 1).isLessThanOrEqualTo((char) 2), + assertThat((char) 1).isLessThanOrEqualTo((char) 2), assertThat((short) 1).isLessThanOrEqualTo((short) 2), assertThat((short) 1).isLessThanOrEqualTo((short) 2), assertThat(1).isLessThanOrEqualTo(2), @@ -115,6 +123,8 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return ImmutableSet.of( assertThat((byte) 1).isGreaterThan((byte) 2), assertThat((byte) 1).isGreaterThan((byte) 2), + assertThat((char) 1).isGreaterThan((char) 2), + assertThat((char) 1).isGreaterThan((char) 2), assertThat((short) 1).isGreaterThan((short) 2), assertThat((short) 1).isGreaterThan((short) 2), assertThat(1).isGreaterThan(2), @@ -131,6 +141,8 @@ AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return ImmutableSet.of( assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), + assertThat((char) 1).isGreaterThanOrEqualTo((char) 2), + assertThat((char) 1).isGreaterThanOrEqualTo((char) 2), assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), assertThat(1).isGreaterThanOrEqualTo(2), From 3d0b0ce7e5e137499f1d51b22660a08d333a1b81 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Thu, 8 Sep 2022 22:08:43 +0200 Subject: [PATCH 14/16] Move some checks (not necessarily happy with new location) --- .../AssertJDoubleTemplates.java | 100 --------------- .../AssertJNumberTemplates.java | 97 +++++++++++++++ .../AssertJDoubleTemplatesTestInput.java | 115 ------------------ .../AssertJDoubleTemplatesTestOutput.java | 115 ------------------ .../AssertJNumberTemplatesTestInput.java | 115 ++++++++++++++++++ .../AssertJNumberTemplatesTestOutput.java | 115 ++++++++++++++++++ 6 files changed, 327 insertions(+), 330 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java index 2e72fdd6d5..44dc57b014 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplates.java @@ -1,15 +1,11 @@ package tech.picnic.errorprone.refastertemplates; -import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; -import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.Offset.offset; import static org.assertj.core.data.Percentage.withPercentage; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractDoubleAssert; import org.assertj.core.data.Offset; @@ -49,26 +45,6 @@ AbstractDoubleAssert after(AbstractDoubleAssert doubleAssert, double n) { } } - static final class AssertThatIsEqualTo { - @BeforeTemplate - AbstractBooleanAssert before(boolean actual, boolean expected) { - return Refaster.anyOf( - assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); - } - - @BeforeTemplate - AbstractBooleanAssert before(double actual, double expected) { - return Refaster.anyOf( - assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractBooleanAssert after(boolean actual, boolean expected) { - return assertThat(actual).isEqualTo(expected); - } - } - static final class AbstractDoubleAssertIsNotEqualTo { @BeforeTemplate AbstractDoubleAssert before(AbstractDoubleAssert doubleAssert, double n) { @@ -83,26 +59,6 @@ AbstractDoubleAssert after(AbstractDoubleAssert doubleAssert, double n) { } } - static final class AssertThatIsNotEqualTo { - @BeforeTemplate - AbstractBooleanAssert before(boolean actual, boolean expected) { - return Refaster.anyOf( - assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); - } - - @BeforeTemplate - AbstractBooleanAssert before(double actual, double expected) { - return Refaster.anyOf( - assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractBooleanAssert after(boolean actual, boolean expected) { - return assertThat(actual).isNotEqualTo(expected); - } - } - static final class AbstractDoubleAssertIsZero { @BeforeTemplate AbstractDoubleAssert before(AbstractDoubleAssert doubleAssert) { @@ -138,60 +94,4 @@ AbstractDoubleAssert after(AbstractDoubleAssert doubleAssert) { return doubleAssert.isEqualTo(1); } } - - static final class AssertThatIsLessThan { - @BeforeTemplate - AbstractBooleanAssert before(double actual, double expected) { - return Refaster.anyOf( - assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractDoubleAssert after(double actual, double expected) { - return assertThat(actual).isLessThan(expected); - } - } - - static final class AssertThatIsLessThanOrEqualTo { - @BeforeTemplate - AbstractBooleanAssert before(double actual, double expected) { - return Refaster.anyOf( - assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractDoubleAssert after(double actual, double expected) { - return assertThat(actual).isLessThanOrEqualTo(expected); - } - } - - static final class AssertThatIsGreaterThan { - @BeforeTemplate - AbstractBooleanAssert before(double actual, double expected) { - return Refaster.anyOf( - assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractDoubleAssert after(double actual, double expected) { - return assertThat(actual).isGreaterThan(expected); - } - } - - static final class AssertThatIsGreaterThanOrEqualTo { - @BeforeTemplate - AbstractBooleanAssert before(double actual, double expected) { - return Refaster.anyOf( - assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractDoubleAssert after(double actual, double expected) { - return assertThat(actual).isGreaterThanOrEqualTo(expected); - } - } } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplates.java index 3d2cb4cd32..f7c49d311b 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplates.java @@ -12,6 +12,7 @@ import java.math.BigInteger; import org.assertj.core.api.AbstractBigDecimalAssert; import org.assertj.core.api.AbstractBigIntegerAssert; +import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractByteAssert; import org.assertj.core.api.AbstractDoubleAssert; import org.assertj.core.api.AbstractFloatAssert; @@ -24,6 +25,102 @@ final class AssertJNumberTemplates { private AssertJNumberTemplates() {} + static final class AssertThatIsEqualTo { + @BeforeTemplate + AbstractBooleanAssert before(boolean actual, boolean expected) { + return Refaster.anyOf( + assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); + } + + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractBooleanAssert after(boolean actual, boolean expected) { + return assertThat(actual).isEqualTo(expected); + } + } + + static final class AssertThatIsNotEqualTo { + @BeforeTemplate + AbstractBooleanAssert before(boolean actual, boolean expected) { + return Refaster.anyOf( + assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); + } + + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractBooleanAssert after(boolean actual, boolean expected) { + return assertThat(actual).isNotEqualTo(expected); + } + } + + static final class AssertThatIsLessThan { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isLessThan(expected); + } + } + + static final class AssertThatIsLessThanOrEqualTo { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isLessThanOrEqualTo(expected); + } + } + + static final class AssertThatIsGreaterThan { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isGreaterThan(expected); + } + } + + static final class AssertThatIsGreaterThanOrEqualTo { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isGreaterThanOrEqualTo(expected); + } + } + static final class NumberAssertIsPositive { @BeforeTemplate AbstractByteAssert before(AbstractByteAssert numberAssert) { diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java index 680f527a9f..04eb0c7206 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestInput.java @@ -5,7 +5,6 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractDoubleAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -26,54 +25,12 @@ ImmutableSet> testAbstractDoubleAssertIsEqualTo() { assertThat(0.0).isCloseTo(1, offset(0.0)), assertThat(0.0).isCloseTo(1, withPercentage(0))); } - @SuppressWarnings("SimplifyBooleanExpression") - ImmutableSet> testAssertThatIsEqualTo() { - return ImmutableSet.of( - assertThat(true == false).isTrue(), - assertThat(true != false).isFalse(), - assertThat((byte) 1 == (byte) 2).isTrue(), - assertThat((byte) 1 != (byte) 2).isFalse(), - assertThat((char) 1 == (char) 2).isTrue(), - assertThat((char) 1 != (char) 2).isFalse(), - assertThat((short) 1 == (short) 2).isTrue(), - assertThat((short) 1 != (short) 2).isFalse(), - assertThat(1 == 2).isTrue(), - assertThat(1 != 2).isFalse(), - assertThat(1L == 2L).isTrue(), - assertThat(1L != 2L).isFalse(), - assertThat(1F == 2F).isTrue(), - assertThat(1F != 2F).isFalse(), - assertThat(1.0 == 2.0).isTrue(), - assertThat(1.0 != 2.0).isFalse()); - } - ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { return ImmutableSet.of( assertThat(0.0).isNotCloseTo(1, offset(0.0)), assertThat(0.0).isNotCloseTo(1, withPercentage(0))); } - @SuppressWarnings("SimplifyBooleanExpression") - ImmutableSet> testAssertThatIsNotEqualTo() { - return ImmutableSet.of( - assertThat(true != false).isTrue(), - assertThat(true == false).isFalse(), - assertThat((byte) 1 != (byte) 2).isTrue(), - assertThat((byte) 1 == (byte) 2).isFalse(), - assertThat((char) 1 != (char) 2).isTrue(), - assertThat((char) 1 == (char) 2).isFalse(), - assertThat((short) 1 != (short) 2).isTrue(), - assertThat((short) 1 == (short) 2).isFalse(), - assertThat(1 != 2).isTrue(), - assertThat(1 == 2).isFalse(), - assertThat(1L != 2L).isTrue(), - assertThat(1L == 2L).isFalse(), - assertThat(1F != 2F).isTrue(), - assertThat(1F == 2F).isFalse(), - assertThat(1.0 != 2.0).isTrue(), - assertThat(1.0 == 2.0).isFalse()); - } - AbstractDoubleAssert testAbstractDoubleAssertIsZero() { return assertThat(0.0).isZero(); } @@ -85,76 +42,4 @@ AbstractDoubleAssert testAbstractDoubleAssertIsNotZero() { AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return assertThat(0.0).isOne(); } - - ImmutableSet> testAssertThatIsLessThan() { - return ImmutableSet.of( - assertThat((byte) 1 < (byte) 2).isTrue(), - assertThat((byte) 1 >= (byte) 2).isFalse(), - assertThat((char) 1 < (char) 2).isTrue(), - assertThat((char) 1 >= (char) 2).isFalse(), - assertThat((short) 1 < (short) 2).isTrue(), - assertThat((short) 1 >= (short) 2).isFalse(), - assertThat(1 < 2).isTrue(), - assertThat(1 >= 2).isFalse(), - assertThat(1L < 2L).isTrue(), - assertThat(1L >= 2L).isFalse(), - assertThat(1F < 2F).isTrue(), - assertThat(1F >= 2F).isFalse(), - assertThat(1.0 < 2.0).isTrue(), - assertThat(1.0 >= 2.0).isFalse()); - } - - ImmutableSet> testAssertThatIsLessThanOrEqualTo() { - return ImmutableSet.of( - assertThat((byte) 1 <= (byte) 2).isTrue(), - assertThat((byte) 1 > (byte) 2).isFalse(), - assertThat((char) 1 <= (char) 2).isTrue(), - assertThat((char) 1 > (char) 2).isFalse(), - assertThat((short) 1 <= (short) 2).isTrue(), - assertThat((short) 1 > (short) 2).isFalse(), - assertThat(1 <= 2).isTrue(), - assertThat(1 > 2).isFalse(), - assertThat(1L <= 2L).isTrue(), - assertThat(1L > 2L).isFalse(), - assertThat(1F <= 2F).isTrue(), - assertThat(1F > 2F).isFalse(), - assertThat(1.0 <= 2.0).isTrue(), - assertThat(1.0 > 2.0).isFalse()); - } - - ImmutableSet> testAssertThatIsGreaterThan() { - return ImmutableSet.of( - assertThat((byte) 1 > (byte) 2).isTrue(), - assertThat((byte) 1 <= (byte) 2).isFalse(), - assertThat((char) 1 > (char) 2).isTrue(), - assertThat((char) 1 <= (char) 2).isFalse(), - assertThat((short) 1 > (short) 2).isTrue(), - assertThat((short) 1 <= (short) 2).isFalse(), - assertThat(1 > 2).isTrue(), - assertThat(1 <= 2).isFalse(), - assertThat(1L > 2L).isTrue(), - assertThat(1L <= 2L).isFalse(), - assertThat(1F > 2F).isTrue(), - assertThat(1F <= 2F).isFalse(), - assertThat(1.0 > 2.0).isTrue(), - assertThat(1.0 <= 2.0).isFalse()); - } - - ImmutableSet> testAssertThatIsGreaterThanOrEqualTo() { - return ImmutableSet.of( - assertThat((byte) 1 >= (byte) 2).isTrue(), - assertThat((byte) 1 < (byte) 2).isFalse(), - assertThat((char) 1 >= (char) 2).isTrue(), - assertThat((char) 1 < (char) 2).isFalse(), - assertThat((short) 1 >= (short) 2).isTrue(), - assertThat((short) 1 < (short) 2).isFalse(), - assertThat(1 >= 2).isTrue(), - assertThat(1 < 2).isFalse(), - assertThat(1L >= 2L).isTrue(), - assertThat(1L < 2L).isFalse(), - assertThat(1F >= 2F).isTrue(), - assertThat(1F < 2F).isFalse(), - assertThat(1.0 >= 2.0).isTrue(), - assertThat(1.0 < 2.0).isFalse()); - } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java index 097d22de9b..12ec9c93be 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJDoubleTemplatesTestOutput.java @@ -5,7 +5,6 @@ import static org.assertj.core.data.Percentage.withPercentage; import com.google.common.collect.ImmutableSet; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractDoubleAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; @@ -25,52 +24,10 @@ ImmutableSet> testAbstractDoubleAssertIsEqualTo() { return ImmutableSet.of(assertThat(0.0).isEqualTo(1), assertThat(0.0).isEqualTo(1)); } - @SuppressWarnings("SimplifyBooleanExpression") - ImmutableSet> testAssertThatIsEqualTo() { - return ImmutableSet.of( - assertThat(true).isEqualTo(false), - assertThat(true).isEqualTo(false), - assertThat((byte) 1).isEqualTo((byte) 2), - assertThat((byte) 1).isEqualTo((byte) 2), - assertThat((char) 1).isEqualTo((char) 2), - assertThat((char) 1).isEqualTo((char) 2), - assertThat((short) 1).isEqualTo((short) 2), - assertThat((short) 1).isEqualTo((short) 2), - assertThat(1).isEqualTo(2), - assertThat(1).isEqualTo(2), - assertThat(1L).isEqualTo(2L), - assertThat(1L).isEqualTo(2L), - assertThat(1F).isEqualTo(2F), - assertThat(1F).isEqualTo(2F), - assertThat(1.0).isEqualTo(2.0), - assertThat(1.0).isEqualTo(2.0)); - } - ImmutableSet> testAbstractDoubleAssertIsNotEqualTo() { return ImmutableSet.of(assertThat(0.0).isNotEqualTo(1), assertThat(0.0).isNotEqualTo(1)); } - @SuppressWarnings("SimplifyBooleanExpression") - ImmutableSet> testAssertThatIsNotEqualTo() { - return ImmutableSet.of( - assertThat(true).isNotEqualTo(false), - assertThat(true).isNotEqualTo(false), - assertThat((byte) 1).isNotEqualTo((byte) 2), - assertThat((byte) 1).isNotEqualTo((byte) 2), - assertThat((char) 1).isNotEqualTo((char) 2), - assertThat((char) 1).isNotEqualTo((char) 2), - assertThat((short) 1).isNotEqualTo((short) 2), - assertThat((short) 1).isNotEqualTo((short) 2), - assertThat(1).isNotEqualTo(2), - assertThat(1).isNotEqualTo(2), - assertThat(1L).isNotEqualTo(2L), - assertThat(1L).isNotEqualTo(2L), - assertThat(1F).isNotEqualTo(2F), - assertThat(1F).isNotEqualTo(2F), - assertThat(1.0).isNotEqualTo(2.0), - assertThat(1.0).isNotEqualTo(2.0)); - } - AbstractDoubleAssert testAbstractDoubleAssertIsZero() { return assertThat(0.0).isEqualTo(0); } @@ -82,76 +39,4 @@ AbstractDoubleAssert testAbstractDoubleAssertIsNotZero() { AbstractDoubleAssert testAbstractDoubleAssertIsOne() { return assertThat(0.0).isEqualTo(1); } - - ImmutableSet> testAssertThatIsLessThan() { - return ImmutableSet.of( - assertThat((byte) 1).isLessThan((byte) 2), - assertThat((byte) 1).isLessThan((byte) 2), - assertThat((char) 1).isLessThan((char) 2), - assertThat((char) 1).isLessThan((char) 2), - assertThat((short) 1).isLessThan((short) 2), - assertThat((short) 1).isLessThan((short) 2), - assertThat(1).isLessThan(2), - assertThat(1).isLessThan(2), - assertThat(1L).isLessThan(2L), - assertThat(1L).isLessThan(2L), - assertThat(1F).isLessThan(2F), - assertThat(1F).isLessThan(2F), - assertThat(1.0).isLessThan(2.0), - assertThat(1.0).isLessThan(2.0)); - } - - ImmutableSet> testAssertThatIsLessThanOrEqualTo() { - return ImmutableSet.of( - assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), - assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), - assertThat((char) 1).isLessThanOrEqualTo((char) 2), - assertThat((char) 1).isLessThanOrEqualTo((char) 2), - assertThat((short) 1).isLessThanOrEqualTo((short) 2), - assertThat((short) 1).isLessThanOrEqualTo((short) 2), - assertThat(1).isLessThanOrEqualTo(2), - assertThat(1).isLessThanOrEqualTo(2), - assertThat(1L).isLessThanOrEqualTo(2L), - assertThat(1L).isLessThanOrEqualTo(2L), - assertThat(1F).isLessThanOrEqualTo(2F), - assertThat(1F).isLessThanOrEqualTo(2F), - assertThat(1.0).isLessThanOrEqualTo(2.0), - assertThat(1.0).isLessThanOrEqualTo(2.0)); - } - - ImmutableSet> testAssertThatIsGreaterThan() { - return ImmutableSet.of( - assertThat((byte) 1).isGreaterThan((byte) 2), - assertThat((byte) 1).isGreaterThan((byte) 2), - assertThat((char) 1).isGreaterThan((char) 2), - assertThat((char) 1).isGreaterThan((char) 2), - assertThat((short) 1).isGreaterThan((short) 2), - assertThat((short) 1).isGreaterThan((short) 2), - assertThat(1).isGreaterThan(2), - assertThat(1).isGreaterThan(2), - assertThat(1L).isGreaterThan(2L), - assertThat(1L).isGreaterThan(2L), - assertThat(1F).isGreaterThan(2F), - assertThat(1F).isGreaterThan(2F), - assertThat(1.0).isGreaterThan(2.0), - assertThat(1.0).isGreaterThan(2.0)); - } - - ImmutableSet> testAssertThatIsGreaterThanOrEqualTo() { - return ImmutableSet.of( - assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), - assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), - assertThat((char) 1).isGreaterThanOrEqualTo((char) 2), - assertThat((char) 1).isGreaterThanOrEqualTo((char) 2), - assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), - assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), - assertThat(1).isGreaterThanOrEqualTo(2), - assertThat(1).isGreaterThanOrEqualTo(2), - assertThat(1L).isGreaterThanOrEqualTo(2L), - assertThat(1L).isGreaterThanOrEqualTo(2L), - assertThat(1F).isGreaterThanOrEqualTo(2F), - assertThat(1F).isGreaterThanOrEqualTo(2F), - assertThat(1.0).isGreaterThanOrEqualTo(2.0), - assertThat(1.0).isGreaterThanOrEqualTo(2.0)); - } } diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestInput.java index ce5773aabe..9ec4adb608 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestInput.java @@ -5,10 +5,125 @@ import com.google.common.collect.ImmutableSet; import java.math.BigDecimal; import java.math.BigInteger; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.NumberAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase { + @SuppressWarnings("SimplifyBooleanExpression") + ImmutableSet> testAssertThatIsEqualTo() { + return ImmutableSet.of( + assertThat(true == false).isTrue(), + assertThat(true != false).isFalse(), + assertThat((byte) 1 == (byte) 2).isTrue(), + assertThat((byte) 1 != (byte) 2).isFalse(), + assertThat((char) 1 == (char) 2).isTrue(), + assertThat((char) 1 != (char) 2).isFalse(), + assertThat((short) 1 == (short) 2).isTrue(), + assertThat((short) 1 != (short) 2).isFalse(), + assertThat(1 == 2).isTrue(), + assertThat(1 != 2).isFalse(), + assertThat(1L == 2L).isTrue(), + assertThat(1L != 2L).isFalse(), + assertThat(1F == 2F).isTrue(), + assertThat(1F != 2F).isFalse(), + assertThat(1.0 == 2.0).isTrue(), + assertThat(1.0 != 2.0).isFalse()); + } + + @SuppressWarnings("SimplifyBooleanExpression") + ImmutableSet> testAssertThatIsNotEqualTo() { + return ImmutableSet.of( + assertThat(true != false).isTrue(), + assertThat(true == false).isFalse(), + assertThat((byte) 1 != (byte) 2).isTrue(), + assertThat((byte) 1 == (byte) 2).isFalse(), + assertThat((char) 1 != (char) 2).isTrue(), + assertThat((char) 1 == (char) 2).isFalse(), + assertThat((short) 1 != (short) 2).isTrue(), + assertThat((short) 1 == (short) 2).isFalse(), + assertThat(1 != 2).isTrue(), + assertThat(1 == 2).isFalse(), + assertThat(1L != 2L).isTrue(), + assertThat(1L == 2L).isFalse(), + assertThat(1F != 2F).isTrue(), + assertThat(1F == 2F).isFalse(), + assertThat(1.0 != 2.0).isTrue(), + assertThat(1.0 == 2.0).isFalse()); + } + + ImmutableSet> testAssertThatIsLessThan() { + return ImmutableSet.of( + assertThat((byte) 1 < (byte) 2).isTrue(), + assertThat((byte) 1 >= (byte) 2).isFalse(), + assertThat((char) 1 < (char) 2).isTrue(), + assertThat((char) 1 >= (char) 2).isFalse(), + assertThat((short) 1 < (short) 2).isTrue(), + assertThat((short) 1 >= (short) 2).isFalse(), + assertThat(1 < 2).isTrue(), + assertThat(1 >= 2).isFalse(), + assertThat(1L < 2L).isTrue(), + assertThat(1L >= 2L).isFalse(), + assertThat(1F < 2F).isTrue(), + assertThat(1F >= 2F).isFalse(), + assertThat(1.0 < 2.0).isTrue(), + assertThat(1.0 >= 2.0).isFalse()); + } + + ImmutableSet> testAssertThatIsLessThanOrEqualTo() { + return ImmutableSet.of( + assertThat((byte) 1 <= (byte) 2).isTrue(), + assertThat((byte) 1 > (byte) 2).isFalse(), + assertThat((char) 1 <= (char) 2).isTrue(), + assertThat((char) 1 > (char) 2).isFalse(), + assertThat((short) 1 <= (short) 2).isTrue(), + assertThat((short) 1 > (short) 2).isFalse(), + assertThat(1 <= 2).isTrue(), + assertThat(1 > 2).isFalse(), + assertThat(1L <= 2L).isTrue(), + assertThat(1L > 2L).isFalse(), + assertThat(1F <= 2F).isTrue(), + assertThat(1F > 2F).isFalse(), + assertThat(1.0 <= 2.0).isTrue(), + assertThat(1.0 > 2.0).isFalse()); + } + + ImmutableSet> testAssertThatIsGreaterThan() { + return ImmutableSet.of( + assertThat((byte) 1 > (byte) 2).isTrue(), + assertThat((byte) 1 <= (byte) 2).isFalse(), + assertThat((char) 1 > (char) 2).isTrue(), + assertThat((char) 1 <= (char) 2).isFalse(), + assertThat((short) 1 > (short) 2).isTrue(), + assertThat((short) 1 <= (short) 2).isFalse(), + assertThat(1 > 2).isTrue(), + assertThat(1 <= 2).isFalse(), + assertThat(1L > 2L).isTrue(), + assertThat(1L <= 2L).isFalse(), + assertThat(1F > 2F).isTrue(), + assertThat(1F <= 2F).isFalse(), + assertThat(1.0 > 2.0).isTrue(), + assertThat(1.0 <= 2.0).isFalse()); + } + + ImmutableSet> testAssertThatIsGreaterThanOrEqualTo() { + return ImmutableSet.of( + assertThat((byte) 1 >= (byte) 2).isTrue(), + assertThat((byte) 1 < (byte) 2).isFalse(), + assertThat((char) 1 >= (char) 2).isTrue(), + assertThat((char) 1 < (char) 2).isFalse(), + assertThat((short) 1 >= (short) 2).isTrue(), + assertThat((short) 1 < (short) 2).isFalse(), + assertThat(1 >= 2).isTrue(), + assertThat(1 < 2).isFalse(), + assertThat(1L >= 2L).isTrue(), + assertThat(1L < 2L).isFalse(), + assertThat(1F >= 2F).isTrue(), + assertThat(1F < 2F).isFalse(), + assertThat(1.0 >= 2.0).isTrue(), + assertThat(1.0 < 2.0).isFalse()); + } + ImmutableSet> testNumberAssertIsPositive() { return ImmutableSet.of( assertThat((byte) 0).isGreaterThan((byte) 0), diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestOutput.java index 227fedf57e..a9880b2dbb 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestOutput.java @@ -5,10 +5,125 @@ import com.google.common.collect.ImmutableSet; import java.math.BigDecimal; import java.math.BigInteger; +import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.NumberAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase { + @SuppressWarnings("SimplifyBooleanExpression") + ImmutableSet> testAssertThatIsEqualTo() { + return ImmutableSet.of( + assertThat(true).isEqualTo(false), + assertThat(true).isEqualTo(false), + assertThat((byte) 1).isEqualTo((byte) 2), + assertThat((byte) 1).isEqualTo((byte) 2), + assertThat((char) 1).isEqualTo((char) 2), + assertThat((char) 1).isEqualTo((char) 2), + assertThat((short) 1).isEqualTo((short) 2), + assertThat((short) 1).isEqualTo((short) 2), + assertThat(1).isEqualTo(2), + assertThat(1).isEqualTo(2), + assertThat(1L).isEqualTo(2L), + assertThat(1L).isEqualTo(2L), + assertThat(1F).isEqualTo(2F), + assertThat(1F).isEqualTo(2F), + assertThat(1.0).isEqualTo(2.0), + assertThat(1.0).isEqualTo(2.0)); + } + + @SuppressWarnings("SimplifyBooleanExpression") + ImmutableSet> testAssertThatIsNotEqualTo() { + return ImmutableSet.of( + assertThat(true).isNotEqualTo(false), + assertThat(true).isNotEqualTo(false), + assertThat((byte) 1).isNotEqualTo((byte) 2), + assertThat((byte) 1).isNotEqualTo((byte) 2), + assertThat((char) 1).isNotEqualTo((char) 2), + assertThat((char) 1).isNotEqualTo((char) 2), + assertThat((short) 1).isNotEqualTo((short) 2), + assertThat((short) 1).isNotEqualTo((short) 2), + assertThat(1).isNotEqualTo(2), + assertThat(1).isNotEqualTo(2), + assertThat(1L).isNotEqualTo(2L), + assertThat(1L).isNotEqualTo(2L), + assertThat(1F).isNotEqualTo(2F), + assertThat(1F).isNotEqualTo(2F), + assertThat(1.0).isNotEqualTo(2.0), + assertThat(1.0).isNotEqualTo(2.0)); + } + + ImmutableSet> testAssertThatIsLessThan() { + return ImmutableSet.of( + assertThat((byte) 1).isLessThan((byte) 2), + assertThat((byte) 1).isLessThan((byte) 2), + assertThat((char) 1).isLessThan((char) 2), + assertThat((char) 1).isLessThan((char) 2), + assertThat((short) 1).isLessThan((short) 2), + assertThat((short) 1).isLessThan((short) 2), + assertThat(1).isLessThan(2), + assertThat(1).isLessThan(2), + assertThat(1L).isLessThan(2L), + assertThat(1L).isLessThan(2L), + assertThat(1F).isLessThan(2F), + assertThat(1F).isLessThan(2F), + assertThat(1.0).isLessThan(2.0), + assertThat(1.0).isLessThan(2.0)); + } + + ImmutableSet> testAssertThatIsLessThanOrEqualTo() { + return ImmutableSet.of( + assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), + assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), + assertThat((char) 1).isLessThanOrEqualTo((char) 2), + assertThat((char) 1).isLessThanOrEqualTo((char) 2), + assertThat((short) 1).isLessThanOrEqualTo((short) 2), + assertThat((short) 1).isLessThanOrEqualTo((short) 2), + assertThat(1).isLessThanOrEqualTo(2), + assertThat(1).isLessThanOrEqualTo(2), + assertThat(1L).isLessThanOrEqualTo(2L), + assertThat(1L).isLessThanOrEqualTo(2L), + assertThat(1F).isLessThanOrEqualTo(2F), + assertThat(1F).isLessThanOrEqualTo(2F), + assertThat(1.0).isLessThanOrEqualTo(2.0), + assertThat(1.0).isLessThanOrEqualTo(2.0)); + } + + ImmutableSet> testAssertThatIsGreaterThan() { + return ImmutableSet.of( + assertThat((byte) 1).isGreaterThan((byte) 2), + assertThat((byte) 1).isGreaterThan((byte) 2), + assertThat((char) 1).isGreaterThan((char) 2), + assertThat((char) 1).isGreaterThan((char) 2), + assertThat((short) 1).isGreaterThan((short) 2), + assertThat((short) 1).isGreaterThan((short) 2), + assertThat(1).isGreaterThan(2), + assertThat(1).isGreaterThan(2), + assertThat(1L).isGreaterThan(2L), + assertThat(1L).isGreaterThan(2L), + assertThat(1F).isGreaterThan(2F), + assertThat(1F).isGreaterThan(2F), + assertThat(1.0).isGreaterThan(2.0), + assertThat(1.0).isGreaterThan(2.0)); + } + + ImmutableSet> testAssertThatIsGreaterThanOrEqualTo() { + return ImmutableSet.of( + assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), + assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), + assertThat((char) 1).isGreaterThanOrEqualTo((char) 2), + assertThat((char) 1).isGreaterThanOrEqualTo((char) 2), + assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), + assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), + assertThat(1).isGreaterThanOrEqualTo(2), + assertThat(1).isGreaterThanOrEqualTo(2), + assertThat(1L).isGreaterThanOrEqualTo(2L), + assertThat(1L).isGreaterThanOrEqualTo(2L), + assertThat(1F).isGreaterThanOrEqualTo(2F), + assertThat(1F).isGreaterThanOrEqualTo(2F), + assertThat(1.0).isGreaterThanOrEqualTo(2.0), + assertThat(1.0).isGreaterThanOrEqualTo(2.0)); + } + ImmutableSet> testNumberAssertIsPositive() { return ImmutableSet.of( assertThat((byte) 0).isPositive(), From e4042dcad256c51ee285f620cfc8fbdc50f99b59 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Fri, 9 Sep 2022 11:49:36 +0200 Subject: [PATCH 15/16] Introduce `AssertJPrimitiveTemplates` and move some templates --- .../AssertJNumberTemplates.java | 97 -------------- .../AssertJPrimitivesTemplates.java | 111 ++++++++++++++++ .../RefasterTemplatesTest.java | 1 + .../AssertJNumberTemplatesTestInput.java | 115 ---------------- .../AssertJNumberTemplatesTestOutput.java | 115 ---------------- .../AssertJPrimitivesTemplatesTestInput.java | 123 ++++++++++++++++++ .../AssertJPrimitivesTemplatesTestOutput.java | 123 ++++++++++++++++++ 7 files changed, 358 insertions(+), 327 deletions(-) create mode 100644 error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplates.java create mode 100644 error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestInput.java create mode 100644 error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestOutput.java diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplates.java index f7c49d311b..3d2cb4cd32 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplates.java @@ -12,7 +12,6 @@ import java.math.BigInteger; import org.assertj.core.api.AbstractBigDecimalAssert; import org.assertj.core.api.AbstractBigIntegerAssert; -import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractByteAssert; import org.assertj.core.api.AbstractDoubleAssert; import org.assertj.core.api.AbstractFloatAssert; @@ -25,102 +24,6 @@ final class AssertJNumberTemplates { private AssertJNumberTemplates() {} - static final class AssertThatIsEqualTo { - @BeforeTemplate - AbstractBooleanAssert before(boolean actual, boolean expected) { - return Refaster.anyOf( - assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); - } - - @BeforeTemplate - AbstractBooleanAssert before(double actual, double expected) { - return Refaster.anyOf( - assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractBooleanAssert after(boolean actual, boolean expected) { - return assertThat(actual).isEqualTo(expected); - } - } - - static final class AssertThatIsNotEqualTo { - @BeforeTemplate - AbstractBooleanAssert before(boolean actual, boolean expected) { - return Refaster.anyOf( - assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); - } - - @BeforeTemplate - AbstractBooleanAssert before(double actual, double expected) { - return Refaster.anyOf( - assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractBooleanAssert after(boolean actual, boolean expected) { - return assertThat(actual).isNotEqualTo(expected); - } - } - - static final class AssertThatIsLessThan { - @BeforeTemplate - AbstractBooleanAssert before(double actual, double expected) { - return Refaster.anyOf( - assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractDoubleAssert after(double actual, double expected) { - return assertThat(actual).isLessThan(expected); - } - } - - static final class AssertThatIsLessThanOrEqualTo { - @BeforeTemplate - AbstractBooleanAssert before(double actual, double expected) { - return Refaster.anyOf( - assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractDoubleAssert after(double actual, double expected) { - return assertThat(actual).isLessThanOrEqualTo(expected); - } - } - - static final class AssertThatIsGreaterThan { - @BeforeTemplate - AbstractBooleanAssert before(double actual, double expected) { - return Refaster.anyOf( - assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractDoubleAssert after(double actual, double expected) { - return assertThat(actual).isGreaterThan(expected); - } - } - - static final class AssertThatIsGreaterThanOrEqualTo { - @BeforeTemplate - AbstractBooleanAssert before(double actual, double expected) { - return Refaster.anyOf( - assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); - } - - @AfterTemplate - @UseImportPolicy(STATIC_IMPORT_ALWAYS) - AbstractDoubleAssert after(double actual, double expected) { - return assertThat(actual).isGreaterThanOrEqualTo(expected); - } - } - static final class NumberAssertIsPositive { @BeforeTemplate AbstractByteAssert before(AbstractByteAssert numberAssert) { diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplates.java new file mode 100644 index 0000000000..202b3e735b --- /dev/null +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplates.java @@ -0,0 +1,111 @@ +package tech.picnic.errorprone.refastertemplates; + +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.errorprone.refaster.Refaster; +import com.google.errorprone.refaster.annotation.AfterTemplate; +import com.google.errorprone.refaster.annotation.BeforeTemplate; +import com.google.errorprone.refaster.annotation.UseImportPolicy; +import org.assertj.core.api.AbstractBooleanAssert; +import org.assertj.core.api.AbstractDoubleAssert; + +final class AssertJPrimitivesTemplates { + private AssertJPrimitivesTemplates() {} + + static final class AssertThatIsEqualTo { + @BeforeTemplate + AbstractBooleanAssert before(boolean actual, boolean expected) { + return Refaster.anyOf( + assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); + } + + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractBooleanAssert after(boolean actual, boolean expected) { + return assertThat(actual).isEqualTo(expected); + } + } + + static final class AssertThatIsNotEqualTo { + @BeforeTemplate + AbstractBooleanAssert before(boolean actual, boolean expected) { + return Refaster.anyOf( + assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); + } + + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractBooleanAssert after(boolean actual, boolean expected) { + return assertThat(actual).isNotEqualTo(expected); + } + } + + static final class AssertThatIsLessThan { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual < expected).isTrue(), assertThat(actual >= expected).isFalse()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isLessThan(expected); + } + } + + static final class AssertThatIsLessThanOrEqualTo { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual <= expected).isTrue(), assertThat(actual > expected).isFalse()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isLessThanOrEqualTo(expected); + } + } + + static final class AssertThatIsGreaterThan { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual > expected).isTrue(), assertThat(actual <= expected).isFalse()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isGreaterThan(expected); + } + } + + static final class AssertThatIsGreaterThanOrEqualTo { + @BeforeTemplate + AbstractBooleanAssert before(double actual, double expected) { + return Refaster.anyOf( + assertThat(actual >= expected).isTrue(), assertThat(actual < expected).isFalse()); + } + + @AfterTemplate + @UseImportPolicy(STATIC_IMPORT_ALWAYS) + AbstractDoubleAssert after(double actual, double expected) { + return assertThat(actual).isGreaterThanOrEqualTo(expected); + } + } +} diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.java index b0c235bdf0..3880f62747 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.java @@ -29,6 +29,7 @@ final class RefasterTemplatesTest { AssertJMapTemplates.class, AssertJObjectTemplates.class, AssertJOptionalTemplates.class, + AssertJPrimitivesTemplates.class, AssertJShortTemplates.class, AssertJStringTemplates.class, AssertJThrowingCallableTemplates.class, diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestInput.java index 9ec4adb608..ce5773aabe 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestInput.java @@ -5,125 +5,10 @@ import com.google.common.collect.ImmutableSet; import java.math.BigDecimal; import java.math.BigInteger; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.NumberAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase { - @SuppressWarnings("SimplifyBooleanExpression") - ImmutableSet> testAssertThatIsEqualTo() { - return ImmutableSet.of( - assertThat(true == false).isTrue(), - assertThat(true != false).isFalse(), - assertThat((byte) 1 == (byte) 2).isTrue(), - assertThat((byte) 1 != (byte) 2).isFalse(), - assertThat((char) 1 == (char) 2).isTrue(), - assertThat((char) 1 != (char) 2).isFalse(), - assertThat((short) 1 == (short) 2).isTrue(), - assertThat((short) 1 != (short) 2).isFalse(), - assertThat(1 == 2).isTrue(), - assertThat(1 != 2).isFalse(), - assertThat(1L == 2L).isTrue(), - assertThat(1L != 2L).isFalse(), - assertThat(1F == 2F).isTrue(), - assertThat(1F != 2F).isFalse(), - assertThat(1.0 == 2.0).isTrue(), - assertThat(1.0 != 2.0).isFalse()); - } - - @SuppressWarnings("SimplifyBooleanExpression") - ImmutableSet> testAssertThatIsNotEqualTo() { - return ImmutableSet.of( - assertThat(true != false).isTrue(), - assertThat(true == false).isFalse(), - assertThat((byte) 1 != (byte) 2).isTrue(), - assertThat((byte) 1 == (byte) 2).isFalse(), - assertThat((char) 1 != (char) 2).isTrue(), - assertThat((char) 1 == (char) 2).isFalse(), - assertThat((short) 1 != (short) 2).isTrue(), - assertThat((short) 1 == (short) 2).isFalse(), - assertThat(1 != 2).isTrue(), - assertThat(1 == 2).isFalse(), - assertThat(1L != 2L).isTrue(), - assertThat(1L == 2L).isFalse(), - assertThat(1F != 2F).isTrue(), - assertThat(1F == 2F).isFalse(), - assertThat(1.0 != 2.0).isTrue(), - assertThat(1.0 == 2.0).isFalse()); - } - - ImmutableSet> testAssertThatIsLessThan() { - return ImmutableSet.of( - assertThat((byte) 1 < (byte) 2).isTrue(), - assertThat((byte) 1 >= (byte) 2).isFalse(), - assertThat((char) 1 < (char) 2).isTrue(), - assertThat((char) 1 >= (char) 2).isFalse(), - assertThat((short) 1 < (short) 2).isTrue(), - assertThat((short) 1 >= (short) 2).isFalse(), - assertThat(1 < 2).isTrue(), - assertThat(1 >= 2).isFalse(), - assertThat(1L < 2L).isTrue(), - assertThat(1L >= 2L).isFalse(), - assertThat(1F < 2F).isTrue(), - assertThat(1F >= 2F).isFalse(), - assertThat(1.0 < 2.0).isTrue(), - assertThat(1.0 >= 2.0).isFalse()); - } - - ImmutableSet> testAssertThatIsLessThanOrEqualTo() { - return ImmutableSet.of( - assertThat((byte) 1 <= (byte) 2).isTrue(), - assertThat((byte) 1 > (byte) 2).isFalse(), - assertThat((char) 1 <= (char) 2).isTrue(), - assertThat((char) 1 > (char) 2).isFalse(), - assertThat((short) 1 <= (short) 2).isTrue(), - assertThat((short) 1 > (short) 2).isFalse(), - assertThat(1 <= 2).isTrue(), - assertThat(1 > 2).isFalse(), - assertThat(1L <= 2L).isTrue(), - assertThat(1L > 2L).isFalse(), - assertThat(1F <= 2F).isTrue(), - assertThat(1F > 2F).isFalse(), - assertThat(1.0 <= 2.0).isTrue(), - assertThat(1.0 > 2.0).isFalse()); - } - - ImmutableSet> testAssertThatIsGreaterThan() { - return ImmutableSet.of( - assertThat((byte) 1 > (byte) 2).isTrue(), - assertThat((byte) 1 <= (byte) 2).isFalse(), - assertThat((char) 1 > (char) 2).isTrue(), - assertThat((char) 1 <= (char) 2).isFalse(), - assertThat((short) 1 > (short) 2).isTrue(), - assertThat((short) 1 <= (short) 2).isFalse(), - assertThat(1 > 2).isTrue(), - assertThat(1 <= 2).isFalse(), - assertThat(1L > 2L).isTrue(), - assertThat(1L <= 2L).isFalse(), - assertThat(1F > 2F).isTrue(), - assertThat(1F <= 2F).isFalse(), - assertThat(1.0 > 2.0).isTrue(), - assertThat(1.0 <= 2.0).isFalse()); - } - - ImmutableSet> testAssertThatIsGreaterThanOrEqualTo() { - return ImmutableSet.of( - assertThat((byte) 1 >= (byte) 2).isTrue(), - assertThat((byte) 1 < (byte) 2).isFalse(), - assertThat((char) 1 >= (char) 2).isTrue(), - assertThat((char) 1 < (char) 2).isFalse(), - assertThat((short) 1 >= (short) 2).isTrue(), - assertThat((short) 1 < (short) 2).isFalse(), - assertThat(1 >= 2).isTrue(), - assertThat(1 < 2).isFalse(), - assertThat(1L >= 2L).isTrue(), - assertThat(1L < 2L).isFalse(), - assertThat(1F >= 2F).isTrue(), - assertThat(1F < 2F).isFalse(), - assertThat(1.0 >= 2.0).isTrue(), - assertThat(1.0 < 2.0).isFalse()); - } - ImmutableSet> testNumberAssertIsPositive() { return ImmutableSet.of( assertThat((byte) 0).isGreaterThan((byte) 0), diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestOutput.java index a9880b2dbb..227fedf57e 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJNumberTemplatesTestOutput.java @@ -5,125 +5,10 @@ import com.google.common.collect.ImmutableSet; import java.math.BigDecimal; import java.math.BigInteger; -import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.NumberAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase { - @SuppressWarnings("SimplifyBooleanExpression") - ImmutableSet> testAssertThatIsEqualTo() { - return ImmutableSet.of( - assertThat(true).isEqualTo(false), - assertThat(true).isEqualTo(false), - assertThat((byte) 1).isEqualTo((byte) 2), - assertThat((byte) 1).isEqualTo((byte) 2), - assertThat((char) 1).isEqualTo((char) 2), - assertThat((char) 1).isEqualTo((char) 2), - assertThat((short) 1).isEqualTo((short) 2), - assertThat((short) 1).isEqualTo((short) 2), - assertThat(1).isEqualTo(2), - assertThat(1).isEqualTo(2), - assertThat(1L).isEqualTo(2L), - assertThat(1L).isEqualTo(2L), - assertThat(1F).isEqualTo(2F), - assertThat(1F).isEqualTo(2F), - assertThat(1.0).isEqualTo(2.0), - assertThat(1.0).isEqualTo(2.0)); - } - - @SuppressWarnings("SimplifyBooleanExpression") - ImmutableSet> testAssertThatIsNotEqualTo() { - return ImmutableSet.of( - assertThat(true).isNotEqualTo(false), - assertThat(true).isNotEqualTo(false), - assertThat((byte) 1).isNotEqualTo((byte) 2), - assertThat((byte) 1).isNotEqualTo((byte) 2), - assertThat((char) 1).isNotEqualTo((char) 2), - assertThat((char) 1).isNotEqualTo((char) 2), - assertThat((short) 1).isNotEqualTo((short) 2), - assertThat((short) 1).isNotEqualTo((short) 2), - assertThat(1).isNotEqualTo(2), - assertThat(1).isNotEqualTo(2), - assertThat(1L).isNotEqualTo(2L), - assertThat(1L).isNotEqualTo(2L), - assertThat(1F).isNotEqualTo(2F), - assertThat(1F).isNotEqualTo(2F), - assertThat(1.0).isNotEqualTo(2.0), - assertThat(1.0).isNotEqualTo(2.0)); - } - - ImmutableSet> testAssertThatIsLessThan() { - return ImmutableSet.of( - assertThat((byte) 1).isLessThan((byte) 2), - assertThat((byte) 1).isLessThan((byte) 2), - assertThat((char) 1).isLessThan((char) 2), - assertThat((char) 1).isLessThan((char) 2), - assertThat((short) 1).isLessThan((short) 2), - assertThat((short) 1).isLessThan((short) 2), - assertThat(1).isLessThan(2), - assertThat(1).isLessThan(2), - assertThat(1L).isLessThan(2L), - assertThat(1L).isLessThan(2L), - assertThat(1F).isLessThan(2F), - assertThat(1F).isLessThan(2F), - assertThat(1.0).isLessThan(2.0), - assertThat(1.0).isLessThan(2.0)); - } - - ImmutableSet> testAssertThatIsLessThanOrEqualTo() { - return ImmutableSet.of( - assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), - assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), - assertThat((char) 1).isLessThanOrEqualTo((char) 2), - assertThat((char) 1).isLessThanOrEqualTo((char) 2), - assertThat((short) 1).isLessThanOrEqualTo((short) 2), - assertThat((short) 1).isLessThanOrEqualTo((short) 2), - assertThat(1).isLessThanOrEqualTo(2), - assertThat(1).isLessThanOrEqualTo(2), - assertThat(1L).isLessThanOrEqualTo(2L), - assertThat(1L).isLessThanOrEqualTo(2L), - assertThat(1F).isLessThanOrEqualTo(2F), - assertThat(1F).isLessThanOrEqualTo(2F), - assertThat(1.0).isLessThanOrEqualTo(2.0), - assertThat(1.0).isLessThanOrEqualTo(2.0)); - } - - ImmutableSet> testAssertThatIsGreaterThan() { - return ImmutableSet.of( - assertThat((byte) 1).isGreaterThan((byte) 2), - assertThat((byte) 1).isGreaterThan((byte) 2), - assertThat((char) 1).isGreaterThan((char) 2), - assertThat((char) 1).isGreaterThan((char) 2), - assertThat((short) 1).isGreaterThan((short) 2), - assertThat((short) 1).isGreaterThan((short) 2), - assertThat(1).isGreaterThan(2), - assertThat(1).isGreaterThan(2), - assertThat(1L).isGreaterThan(2L), - assertThat(1L).isGreaterThan(2L), - assertThat(1F).isGreaterThan(2F), - assertThat(1F).isGreaterThan(2F), - assertThat(1.0).isGreaterThan(2.0), - assertThat(1.0).isGreaterThan(2.0)); - } - - ImmutableSet> testAssertThatIsGreaterThanOrEqualTo() { - return ImmutableSet.of( - assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), - assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), - assertThat((char) 1).isGreaterThanOrEqualTo((char) 2), - assertThat((char) 1).isGreaterThanOrEqualTo((char) 2), - assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), - assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), - assertThat(1).isGreaterThanOrEqualTo(2), - assertThat(1).isGreaterThanOrEqualTo(2), - assertThat(1L).isGreaterThanOrEqualTo(2L), - assertThat(1L).isGreaterThanOrEqualTo(2L), - assertThat(1F).isGreaterThanOrEqualTo(2F), - assertThat(1F).isGreaterThanOrEqualTo(2F), - assertThat(1.0).isGreaterThanOrEqualTo(2.0), - assertThat(1.0).isGreaterThanOrEqualTo(2.0)); - } - ImmutableSet> testNumberAssertIsPositive() { return ImmutableSet.of( assertThat((byte) 0).isPositive(), diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestInput.java new file mode 100644 index 0000000000..fd07a1d8bd --- /dev/null +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestInput.java @@ -0,0 +1,123 @@ +package tech.picnic.errorprone.refastertemplates; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractAssert; +import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; + +final class AssertJStringTemplatesTest implements RefasterTemplateTestCase { + @SuppressWarnings("SimplifyBooleanExpression") + ImmutableSet> testAssertThatIsEqualTo() { + return ImmutableSet.of( + assertThat(true == false).isTrue(), + assertThat(true != false).isFalse(), + assertThat((byte) 1 == (byte) 2).isTrue(), + assertThat((byte) 1 != (byte) 2).isFalse(), + assertThat((char) 1 == (char) 2).isTrue(), + assertThat((char) 1 != (char) 2).isFalse(), + assertThat((short) 1 == (short) 2).isTrue(), + assertThat((short) 1 != (short) 2).isFalse(), + assertThat(1 == 2).isTrue(), + assertThat(1 != 2).isFalse(), + assertThat(1L == 2L).isTrue(), + assertThat(1L != 2L).isFalse(), + assertThat(1F == 2F).isTrue(), + assertThat(1F != 2F).isFalse(), + assertThat(1.0 == 2.0).isTrue(), + assertThat(1.0 != 2.0).isFalse()); + } + + @SuppressWarnings("SimplifyBooleanExpression") + ImmutableSet> testAssertThatIsNotEqualTo() { + return ImmutableSet.of( + assertThat(true != false).isTrue(), + assertThat(true == false).isFalse(), + assertThat((byte) 1 != (byte) 2).isTrue(), + assertThat((byte) 1 == (byte) 2).isFalse(), + assertThat((char) 1 != (char) 2).isTrue(), + assertThat((char) 1 == (char) 2).isFalse(), + assertThat((short) 1 != (short) 2).isTrue(), + assertThat((short) 1 == (short) 2).isFalse(), + assertThat(1 != 2).isTrue(), + assertThat(1 == 2).isFalse(), + assertThat(1L != 2L).isTrue(), + assertThat(1L == 2L).isFalse(), + assertThat(1F != 2F).isTrue(), + assertThat(1F == 2F).isFalse(), + assertThat(1.0 != 2.0).isTrue(), + assertThat(1.0 == 2.0).isFalse()); + } + + ImmutableSet> testAssertThatIsLessThan() { + return ImmutableSet.of( + assertThat((byte) 1 < (byte) 2).isTrue(), + assertThat((byte) 1 >= (byte) 2).isFalse(), + assertThat((char) 1 < (char) 2).isTrue(), + assertThat((char) 1 >= (char) 2).isFalse(), + assertThat((short) 1 < (short) 2).isTrue(), + assertThat((short) 1 >= (short) 2).isFalse(), + assertThat(1 < 2).isTrue(), + assertThat(1 >= 2).isFalse(), + assertThat(1L < 2L).isTrue(), + assertThat(1L >= 2L).isFalse(), + assertThat(1F < 2F).isTrue(), + assertThat(1F >= 2F).isFalse(), + assertThat(1.0 < 2.0).isTrue(), + assertThat(1.0 >= 2.0).isFalse()); + } + + ImmutableSet> testAssertThatIsLessThanOrEqualTo() { + return ImmutableSet.of( + assertThat((byte) 1 <= (byte) 2).isTrue(), + assertThat((byte) 1 > (byte) 2).isFalse(), + assertThat((char) 1 <= (char) 2).isTrue(), + assertThat((char) 1 > (char) 2).isFalse(), + assertThat((short) 1 <= (short) 2).isTrue(), + assertThat((short) 1 > (short) 2).isFalse(), + assertThat(1 <= 2).isTrue(), + assertThat(1 > 2).isFalse(), + assertThat(1L <= 2L).isTrue(), + assertThat(1L > 2L).isFalse(), + assertThat(1F <= 2F).isTrue(), + assertThat(1F > 2F).isFalse(), + assertThat(1.0 <= 2.0).isTrue(), + assertThat(1.0 > 2.0).isFalse()); + } + + ImmutableSet> testAssertThatIsGreaterThan() { + return ImmutableSet.of( + assertThat((byte) 1 > (byte) 2).isTrue(), + assertThat((byte) 1 <= (byte) 2).isFalse(), + assertThat((char) 1 > (char) 2).isTrue(), + assertThat((char) 1 <= (char) 2).isFalse(), + assertThat((short) 1 > (short) 2).isTrue(), + assertThat((short) 1 <= (short) 2).isFalse(), + assertThat(1 > 2).isTrue(), + assertThat(1 <= 2).isFalse(), + assertThat(1L > 2L).isTrue(), + assertThat(1L <= 2L).isFalse(), + assertThat(1F > 2F).isTrue(), + assertThat(1F <= 2F).isFalse(), + assertThat(1.0 > 2.0).isTrue(), + assertThat(1.0 <= 2.0).isFalse()); + } + + ImmutableSet> testAssertThatIsGreaterThanOrEqualTo() { + return ImmutableSet.of( + assertThat((byte) 1 >= (byte) 2).isTrue(), + assertThat((byte) 1 < (byte) 2).isFalse(), + assertThat((char) 1 >= (char) 2).isTrue(), + assertThat((char) 1 < (char) 2).isFalse(), + assertThat((short) 1 >= (short) 2).isTrue(), + assertThat((short) 1 < (short) 2).isFalse(), + assertThat(1 >= 2).isTrue(), + assertThat(1 < 2).isFalse(), + assertThat(1L >= 2L).isTrue(), + assertThat(1L < 2L).isFalse(), + assertThat(1F >= 2F).isTrue(), + assertThat(1F < 2F).isFalse(), + assertThat(1.0 >= 2.0).isTrue(), + assertThat(1.0 < 2.0).isFalse()); + } +} diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestOutput.java new file mode 100644 index 0000000000..b3bfc451ff --- /dev/null +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestOutput.java @@ -0,0 +1,123 @@ +package tech.picnic.errorprone.refastertemplates; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.common.collect.ImmutableSet; +import org.assertj.core.api.AbstractAssert; +import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; + +final class AssertJStringTemplatesTest implements RefasterTemplateTestCase { + @SuppressWarnings("SimplifyBooleanExpression") + ImmutableSet> testAssertThatIsEqualTo() { + return ImmutableSet.of( + assertThat(true).isEqualTo(false), + assertThat(true).isEqualTo(false), + assertThat((byte) 1).isEqualTo((byte) 2), + assertThat((byte) 1).isEqualTo((byte) 2), + assertThat((char) 1).isEqualTo((char) 2), + assertThat((char) 1).isEqualTo((char) 2), + assertThat((short) 1).isEqualTo((short) 2), + assertThat((short) 1).isEqualTo((short) 2), + assertThat(1).isEqualTo(2), + assertThat(1).isEqualTo(2), + assertThat(1L).isEqualTo(2L), + assertThat(1L).isEqualTo(2L), + assertThat(1F).isEqualTo(2F), + assertThat(1F).isEqualTo(2F), + assertThat(1.0).isEqualTo(2.0), + assertThat(1.0).isEqualTo(2.0)); + } + + @SuppressWarnings("SimplifyBooleanExpression") + ImmutableSet> testAssertThatIsNotEqualTo() { + return ImmutableSet.of( + assertThat(true).isNotEqualTo(false), + assertThat(true).isNotEqualTo(false), + assertThat((byte) 1).isNotEqualTo((byte) 2), + assertThat((byte) 1).isNotEqualTo((byte) 2), + assertThat((char) 1).isNotEqualTo((char) 2), + assertThat((char) 1).isNotEqualTo((char) 2), + assertThat((short) 1).isNotEqualTo((short) 2), + assertThat((short) 1).isNotEqualTo((short) 2), + assertThat(1).isNotEqualTo(2), + assertThat(1).isNotEqualTo(2), + assertThat(1L).isNotEqualTo(2L), + assertThat(1L).isNotEqualTo(2L), + assertThat(1F).isNotEqualTo(2F), + assertThat(1F).isNotEqualTo(2F), + assertThat(1.0).isNotEqualTo(2.0), + assertThat(1.0).isNotEqualTo(2.0)); + } + + ImmutableSet> testAssertThatIsLessThan() { + return ImmutableSet.of( + assertThat((byte) 1).isLessThan((byte) 2), + assertThat((byte) 1).isLessThan((byte) 2), + assertThat((char) 1).isLessThan((char) 2), + assertThat((char) 1).isLessThan((char) 2), + assertThat((short) 1).isLessThan((short) 2), + assertThat((short) 1).isLessThan((short) 2), + assertThat(1).isLessThan(2), + assertThat(1).isLessThan(2), + assertThat(1L).isLessThan(2L), + assertThat(1L).isLessThan(2L), + assertThat(1F).isLessThan(2F), + assertThat(1F).isLessThan(2F), + assertThat(1.0).isLessThan(2.0), + assertThat(1.0).isLessThan(2.0)); + } + + ImmutableSet> testAssertThatIsLessThanOrEqualTo() { + return ImmutableSet.of( + assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), + assertThat((byte) 1).isLessThanOrEqualTo((byte) 2), + assertThat((char) 1).isLessThanOrEqualTo((char) 2), + assertThat((char) 1).isLessThanOrEqualTo((char) 2), + assertThat((short) 1).isLessThanOrEqualTo((short) 2), + assertThat((short) 1).isLessThanOrEqualTo((short) 2), + assertThat(1).isLessThanOrEqualTo(2), + assertThat(1).isLessThanOrEqualTo(2), + assertThat(1L).isLessThanOrEqualTo(2L), + assertThat(1L).isLessThanOrEqualTo(2L), + assertThat(1F).isLessThanOrEqualTo(2F), + assertThat(1F).isLessThanOrEqualTo(2F), + assertThat(1.0).isLessThanOrEqualTo(2.0), + assertThat(1.0).isLessThanOrEqualTo(2.0)); + } + + ImmutableSet> testAssertThatIsGreaterThan() { + return ImmutableSet.of( + assertThat((byte) 1).isGreaterThan((byte) 2), + assertThat((byte) 1).isGreaterThan((byte) 2), + assertThat((char) 1).isGreaterThan((char) 2), + assertThat((char) 1).isGreaterThan((char) 2), + assertThat((short) 1).isGreaterThan((short) 2), + assertThat((short) 1).isGreaterThan((short) 2), + assertThat(1).isGreaterThan(2), + assertThat(1).isGreaterThan(2), + assertThat(1L).isGreaterThan(2L), + assertThat(1L).isGreaterThan(2L), + assertThat(1F).isGreaterThan(2F), + assertThat(1F).isGreaterThan(2F), + assertThat(1.0).isGreaterThan(2.0), + assertThat(1.0).isGreaterThan(2.0)); + } + + ImmutableSet> testAssertThatIsGreaterThanOrEqualTo() { + return ImmutableSet.of( + assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), + assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 2), + assertThat((char) 1).isGreaterThanOrEqualTo((char) 2), + assertThat((char) 1).isGreaterThanOrEqualTo((char) 2), + assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), + assertThat((short) 1).isGreaterThanOrEqualTo((short) 2), + assertThat(1).isGreaterThanOrEqualTo(2), + assertThat(1).isGreaterThanOrEqualTo(2), + assertThat(1L).isGreaterThanOrEqualTo(2L), + assertThat(1L).isGreaterThanOrEqualTo(2L), + assertThat(1F).isGreaterThanOrEqualTo(2F), + assertThat(1F).isGreaterThanOrEqualTo(2F), + assertThat(1.0).isGreaterThanOrEqualTo(2.0), + assertThat(1.0).isGreaterThanOrEqualTo(2.0)); + } +} From 12518ec41eda52974922f63fa7e155a425fdfdea Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sat, 10 Sep 2022 16:26:24 +0200 Subject: [PATCH 16/16] Suggestions --- ...rimitivesTemplates.java => AssertJPrimitiveTemplates.java} | 4 ++-- .../errorprone/refastertemplates/RefasterTemplatesTest.java | 2 +- ...TestInput.java => AssertJPrimitiveTemplatesTestInput.java} | 2 +- ...stOutput.java => AssertJPrimitiveTemplatesTestOutput.java} | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/{AssertJPrimitivesTemplates.java => AssertJPrimitiveTemplates.java} (97%) rename error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/{AssertJPrimitivesTemplatesTestInput.java => AssertJPrimitiveTemplatesTestInput.java} (98%) rename error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/{AssertJPrimitivesTemplatesTestOutput.java => AssertJPrimitiveTemplatesTestOutput.java} (98%) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJPrimitiveTemplates.java similarity index 97% rename from error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplates.java rename to error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJPrimitiveTemplates.java index 202b3e735b..b58a703c71 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJPrimitiveTemplates.java @@ -10,8 +10,8 @@ import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.AbstractDoubleAssert; -final class AssertJPrimitivesTemplates { - private AssertJPrimitivesTemplates() {} +final class AssertJPrimitiveTemplates { + private AssertJPrimitiveTemplates() {} static final class AssertThatIsEqualTo { @BeforeTemplate diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.java index 3880f62747..b739216bcd 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.java @@ -29,7 +29,7 @@ final class RefasterTemplatesTest { AssertJMapTemplates.class, AssertJObjectTemplates.class, AssertJOptionalTemplates.class, - AssertJPrimitivesTemplates.class, + AssertJPrimitiveTemplates.class, AssertJShortTemplates.class, AssertJStringTemplates.class, AssertJThrowingCallableTemplates.class, diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitiveTemplatesTestInput.java similarity index 98% rename from error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestInput.java rename to error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitiveTemplatesTestInput.java index fd07a1d8bd..ace0e0e6c3 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitiveTemplatesTestInput.java @@ -6,7 +6,7 @@ import org.assertj.core.api.AbstractAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; -final class AssertJStringTemplatesTest implements RefasterTemplateTestCase { +final class AssertJPrimitiveTemplatesTest implements RefasterTemplateTestCase { @SuppressWarnings("SimplifyBooleanExpression") ImmutableSet> testAssertThatIsEqualTo() { return ImmutableSet.of( diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitiveTemplatesTestOutput.java similarity index 98% rename from error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestOutput.java rename to error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitiveTemplatesTestOutput.java index b3bfc451ff..7215bbfb8c 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitivesTemplatesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refastertemplates/AssertJPrimitiveTemplatesTestOutput.java @@ -6,7 +6,7 @@ import org.assertj.core.api.AbstractAssert; import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase; -final class AssertJStringTemplatesTest implements RefasterTemplateTestCase { +final class AssertJPrimitiveTemplatesTest implements RefasterTemplateTestCase { @SuppressWarnings("SimplifyBooleanExpression") ImmutableSet> testAssertThatIsEqualTo() { return ImmutableSet.of(