From 9c603ab3383858e5fdf27aff203448a0c3518aba Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Fri, 13 Dec 2024 11:09:47 -0500 Subject: [PATCH] Fix `EnableRetryWithBackoffTests` for possible random as `0` jitter * Some other code style refactoring for better readability and AssertJ API usage --- .../annotation/EnableRetryWithBackoffTests.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/springframework/retry/annotation/EnableRetryWithBackoffTests.java b/src/test/java/org/springframework/retry/annotation/EnableRetryWithBackoffTests.java index 25b2669a..9f15adea 100644 --- a/src/test/java/org/springframework/retry/annotation/EnableRetryWithBackoffTests.java +++ b/src/test/java/org/springframework/retry/annotation/EnableRetryWithBackoffTests.java @@ -52,7 +52,7 @@ public void type() { RandomService service = context.getBean(RandomService.class); service.service(); List 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(); } @@ -76,9 +76,7 @@ public void randomExponential() { List 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(); } @@ -90,9 +88,8 @@ public void randomExponentialExpression() { assertThat(service.getCount()).isEqualTo(3); List 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(); } @@ -102,7 +99,7 @@ public void randomExponentialExpression() { protected static class TestConfiguration { @Bean - public PeriodSleeper sleper() { + public PeriodSleeper sleeper() { return new PeriodSleeper(); }