Skip to content

Commit

Permalink
Suggestions for AssertJComparableTemplates
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Sep 8, 2022
1 parent c53784f commit 19f3da2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
final class AssertJComparableTemplates {
private AssertJComparableTemplates() {}

static final class AbstractComparableAssertActualIsEqualByComparingToExpected<
T extends Comparable<? super T>> {
static final class AssertThatIsEqualByComparingTo<T extends Comparable<? super T>> {
@BeforeTemplate
AbstractIntegerAssert<?> before(T actual, T expected) {
return assertThat(actual.compareTo(expected)).isEqualTo(0);
Expand All @@ -26,8 +25,7 @@ AbstractIntegerAssert<?> before(T actual, T expected) {
}
}

static final class AbstractComparableAssertActualIsNotEqualByComparingToExpected<
T extends Comparable<? super T>> {
static final class AssertThatIsNotEqualByComparingTo<T extends Comparable<? super T>> {
@BeforeTemplate
AbstractIntegerAssert<?> before(T actual, T expected) {
return assertThat(actual.compareTo(expected)).isNotEqualTo(0);
Expand All @@ -40,8 +38,7 @@ AbstractIntegerAssert<?> before(T actual, T expected) {
}
}

static final class AbstractComparableAssertActualIsLessThanExpected<
T extends Comparable<? super T>> {
static final class AssertThatIsLessThan<T extends Comparable<? super T>> {
@BeforeTemplate
AbstractIntegerAssert<?> before(T actual, T expected) {
return assertThat(actual.compareTo(expected)).isNegative();
Expand All @@ -54,8 +51,7 @@ AbstractIntegerAssert<?> before(T actual, T expected) {
}
}

static final class AbstractComparableAssertActualIsLessThanOrEqualToExpected<
T extends Comparable<? super T>> {
static final class AssertThatIsLessThanOrEqualTo<T extends Comparable<? super T>> {
@BeforeTemplate
AbstractIntegerAssert<?> before(T actual, T expected) {
return assertThat(actual.compareTo(expected)).isNotPositive();
Expand All @@ -68,8 +64,7 @@ AbstractIntegerAssert<?> before(T actual, T expected) {
}
}

static final class AbstractComparableAssertActualIsGreaterThanExpected<
T extends Comparable<? super T>> {
static final class AssertThatIsGreaterThan<T extends Comparable<? super T>> {
@BeforeTemplate
AbstractIntegerAssert<?> before(T actual, T expected) {
return assertThat(actual.compareTo(expected)).isPositive();
Expand All @@ -82,8 +77,7 @@ AbstractIntegerAssert<?> before(T actual, T expected) {
}
}

static final class AbstractComparableAssertActualIsGreaterThanOrEqualToExpected<
T extends Comparable<? super T>> {
static final class AssertThatIsGreaterThanOrEqualTo<T extends Comparable<? super T>> {
@BeforeTemplate
AbstractIntegerAssert<?> before(T actual, T expected) {
return assertThat(actual.compareTo(expected)).isNotNegative();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 19f3da2

Please sign in to comment.