Skip to content

Commit

Permalink
Refactored spy stubbing. (#4544)
Browse files Browse the repository at this point in the history
Signed-off-by: mark-terry <[email protected]>

Co-authored-by: Sally MacFarlane <[email protected]>
  • Loading branch information
mark-terry and macfarla authored Oct 19, 2022
1 parent 226557a commit 618ad09
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.hyperledger.besu.ethereum.api.jsonrpc.internal.QosTimer;

Expand Down Expand Up @@ -56,7 +56,7 @@ public void shouldNotWarnWhenCalledWithinTimeout(final TestContext ctx) {
final var spyTimer =
spy(new QosTimer(vertx, TEST_QOS_TIMEOUT, z -> spyEngineQosTimer.logTimeoutWarning()));
spyTimer.resetTimer();
when(spyEngineQosTimer.getQosTimer()).thenReturn(spyTimer);
doReturn(spyTimer).when(spyEngineQosTimer).getQosTimer();

// call executionEngineCalled() 50 milliseconds hence to reset our QoS timer
vertx.setTimer(50L, z -> spyEngineQosTimer.executionEngineCalled());
Expand All @@ -83,7 +83,7 @@ public void shouldWarnWhenNotCalledWithinTimeout(final TestContext ctx) {
final var spyTimer =
spy(new QosTimer(vertx, TEST_QOS_TIMEOUT, z -> spyEngineQosTimer.logTimeoutWarning()));
spyTimer.resetTimer();
when(spyEngineQosTimer.getQosTimer()).thenReturn(spyTimer);
doReturn(spyTimer).when(spyEngineQosTimer).getQosTimer();

vertx.setTimer(
100L,
Expand Down

0 comments on commit 618ad09

Please sign in to comment.