1414 * limitations under the License.
1515 */
1616
17- package org .metafacture .flowcontrol ;
17+ package org .metafacture .flowcontrol ;
1818
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 ;
2122
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 ;
3031
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 {
3839
3940 @ Mock
4041 private ObjectReceiver <String > sleepTimer ;
@@ -44,30 +45,23 @@ public void setup() {
4445 MockitoAnnotations .initMocks (this );
4546 }
4647
47- @ After
48- public void cleanup () {
49- bulk .closeStream ();
50- }
51-
48+ @ Test
49+ public void shouldTestIfClockedTimeExceedsDuration () {
50+ long sleepTime = 10 ;
5251
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 ();
5657
57- objectSleeper = new ObjectSleeper ();
58- objectSleeper .setSleepTime (sleepTime );
59- Instant start = Instant .now ();
60- sleepTimer .objectSleeper ();
61- Instant end = Instant .now ();
6258
63- Duration timeElapsed = Duration .between (start , end );
59+ Duration timeElapsed = Duration .between (start , end );
60+ Duration sleepTimeDuration = Duration .ofSeconds (sleepTime );
6461
65- if (timeElampse > sleepTime ) {
66- exception .expect (MetafactureException .class );
67- exception .expectMessage ("Process did not sleep enough." );
68- }
62+ assertTrue (timeElapsed >= sleepTimeDuration )
6963
70- }
64+ }
7165
7266
73- }
67+ }
0 commit comments