Skip to content

Commit

Permalink
Tweak test to fix compiler error and warnings, wait 100 ms (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Nov 27, 2024
1 parent b86dce3 commit 03bc009
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;

Expand All @@ -38,7 +37,7 @@
public final class ObjectSleeperTest {

@Mock
private ObjectReceiver<String> sleepTimer;
private ObjectReceiver<String> receiver;

@Before
public void setup() {
Expand All @@ -47,18 +46,18 @@ public void setup() {

@Test
public void shouldTestIfClockedTimeExceedsDuration() {
long sleepTime = 10;
long sleepTime = 100;

ObjectSleeper objectSleeper = new ObjectSleeper();
ObjectSleeper<String> 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);

}

Expand Down

0 comments on commit 03bc009

Please sign in to comment.