14
14
* limitations under the License.
15
15
*/
16
16
17
- package org .metafacture .flowcontrol ;
17
+ package org .metafacture .flowcontrol ;
18
18
19
- import static org .mockito .ArgumentMatchers .anyString ;
20
- import static org .mockito .Mockito .doThrow ;
19
+ import static org .junit .Assert .assertTrue ;
20
+ import static org .mockito .ArgumentMatchers .anyString ;
21
+ import static org .mockito .Mockito .doThrow ;
21
22
22
- import org .junit .Before ;
23
- import org .junit .Test ;
24
- import org .metafacture .framework .MetafactureException ;
25
- import org .metafacture .framework .ObjectReceiver ;
26
- import org .mockito .Mock ;
27
- import org .mockito .MockitoAnnotations ;
28
- import java .time .Duration ;
29
- import java .time .Instant ;
23
+ import org .junit .Before ;
24
+ import org .junit .Test ;
25
+ import org .metafacture .framework .MetafactureException ;
26
+ import org .metafacture .framework .ObjectReceiver ;
27
+ import org .mockito .Mock ;
28
+ import org .mockito .MockitoAnnotations ;
29
+ import java .time .Duration ;
30
+ import java .time .Instant ;
30
31
31
- /**
32
- * Tests for class {@link ObjectSleeper}.
33
- *
34
- * @author Tobias Bülte
35
- *
36
- */
37
- public final class ObjectExceptionSleeperTest {
32
+ /**
33
+ * Tests for class {@link ObjectSleeper}.
34
+ *
35
+ * @author Tobias Bülte
36
+ *
37
+ */
38
+ public final class ObjectSleeperTest {
38
39
39
40
@ Mock
40
41
private ObjectReceiver <String > sleepTimer ;
@@ -44,30 +45,22 @@ public void setup() {
44
45
MockitoAnnotations .initMocks (this );
45
46
}
46
47
47
- @ After
48
- public void cleanup () {
49
- bulk .closeStream ();
50
- }
51
-
48
+ @ Test
49
+ public void shouldTestIfClockedTimeExceedsDuration () {
50
+ long sleepTime = 10 ;
52
51
53
- @ Test
54
- public void shouldTestIfClockedTimeExceedsDuration () {
55
- long sleepTime = 10 ;
52
+ ObjectSleeper objectSleeper = new ObjectSleeper ();
53
+ objectSleeper .setSleepTime (sleepTime );
54
+ Instant start = Instant .now ();
55
+ sleepTimer .objectSleeper ;
56
+ Instant end = Instant .now ();
56
57
57
- objectSleeper = new ObjectSleeper ();
58
- objectSleeper .setSleepTime (sleepTime );
59
- Instant start = Instant .now ();
60
- sleepTimer .objectSleeper ();
61
- Instant end = Instant .now ();
62
58
63
- Duration timeElapsed = Duration .between (start , end );
59
+ Duration timeElapsed = Duration .between (start , end );
64
60
65
- if (timeElampse > sleepTime ) {
66
- exception .expect (MetafactureException .class );
67
- exception .expectMessage ("Process did not sleep enough." );
68
- }
61
+ assertTrue (timeElapsed .toSeconds () >= sleepTime );
69
62
70
- }
63
+ }
71
64
72
65
73
- }
66
+ }
0 commit comments