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 5dc35f3f..ba3ae098 100644 --- a/metafacture-flowcontrol/src/test/java/org/metafacture/flowcontrol/ObjectSleeperTest.java +++ b/metafacture-flowcontrol/src/test/java/org/metafacture/flowcontrol/ObjectSleeperTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Christoph Böhme + * Copyright 2024 Tobias Bülte, hbz * * Licensed under the Apache License, Version 2.0 the "License"; * you may not use this file except in compliance with the License. @@ -17,15 +17,14 @@ package org.metafacture.flowcontrol; import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.doThrow; + +import org.metafacture.framework.ObjectReceiver; 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; @@ -38,7 +37,7 @@ public final class ObjectSleeperTest { @Mock - private ObjectReceiver sleepTimer; + private ObjectReceiver receiver; @Before public void setup() { @@ -47,18 +46,18 @@ public void setup() { @Test public void shouldTestIfClockedTimeExceedsDuration() { - long sleepTime = 10; + long sleepTime = 100; - ObjectSleeper objectSleeper = new ObjectSleeper(); + ObjectSleeper objectSleeper = new ObjectSleeper<>(); + objectSleeper.setReceiver(receiver); objectSleeper.setSleepTime(sleepTime); Instant start = Instant.now(); - sleepTimer.objectSleeper; + objectSleeper.process(null); Instant end = Instant.now(); - Duration timeElapsed = Duration.between(start, end); - assertTrue(timeElapsed.toSeconds() >= sleepTime); + assertTrue(timeElapsed.toMillis() >= sleepTime); }