Skip to content

Commit 9c603ab

Browse files
committed
Fix EnableRetryWithBackoffTests for possible random as 0 jitter
* Some other code style refactoring for better readability and AssertJ API usage
1 parent 87f02c2 commit 9c603ab

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/test/java/org/springframework/retry/annotation/EnableRetryWithBackoffTests.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void type() {
5252
RandomService service = context.getBean(RandomService.class);
5353
service.service();
5454
List<Long> periods = context.getBean(PeriodSleeper.class).getPeriods();
55-
assertThat(periods.get(0) > 1000).describedAs("Wrong periods: %s" + periods.toString()).isTrue();
55+
assertThat(periods.get(0)).describedAs("Wrong periods: %s" + periods).isGreaterThan(1000);
5656
assertThat(service.getCount()).isEqualTo(3);
5757
context.close();
5858
}
@@ -76,9 +76,7 @@ public void randomExponential() {
7676
List<Long> periods = context.getBean(PeriodSleeper.class).getPeriods();
7777
assertThat(context.getBean(PeriodSleeper.class).getPeriods().toString()).isNotEqualTo("[1000, 1100]");
7878
assertThat(periods.get(0)).describedAs("Wrong periods: %s" + periods).isGreaterThanOrEqualTo(1000);
79-
assertThat(periods.get(1)).describedAs("Wrong periods: %s" + periods)
80-
.isGreaterThanOrEqualTo(1100)
81-
.isLessThanOrEqualTo(1210);
79+
assertThat(periods.get(1)).describedAs("Wrong periods: %s" + periods).isBetween(1100L, 1210L);
8280
context.close();
8381
}
8482

@@ -90,9 +88,8 @@ public void randomExponentialExpression() {
9088
assertThat(service.getCount()).isEqualTo(3);
9189
List<Long> periods = context.getBean(PeriodSleeper.class).getPeriods();
9290
assertThat(context.getBean(PeriodSleeper.class).getPeriods().toString()).isNotEqualTo("[1000, 1100]");
93-
assertThat(periods.get(0) > 1000).describedAs("Wrong periods: %s" + periods.toString()).isTrue();
94-
assertThat(periods.get(1) > 1100 && periods.get(1) < 1210).describedAs("Wrong periods: %s" + periods.toString())
95-
.isTrue();
91+
assertThat(periods.get(0)).describedAs("Wrong periods: %s" + periods).isGreaterThanOrEqualTo(1000);
92+
assertThat(periods.get(1)).describedAs("Wrong periods: %s" + periods).isBetween(1100L, 1210L);
9693
context.close();
9794
}
9895

@@ -102,7 +99,7 @@ public void randomExponentialExpression() {
10299
protected static class TestConfiguration {
103100

104101
@Bean
105-
public PeriodSleeper sleper() {
102+
public PeriodSleeper sleeper() {
106103
return new PeriodSleeper();
107104
}
108105

0 commit comments

Comments
 (0)