Skip to content

Commit

Permalink
Fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
gianm committed Mar 19, 2024
1 parent ef2e278 commit d7eb681
Showing 1 changed file with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,6 @@ public void setup()
);
}

@Test
public void testControllerCheckerRunnableExitsWhenEmptyStatus()
{
final ServiceLocator controllerLocatorMock = Mockito.mock(ServiceLocator.class);
Mockito.when(controllerLocatorMock.locate())
.thenReturn(Futures.immediateFuture(ServiceLocations.forLocations(Collections.emptySet())));

final Worker workerMock = Mockito.mock(Worker.class);

indexerWorkerContext.controllerCheckerRunnable(controllerLocatorMock, workerMock);
Mockito.verify(controllerLocatorMock, Mockito.times(1)).locate();
Mockito.verify(workerMock, Mockito.times(1)).controllerFailed();
}

@Test
public void testControllerCheckerRunnableExitsOnlyWhenClosedStatus()
{
Expand All @@ -76,12 +62,13 @@ public void testControllerCheckerRunnableExitsOnlyWhenClosedStatus()
.thenReturn(Futures.immediateFuture(ServiceLocations.forLocation(new ServiceLocation("h", 1, -1, "/"))))
// Done to check the behavior of the runnable, the situation of exiting after success might not occur actually
.thenReturn(Futures.immediateFuture(ServiceLocations.forLocation(new ServiceLocation("h", 1, -1, "/"))))
.thenReturn(Futures.immediateFuture(ServiceLocations.forLocations(Collections.emptySet())))
.thenReturn(Futures.immediateFuture(ServiceLocations.closed()));

final Worker workerMock = Mockito.mock(Worker.class);

indexerWorkerContext.controllerCheckerRunnable(controllerLocatorMock, workerMock);
Mockito.verify(controllerLocatorMock, Mockito.times(3)).locate();
Mockito.verify(controllerLocatorMock, Mockito.times(4)).locate();
Mockito.verify(workerMock, Mockito.times(1)).controllerFailed();
}
}

0 comments on commit d7eb681

Please sign in to comment.