diff --git a/metafacture-flowcontrol/src/test/java/org/metafacture/flowcontrol/ObjectSleeperTest.java b/metafacture-flowcontrol/src/test/java/org/metafacture/flowcontrol/ObjectSleeperTest.java index 1b6aea19..67b133a5 100644 --- a/metafacture-flowcontrol/src/test/java/org/metafacture/flowcontrol/ObjectSleeperTest.java +++ b/metafacture-flowcontrol/src/test/java/org/metafacture/flowcontrol/ObjectSleeperTest.java @@ -14,27 +14,28 @@ * limitations under the License. */ - package org.metafacture.flowcontrol; +package org.metafacture.flowcontrol; - import static org.mockito.ArgumentMatchers.anyString; - import static org.mockito.Mockito.doThrow; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doThrow; - import org.junit.Before; - import org.junit.Test; - import org.metafacture.framework.MetafactureException; - import org.metafacture.framework.ObjectReceiver; - import org.mockito.Mock; - import org.mockito.MockitoAnnotations; - import java.time.Duration; - import java.time.Instant; +import org.junit.Before; +import org.junit.Test; +import org.metafacture.framework.MetafactureException; +import org.metafacture.framework.ObjectReceiver; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import java.time.Duration; +import java.time.Instant; - /** - * Tests for class {@link ObjectSleeper}. - * - * @author Tobias Bülte - * - */ - public final class ObjectExceptionSleeperTest { +/** + * Tests for class {@link ObjectSleeper}. +* +* @author Tobias Bülte +* +*/ +public final class ObjectSleeperTest { @Mock private ObjectReceiver sleepTimer; @@ -44,30 +45,23 @@ public void setup() { MockitoAnnotations.initMocks(this); } - @After - public void cleanup() { - bulk.closeStream(); - } - + @Test + public void shouldTestIfClockedTimeExceedsDuration() { + long sleepTime = 10; - @Test - public void shouldTestIfClockedTimeExceedsDuration() { - long sleepTime = 10; + ObjectSleeper objectSleeper = new ObjectSleeper(); + objectSleeper.setSleepTime(sleepTime); + Instant start = Instant.now(); + sleepTimer.objectSleeper(); + Instant end = Instant.now(); - objectSleeper = new ObjectSleeper(); - objectSleeper.setSleepTime(sleepTime); - Instant start = Instant.now(); - sleepTimer.objectSleeper(); - Instant end = Instant.now(); - Duration timeElapsed = Duration.between(start, end); + Duration timeElapsed = Duration.between(start, end); + Duration sleepTimeDuration = Duration.ofSeconds(sleepTime); - if (timeElampse > sleepTime) { - exception.expect(MetafactureException.class); - exception.expectMessage("Process did not sleep enough."); - } + assertTrue(timeElapsed >= sleepTimeDuration) - } + } - } +}