Skip to content

Commit

Permalink
Fix EnableRetryWithBackoffTests for possible random as 0 jitter
Browse files Browse the repository at this point in the history
* Some other code style refactoring for better readability and AssertJ API usage
  • Loading branch information
artembilan committed Dec 13, 2024
1 parent 87f02c2 commit 9c603ab
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void type() {
RandomService service = context.getBean(RandomService.class);
service.service();
List<Long> periods = context.getBean(PeriodSleeper.class).getPeriods();
assertThat(periods.get(0) > 1000).describedAs("Wrong periods: %s" + periods.toString()).isTrue();
assertThat(periods.get(0)).describedAs("Wrong periods: %s" + periods).isGreaterThan(1000);
assertThat(service.getCount()).isEqualTo(3);
context.close();
}
Expand All @@ -76,9 +76,7 @@ public void randomExponential() {
List<Long> periods = context.getBean(PeriodSleeper.class).getPeriods();
assertThat(context.getBean(PeriodSleeper.class).getPeriods().toString()).isNotEqualTo("[1000, 1100]");
assertThat(periods.get(0)).describedAs("Wrong periods: %s" + periods).isGreaterThanOrEqualTo(1000);
assertThat(periods.get(1)).describedAs("Wrong periods: %s" + periods)
.isGreaterThanOrEqualTo(1100)
.isLessThanOrEqualTo(1210);
assertThat(periods.get(1)).describedAs("Wrong periods: %s" + periods).isBetween(1100L, 1210L);
context.close();
}

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

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

@Bean
public PeriodSleeper sleper() {
public PeriodSleeper sleeper() {
return new PeriodSleeper();
}

Expand Down

0 comments on commit 9c603ab

Please sign in to comment.