File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
main/java/javaslang/retry
test/java/javaslang/retry Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -93,8 +93,8 @@ public Builder maxAttempts(int maxAttempts) {
93
93
}
94
94
95
95
public Builder waitDuration (Duration waitDuration ) {
96
- if (waitDuration .getSeconds () < 0.01 ) {
97
- throw new IllegalArgumentException ("waitDurationInOpenState must be at least than 10[ms] " );
96
+ if (waitDuration .toMillis () < 10 ) {
97
+ throw new IllegalArgumentException ("waitDurationInOpenState must be at least 10ms " );
98
98
}
99
99
this .waitDuration = waitDuration ;
100
100
return this ;
Original file line number Diff line number Diff line change 22
22
23
23
import java .time .Duration ;
24
24
25
+ import static org .assertj .core .api .Assertions .assertThat ;
26
+
25
27
public class RetryBuilderTest {
26
28
27
29
@ Test (expected = IllegalArgumentException .class )
@@ -33,4 +35,21 @@ public void zeroMaxAttemptsShouldFail() {
33
35
public void zeroWaitIntervalShouldFail () {
34
36
Retry .custom ().waitDuration (Duration .ofMillis (0 )).build ();
35
37
}
38
+
39
+ @ Test (expected = IllegalArgumentException .class )
40
+ public void WaitIntervalUnderTenMillisShouldFail () {
41
+ Retry .custom ().waitDuration (Duration .ofMillis (5 )).build ();
42
+ }
43
+
44
+ @ Test
45
+ public void waitIntervalOfTenMillisShouldSucceed () {
46
+ Retry retryCtx = Retry .custom ().waitDuration (Duration .ofMillis (10 )).build ();
47
+ assertThat (retryCtx ).isNotNull ();
48
+ }
49
+
50
+ @ Test
51
+ public void waitIntervalOverTenMillisShouldSucceed () {
52
+ Retry retryCtx = Retry .custom ().waitDuration (Duration .ofSeconds (10 )).build ();
53
+ assertThat (retryCtx ).isNotNull ();
54
+ }
36
55
}
You can’t perform that action at this time.
0 commit comments