File tree Expand file tree Collapse file tree 3 files changed +14
-9
lines changed
main/java/tech/picnic/errorprone/refasterrules
test/resources/tech/picnic/errorprone/refasterrules Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -112,11 +112,14 @@ AbstractDurationAssert<?> after(Duration duration) {
112112 }
113113 }
114114
115- // XXX: Once we build against JDK 18+, update this rule to also rewrite
116- // `assertThat(duration.isPositive()).isTrue()`
117115 static final class AssertThatIsPositive {
118116 @ BeforeTemplate
119- AbstractDurationAssert <?> before (Duration duration ) {
117+ AbstractBooleanAssert <?> before (Duration duration ) {
118+ return assertThat (duration .isPositive ()).isTrue ();
119+ }
120+
121+ @ BeforeTemplate
122+ AbstractDurationAssert <?> before2 (Duration duration ) {
120123 return assertThat (duration ).isGreaterThan (Duration .ZERO );
121124 }
122125
Original file line number Diff line number Diff line change 55import com .google .common .collect .ImmutableSet ;
66import java .time .Duration ;
77import org .assertj .core .api .AbstractAssert ;
8- import org .assertj .core .api .AbstractDurationAssert ;
98import tech .picnic .errorprone .refaster .test .RefasterRuleCollectionTestCase ;
109
1110final class AssertJDurationRulesTest implements RefasterRuleCollectionTestCase {
@@ -39,8 +38,10 @@ final class AssertJDurationRulesTest implements RefasterRuleCollectionTestCase {
3938 assertThat (Duration .ofMillis (1 )).isEqualTo (Duration .ZERO ));
4039 }
4140
42- AbstractDurationAssert <?> testAssertThatIsPositive () {
43- return assertThat (Duration .ofMillis (0 )).isGreaterThan (Duration .ZERO );
41+ ImmutableSet <AbstractAssert <?, ?>> testAssertThatIsPositive () {
42+ return ImmutableSet .of (
43+ assertThat (Duration .ofMillis (0 ).isPositive ()).isTrue (),
44+ assertThat (Duration .ofMillis (1 )).isGreaterThan (Duration .ZERO ));
4445 }
4546
4647 ImmutableSet <AbstractAssert <?, ?>> testAssertThatIsNegative () {
Original file line number Diff line number Diff line change 55import com .google .common .collect .ImmutableSet ;
66import java .time .Duration ;
77import org .assertj .core .api .AbstractAssert ;
8- import org .assertj .core .api .AbstractDurationAssert ;
98import tech .picnic .errorprone .refaster .test .RefasterRuleCollectionTestCase ;
109
1110final class AssertJDurationRulesTest implements RefasterRuleCollectionTestCase {
@@ -38,8 +37,10 @@ final class AssertJDurationRulesTest implements RefasterRuleCollectionTestCase {
3837 assertThat (Duration .ofMillis (0 )).isZero (), assertThat (Duration .ofMillis (1 )).isZero ());
3938 }
4039
41- AbstractDurationAssert <?> testAssertThatIsPositive () {
42- return assertThat (Duration .ofMillis (0 )).isPositive ();
40+ ImmutableSet <AbstractAssert <?, ?>> testAssertThatIsPositive () {
41+ return ImmutableSet .of (
42+ assertThat (Duration .ofMillis (0 )).isPositive (),
43+ assertThat (Duration .ofMillis (1 )).isPositive ());
4344 }
4445
4546 ImmutableSet <AbstractAssert <?, ?>> testAssertThatIsNegative () {
You can’t perform that action at this time.
0 commit comments