@Test public void testFailureFromListener() throws Exception { LimitedRetryRestartStrategy strategy = new LimitedRetryRestartStrategy(3, 20, 40, spaceEnvironment); strategy.addRestartStrategyListener(restartListener); Mockito.when(restartable.isRestarted()).thenReturn(false); Mockito.when(restartListener.onRestartAttempt(strategy, restartable, true)).thenReturn(false); Mockito.when(timeProvider.getCurrentTime()).thenReturn(0l, 100l); RestartStrategyInstance instance = strategy.newInstance(restartable); Thread.sleep(1000); Mockito.verify(restartable, Mockito.times(0)).attemptRestart(); Mockito.verify(restartable, Mockito.times(1)).restartComplete(false); Mockito.verify(restartListener, Mockito.times(1)).onRestartFailure(strategy, restartable); Mockito.verify(restartListener, Mockito.times(1)).onRestartAttempt(strategy, restartable, true); Mockito.verify(restartListener, Mockito.times(0)).onRestartSuccess(strategy, restartable); }
@Override public RestartStrategyInstance<T> newInstance(T restartable) { LimitedRetryRestartStrategyInstance<T> instance = new LimitedRetryRestartStrategyInstance<T>(restartable, this, numberRetries, sampleDelay, timeDurationSuccessfulRestart, spaceEnvironment.getTimeProvider(), spaceEnvironment.getExecutorService()); instance.startRestartAttempts(); return instance; }
LimitedRetryRestartStrategy extends BaseRestartStrategy<T> { @Override public RestartStrategyInstance<T> newInstance(T restartable) { LimitedRetryRestartStrategyInstance<T> instance = new LimitedRetryRestartStrategyInstance<T>(restartable, this, numberRetries, sampleDelay, timeDurationSuccessfulRestart, spaceEnvironment.getTimeProvider(), spaceEnvironment.getExecutorService()); instance.startRestartAttempts(); return instance; } }
LimitedRetryRestartStrategy extends BaseRestartStrategy<T> { @Override public RestartStrategyInstance<T> newInstance(T restartable) { LimitedRetryRestartStrategyInstance<T> instance = new LimitedRetryRestartStrategyInstance<T>(restartable, this, numberRetries, sampleDelay, timeDurationSuccessfulRestart, spaceEnvironment.getTimeProvider(), spaceEnvironment.getExecutorService()); instance.startRestartAttempts(); return instance; } LimitedRetryRestartStrategy(int numberRetries, long sampleDelay, long timeDurationSuccessfulRestart,
      InteractiveSpacesEnvironment spaceEnvironment); }
LimitedRetryRestartStrategy extends BaseRestartStrategy<T> { @Override public RestartStrategyInstance<T> newInstance(T restartable) { LimitedRetryRestartStrategyInstance<T> instance = new LimitedRetryRestartStrategyInstance<T>(restartable, this, numberRetries, sampleDelay, timeDurationSuccessfulRestart, spaceEnvironment.getTimeProvider(), spaceEnvironment.getExecutorService()); instance.startRestartAttempts(); return instance; } LimitedRetryRestartStrategy(int numberRetries, long sampleDelay, long timeDurationSuccessfulRestart,
      InteractiveSpacesEnvironment spaceEnvironment); @Override RestartStrategyInstance<T> newInstance(T restartable); }
LimitedRetryRestartStrategy extends BaseRestartStrategy<T> { @Override public RestartStrategyInstance<T> newInstance(T restartable) { LimitedRetryRestartStrategyInstance<T> instance = new LimitedRetryRestartStrategyInstance<T>(restartable, this, numberRetries, sampleDelay, timeDurationSuccessfulRestart, spaceEnvironment.getTimeProvider(), spaceEnvironment.getExecutorService()); instance.startRestartAttempts(); return instance; } LimitedRetryRestartStrategy(int numberRetries, long sampleDelay, long timeDurationSuccessfulRestart,
      InteractiveSpacesEnvironment spaceEnvironment); @Override RestartStrategyInstance<T> newInstance(T restartable);  }