Skip to content

Commit

Permalink
Incorporate some suggestions by @fsteeg
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasNx committed Nov 25, 2024
1 parent 4f11c69 commit 9f9b8d7
Showing 1 changed file with 32 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> sleepTimer;
Expand All @@ -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)

}
}


}
}

0 comments on commit 9f9b8d7

Please sign in to comment.