OrchestratorImpl implements Orchestrator { @Override public void resume(final String hostName) { UpdateHostResponse response; try { String path = getSuspendPath(hostName); response = configServerApi.delete(path, UpdateHostResponse.class); } catch (HttpException.NotFoundException n) { throw new OrchestratorNotFoundException("Failed to resume " + hostName + ", host not found"); } catch (HttpException e) { throw new OrchestratorException("Failed to resume " + hostName + ": " + e.toString()); } catch (ConnectionException e) { throw new ConvergenceException("Failed to resume " + hostName + ": " + e.getMessage()); } catch (RuntimeException e) { throw new RuntimeException("Got error on resume", e); } Optional.ofNullable(response.reason()).ifPresent(reason -> { throw new OrchestratorException(reason.message()); }); } OrchestratorImpl(ConfigServerApi configServerApi); @Override void suspend(final String hostName); @Override void suspend(String parentHostName, List<String> hostNames); @Override void resume(final String hostName);  }
@Test public void testResumeCall() { when(configServerApi.delete( OrchestratorImpl.ORCHESTRATOR_PATH_PREFIX_HOST_API + "/" + hostName+ "/suspended", UpdateHostResponse.class )).thenReturn(new UpdateHostResponse(hostName, null)); orchestrator.resume(hostName); }
@Test(expected=OrchestratorException.class) public void testResumeCallWithFailureReason() { when(configServerApi.delete( OrchestratorImpl.ORCHESTRATOR_PATH_PREFIX_HOST_API + "/" + hostName+ "/suspended", UpdateHostResponse.class )).thenReturn(new UpdateHostResponse(hostName, new HostStateChangeDenialReason("hostname", "fail"))); orchestrator.resume(hostName); }
@Test(expected=OrchestratorNotFoundException.class) public void testResumeCallWithNotFound() { when(configServerApi.delete( any(String.class), any() )).thenThrow(new HttpException.NotFoundException("Not Found")); orchestrator.resume(hostName); }