@@ -87,29 +87,6 @@ void withMaxAttempts() {
8787 assertThat (backOff .getInterval ()).isEqualTo (1000 );
8888 });
8989 }
90-
91- @ Test
92- void withMaxElapsedTimePreconditions () {
93- assertThatIllegalArgumentException ()
94- .isThrownBy (() -> RetryPolicy .withMaxElapsedTime (Duration .ofMillis (0 )))
95- .withMessage ("Invalid duration (0ms): maxElapsedTime must be positive." );
96- assertThatIllegalArgumentException ()
97- .isThrownBy (() -> RetryPolicy .withMaxElapsedTime (Duration .ofMillis (-1 )))
98- .withMessage ("Invalid duration (-1ms): maxElapsedTime must be positive." );
99- }
100-
101- @ Test
102- void withMaxElapsedTime () {
103- var policy = RetryPolicy .withMaxElapsedTime (Duration .ofMillis (42 ));
104-
105- assertThat (policy .shouldRetry (new AssertionError ())).isTrue ();
106- assertThat (policy .shouldRetry (new IOException ())).isTrue ();
107-
108- assertThat (policy .getBackOff ())
109- .asInstanceOf (type (ExponentialBackOff .class ))
110- .satisfies (hasDefaultMaxAttemptsAndDelay ())
111- .extracting (ExponentialBackOff ::getMaxElapsedTime ).isEqualTo (42L );
112- }
11390 }
11491
11592
@@ -122,7 +99,7 @@ void backOffPlusConflictingConfig() {
12299 .isThrownBy (() -> RetryPolicy .builder ().backOff (mock ()).delay (Duration .ofMillis (10 )).build ())
123100 .withMessage ("""
124101 The following configuration options are not supported with a custom BackOff strategy: \
125- maxAttempts, delay, jitter, multiplier, maxDelay, or maxElapsedTime .""" );
102+ maxAttempts, delay, jitter, multiplier, or maxDelay .""" );
126103 }
127104
128105 @ Test
@@ -157,7 +134,7 @@ void maxAttempts() {
157134 assertThat (backOff .getInitialInterval ()).isEqualTo (1000 );
158135 });
159136
160- assertToString (policy , 1000 , 0 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 5 );
137+ assertToString (policy , 1000 , 0 , 1.0 , Long .MAX_VALUE , 5 );
161138 }
162139
163140 @ Test
@@ -178,7 +155,7 @@ void delay() {
178155 assertThat (backOff .getMaxAttempts ()).isEqualTo (3 );
179156 });
180157
181- assertToString (policy , 42 , 0 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 3 );
158+ assertToString (policy , 42 , 0 , 1.0 , Long .MAX_VALUE , 3 );
182159 }
183160
184161 @ Test
@@ -197,7 +174,7 @@ void jitter() {
197174 .satisfies (hasDefaultMaxAttemptsAndDelay ())
198175 .extracting (ExponentialBackOff ::getJitter ).isEqualTo (42L );
199176
200- assertToString (policy , 1000 , 42 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 3 );
177+ assertToString (policy , 1000 , 42 , 1.0 , Long .MAX_VALUE , 3 );
201178 }
202179
203180 @ Test
@@ -226,7 +203,7 @@ void multiplier() {
226203 .satisfies (hasDefaultMaxAttemptsAndDelay ())
227204 .extracting (ExponentialBackOff ::getMultiplier ).isEqualTo (1.5 );
228205
229- assertToString (policy , 1000 , 0 , 1.5 , Long .MAX_VALUE , Long . MAX_VALUE , 3 );
206+ assertToString (policy , 1000 , 0 , 1.5 , Long .MAX_VALUE , 3 );
230207 }
231208
232209 @ Test
@@ -248,29 +225,7 @@ void maxDelay() {
248225 .satisfies (hasDefaultMaxAttemptsAndDelay ())
249226 .extracting (ExponentialBackOff ::getMaxInterval ).isEqualTo (42L );
250227
251- assertToString (policy , 1000 , 0 , 1 , 42 , Long .MAX_VALUE , 3 );
252- }
253-
254- @ Test
255- void maxElapsedTimePreconditions () {
256- assertThatIllegalArgumentException ()
257- .isThrownBy (() -> RetryPolicy .builder ().maxElapsedTime (Duration .ofMillis (0 )))
258- .withMessage ("Invalid duration (0ms): maxElapsedTime must be positive." );
259- assertThatIllegalArgumentException ()
260- .isThrownBy (() -> RetryPolicy .builder ().maxElapsedTime (Duration .ofMillis (-1 )))
261- .withMessage ("Invalid duration (-1ms): maxElapsedTime must be positive." );
262- }
263-
264- @ Test
265- void maxElapsedTime () {
266- var policy = RetryPolicy .builder ().maxElapsedTime (Duration .ofMillis (42 )).build ();
267-
268- assertThat (policy .getBackOff ())
269- .asInstanceOf (type (ExponentialBackOff .class ))
270- .satisfies (hasDefaultMaxAttemptsAndDelay ())
271- .extracting (ExponentialBackOff ::getMaxElapsedTime ).isEqualTo (42L );
272-
273- assertToString (policy , 1000 , 0 , 1 , Long .MAX_VALUE , 42 , 3 );
228+ assertToString (policy , 1000 , 0 , 1.0 , 42 , 3 );
274229 }
275230
276231 @ Test
@@ -294,7 +249,7 @@ void includes() {
294249
295250 String filters = "includes=" + names (FileNotFoundException .class , IllegalArgumentException .class ,
296251 NumberFormatException .class , AssertionError .class ) + ", " ;
297- assertToString (policy , filters , 1000 , 0 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 3 );
252+ assertToString (policy , filters , 1000 , 0 , 1.0 , Long .MAX_VALUE , 3 );
298253 }
299254
300255 @ Test
@@ -311,7 +266,7 @@ void includesSubtypeMatching() {
311266 .asInstanceOf (type (ExponentialBackOff .class ))
312267 .satisfies (hasDefaultMaxAttemptsAndDelay ());
313268
314- assertToString (policy , "includes=[java.io.IOException], " , 1000 , 0 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 3 );
269+ assertToString (policy , "includes=[java.io.IOException], " , 1000 , 0 , 1.0 , Long .MAX_VALUE , 3 );
315270 }
316271
317272 @ Test
@@ -335,7 +290,7 @@ void excludes() {
335290
336291 String filters = "excludes=" + names (FileNotFoundException .class , IllegalArgumentException .class ,
337292 NumberFormatException .class , AssertionError .class ) + ", " ;
338- assertToString (policy , filters , 1000 , 0 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 3 );
293+ assertToString (policy , filters , 1000 , 0 , 1.0 , Long .MAX_VALUE , 3 );
339294 }
340295
341296 @ Test
@@ -349,7 +304,7 @@ void excludesSubtypeMatching() {
349304 assertThat (policy .shouldRetry (new Throwable ())).isTrue ();
350305 assertThat (policy .shouldRetry (new AssertionError ())).isTrue ();
351306
352- assertToString (policy , "excludes=[java.io.IOException], " , 1000 , 0 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 3 );
307+ assertToString (policy , "excludes=[java.io.IOException], " , 1000 , 0 , 1.0 , Long .MAX_VALUE , 3 );
353308 }
354309
355310 @ Test
@@ -368,8 +323,7 @@ void predicate() {
368323 .asInstanceOf (type (ExponentialBackOff .class ))
369324 .satisfies (hasDefaultMaxAttemptsAndDelay ());
370325
371- assertToString (policy , "predicate=NumberFormatExceptionMatcher, " ,
372- 1000 , 0 , 1 , Long .MAX_VALUE , Long .MAX_VALUE , 3 );
326+ assertToString (policy , "predicate=NumberFormatExceptionMatcher, " , 1000 , 0 , 1.0 , Long .MAX_VALUE , 3 );
373327 }
374328
375329 @ Test
@@ -398,13 +352,13 @@ void predicatesCombined() {
398352
399353
400354 private static void assertToString (RetryPolicy policy , long initialInterval , long jitter ,
401- double multiplier , long maxInterval , long maxElapsedTime , int maxAttempts ) {
355+ double multiplier , long maxInterval , int maxAttempts ) {
402356
403- assertToString (policy , "" , initialInterval , jitter , multiplier , maxInterval , maxElapsedTime , maxAttempts );
357+ assertToString (policy , "" , initialInterval , jitter , multiplier , maxInterval , maxAttempts );
404358 }
405359
406360 private static void assertToString (RetryPolicy policy , String filters , long initialInterval , long jitter ,
407- double multiplier , long maxInterval , long maxElapsedTime , int maxAttempts ) {
361+ double multiplier , long maxInterval , int maxAttempts ) {
408362
409363 assertThat (policy ).asString ()
410364 .isEqualTo ("""
@@ -416,7 +370,7 @@ private static void assertToString(RetryPolicy policy, String filters, long init
416370 maxElapsedTime=%d, \
417371 maxAttempts=%d\
418372 ]]""" ,
419- filters , initialInterval , jitter , multiplier , maxInterval , maxElapsedTime , maxAttempts );
373+ filters , initialInterval , jitter , multiplier , maxInterval , Long . MAX_VALUE , maxAttempts );
420374 }
421375
422376 @ SafeVarargs
0 commit comments