1212*/
1313package io .dapr .durabletask ;
1414
15- import static org .junit .jupiter .api .Assertions .assertEquals ;
16- import static org .junit .jupiter .api .Assertions .assertFalse ;
17- import static org .junit .jupiter .api .Assertions .assertNotEquals ;
18- import static org .junit .jupiter .api .Assertions .assertNotNull ;
19- import static org .junit .jupiter .api .Assertions .assertNull ;
20- import static org .junit .jupiter .api .Assertions .assertThrows ;
21- import static org .junit .jupiter .api .Assertions .assertTrue ;
15+ import org .junit .jupiter .api .Disabled ;
16+ import org .junit .jupiter .api .Tag ;
17+ import org .junit .jupiter .api .Test ;
18+ import org .junit .jupiter .params .ParameterizedTest ;
19+ import org .junit .jupiter .params .provider .ValueSource ;
2220
2321import java .io .IOException ;
2422import java .time .Duration ;
4240import java .util .stream .IntStream ;
4341import java .util .stream .Stream ;
4442
45- import org .junit .jupiter .api .Disabled ;
46- import org .junit .jupiter .api .Tag ;
47- import org .junit .jupiter .api .Test ;
48- import org .junit .jupiter .params .ParameterizedTest ;
49- import org .junit .jupiter .params .provider .ValueSource ;
43+ import static org .junit .jupiter .api .Assertions .assertEquals ;
44+ import static org .junit .jupiter .api .Assertions .assertFalse ;
45+ import static org .junit .jupiter .api .Assertions .assertNotEquals ;
46+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
47+ import static org .junit .jupiter .api .Assertions .assertNull ;
48+ import static org .junit .jupiter .api .Assertions .assertThrows ;
49+ import static org .junit .jupiter .api .Assertions .assertTrue ;
5050
5151/**
5252 * These integration tests are designed to exercise the core, high-level features of
@@ -118,11 +118,11 @@ void singleTimer() throws IOException, TimeoutException {
118118 assertEquals (2 , counter .get ());
119119
120120 // Verify that each timer is the expected length
121- int [] secondsElapsed = new int [1 ];
121+ long [] millisElapsed = new long [1 ];
122122 for (int i = 0 ; i < timestamps .length () - 1 ; i ++) {
123- secondsElapsed [i ] = timestamps .get (i + 1 ). getSecond () - timestamps .get (i ). getSecond ();
123+ millisElapsed [i ] = Duration . between ( timestamps .get (i ), timestamps .get (i + 1 )). toMillis ();
124124 }
125- assertEquals (3 , secondsElapsed [0 ]);
125+ assertEquals (3000 , millisElapsed [0 ], 50 );
126126
127127 }
128128 }
@@ -163,19 +163,17 @@ void loopWithTimer() throws IOException, TimeoutException {
163163 assertEquals (3 , counter .get ());
164164
165165 // Verify that each timer is the expected length
166- int [] secondsElapsed = new int [timestamps .length ()];
166+ long [] millisElapsed = new long [timestamps .length ()];
167167 for (int i = 0 ; i < timestamps .length () - 1 ; i ++) {
168168 if (timestamps .get (i + 1 ) != null && timestamps .get (i ) != null ) {
169- secondsElapsed [i ] = timestamps .get (i + 1 ). getSecond () - timestamps .get (i ). getSecond ();
169+ millisElapsed [i ] = Duration . between ( timestamps .get (i ), timestamps .get (i + 1 )). toMillis ();
170170 } else {
171- secondsElapsed [i ] = -1 ;
171+ millisElapsed [i ] = -1 ;
172172 }
173173 }
174- assertEquals (2 , secondsElapsed [0 ]);
175- assertEquals (2 , secondsElapsed [1 ]);
176- assertEquals (-1 , secondsElapsed [2 ]);
177-
178-
174+ assertEquals (2000 , millisElapsed [0 ], 50 );
175+ assertEquals (2000 , millisElapsed [1 ], 50 );
176+ assertEquals (-1 , millisElapsed [2 ]);
179177 }
180178 }
181179
@@ -195,7 +193,6 @@ void loopWithWaitForEvent() throws IOException, TimeoutException {
195193 timestamps .set (counter .get (), LocalDateTime .now ());
196194 counter .incrementAndGet ();
197195 }
198-
199196 }
200197 }
201198 })
@@ -218,18 +215,20 @@ void loopWithWaitForEvent() throws IOException, TimeoutException {
218215 assertEquals (4 , counter .get ());
219216
220217 // Verify that each timer is the expected length
221- int [] secondsElapsed = new int [timestamps .length ()];
218+ long [] millisElapsed = new long [timestamps .length ()];
222219 for (int i = 0 ; i < timestamps .length () - 1 ; i ++) {
223220 if (timestamps .get (i + 1 ) != null && timestamps .get (i ) != null ) {
224- secondsElapsed [i ] = timestamps .get (i + 1 ).getSecond () - timestamps .get (i ).getSecond ();
221+ millisElapsed [i ] =
222+ java .time .Duration .between (timestamps .get (i ), timestamps .get (i + 1 )).toMillis ();
225223 } else {
226- secondsElapsed [i ] = -1 ;
224+ millisElapsed [i ] = -1 ;
227225 }
228226 }
229- assertEquals (2 , secondsElapsed [0 ]);
230- assertEquals (2 , secondsElapsed [1 ]);
231- assertEquals (2 , secondsElapsed [2 ]);
232- assertEquals (0 , secondsElapsed [3 ]);
227+
228+ assertEquals (2000 , millisElapsed [0 ], 50 );
229+ assertEquals (2000 , millisElapsed [1 ], 50 );
230+ assertEquals (2000 , millisElapsed [2 ], 50 );
231+ assertEquals (0 , millisElapsed [3 ]);
233232
234233
235234 }
@@ -269,13 +268,13 @@ void longTimer() throws TimeoutException {
269268 assertEquals (4 , counter .get ());
270269
271270 // Verify that each timer is the expected length
272- int [] secondsElapsed = new int [3 ];
271+ long [] millisElapsed = new long [3 ];
273272 for (int i = 0 ; i < timestamps .length () - 1 ; i ++) {
274- secondsElapsed [i ] = timestamps .get (i + 1 ). getSecond () - timestamps .get (i ). getSecond ();
273+ millisElapsed [i ] = Duration . between ( timestamps .get (i ), timestamps .get (i + 1 )). toMillis ();
275274 }
276- assertEquals (secondsElapsed [0 ], 3 );
277- assertEquals (secondsElapsed [1 ], 3 );
278- assertEquals (secondsElapsed [2 ], 1 );
275+ assertEquals (3000 , millisElapsed [0 ], 50 );
276+ assertEquals (3000 , millisElapsed [1 ], 50 );
277+ assertEquals (1000 , millisElapsed [2 ], 50 );
279278 }
280279 }
281280
0 commit comments