Skip to content

Commit

Permalink
Added one template.
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolTomatos committed Sep 6, 2022
1 parent 23a34ad commit 2346fee
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
final class AssertJComparableTemplates {
private AssertJComparableTemplates() {}

static final class AbstractComparableAssertActualIsEqualByComparingToExpected<
T extends Comparable<? super T>> {
@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 AbstractComparableAssertActualIsLessThanExpected<
T extends Comparable<? super T>> {
@BeforeTemplate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase;

final class AssertJComparableTemplatesTest implements RefasterTemplateTestCase {
AbstractAssert<?, ?> testAbstractComparableAssertActualIsEqualByComparingToExpected() {
return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isEqualTo(0);
}

AbstractAssert<?, ?> testAbstractComparableAssertActualIsLessThanExpected() {
return assertThat(BigDecimal.ZERO.compareTo(BigDecimal.ONE)).isNegative();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase;

final class AssertJComparableTemplatesTest implements RefasterTemplateTestCase {
AbstractAssert<?, ?> testAbstractComparableAssertActualIsEqualByComparingToExpected() {
return assertThat(BigDecimal.ZERO).isEqualByComparingTo(BigDecimal.ONE);
}

AbstractAssert<?, ?> testAbstractComparableAssertActualIsLessThanExpected() {
return assertThat(BigDecimal.ZERO).isLessThan(BigDecimal.ONE);
}
Expand Down

0 comments on commit 2346fee

Please sign in to comment.