@Test public void shouldStartAndStopPullingUpdatesWhenStartAndStopIsCalled() throws Throwable { // GIVEN final UpdatePullerClient puller = new UpdatePullerClient(1, scheduler, logging, updatePuller, availabilityGuard); // WHEN puller.init(); // THEN // Asserts the puller set the job assertNotNull(scheduler.getJob()); puller.start(); updatePuller.unpause(); scheduler.runJob(); verify(lastUpdateTime, times(1)).setLastUpdateTime(anyLong()); verify(availabilityGuard, times(1)).isAvailable(anyLong()); verify(master, times(1)).pullUpdates(Matchers.<RequestContext>any()); updatePuller.stop(); scheduler.runJob(); verifyNoMoreInteractions(lastUpdateTime, availabilityGuard); }
@Test public void shouldNotStartPullingUpdatesUntilStartIsCalled() throws Throwable { // GIVEN final UpdatePullerClient puller = new UpdatePullerClient(1, scheduler, logging, updatePuller, availabilityGuard); // WHEN puller.init(); // THEN // Asserts the puller set the job assertNotNull(scheduler.getJob()); scheduler.runJob(); verifyZeroInteractions(lastUpdateTime, availabilityGuard); }