@Test
public void testContainerRetries() throws Exception {

  DefaultProviderService providerService = new DefaultProviderService();
  AbstractLauncher mockLauncher = mock(AbstractLauncher.class);
  ContainerLaunchService.ComponentLaunchContext componentLaunchContext =
      mock(ContainerLaunchService.ComponentLaunchContext.class);
  ComponentInstance componentInstance = mock(ComponentInstance.class);
  //Never Restart Policy
  Component component = mock(Component.class);
  when(componentInstance.getComponent()).thenReturn(component);
  when(component.getRestartPolicyHandler()).thenReturn(NeverRestartPolicy
      .getInstance());
  providerService.buildContainerRetry(mockLauncher, getConfig(),
      componentLaunchContext, componentInstance);
  verifyZeroInteractions(mockLauncher);
  //OnFailure restart policy
  when(component.getRestartPolicyHandler()).thenReturn(OnFailureRestartPolicy
      .getInstance());
  when(componentLaunchContext.getConfiguration()).thenReturn(new
      Configuration());
  providerService.buildContainerRetry(mockLauncher, getConfig(),
      componentLaunchContext, componentInstance);
  verify(mockLauncher).setRetryContext(DEFAULT_CONTAINER_RETRY_MAX,
      DEFAULT_CONTAINER_RETRY_INTERVAL,
      DEFAULT_CONTAINER_FAILURES_VALIDITY_INTERVAL);
  reset(mockLauncher);
  //Always restart policy
  when(component.getRestartPolicyHandler()).thenReturn(AlwaysRestartPolicy
      .getInstance());
  providerService.buildContainerRetry(mockLauncher, getConfig(),
      componentLaunchContext, componentInstance);
  verify(mockLauncher).setRetryContext(DEFAULT_CONTAINER_RETRY_MAX,
      DEFAULT_CONTAINER_RETRY_INTERVAL,
      DEFAULT_CONTAINER_FAILURES_VALIDITY_INTERVAL);
}