@Test(expected=RuntimeException.class) public void testResumeCallWithSomeOtherException() { when(configServerApi.put(any(String.class), any(), any(), any())) .thenThrow(new RuntimeException("Some parameter was wrong")); orchestrator.suspend(hostName); }
@Override public void suspend(final String hostName) { UpdateHostResponse response; try { var params = new ConfigServerApi.Params().setConnectionTimeout(CONNECTION_TIMEOUT); response = configServerApi.put(getSuspendPath(hostName), Optional.empty(), UpdateHostResponse.class, params); } catch (HttpException.NotFoundException n) { throw new OrchestratorNotFoundException("Failed to suspend " + hostName + ", host not found"); } catch (HttpException e) { throw new OrchestratorException("Failed to suspend " + hostName + ": " + e.toString()); } catch (ConnectionException e) { throw new ConvergenceException("Failed to suspend " + hostName + ": " + e.getMessage()); } catch (RuntimeException e) { throw new RuntimeException("Got error on suspend", e); } Optional.ofNullable(response.reason()).ifPresent(reason -> { throw new OrchestratorException(reason.message()); }); }
OrchestratorImpl implements Orchestrator { @Override public void suspend(final String hostName) { UpdateHostResponse response; try { var params = new ConfigServerApi.Params().setConnectionTimeout(CONNECTION_TIMEOUT); response = configServerApi.put(getSuspendPath(hostName), Optional.empty(), UpdateHostResponse.class, params); } catch (HttpException.NotFoundException n) { throw new OrchestratorNotFoundException("Failed to suspend " + hostName + ", host not found"); } catch (HttpException e) { throw new OrchestratorException("Failed to suspend " + hostName + ": " + e.toString()); } catch (ConnectionException e) { throw new ConvergenceException("Failed to suspend " + hostName + ": " + e.getMessage()); } catch (RuntimeException e) { throw new RuntimeException("Got error on suspend", e); } Optional.ofNullable(response.reason()).ifPresent(reason -> { throw new OrchestratorException(reason.message()); }); } }
OrchestratorImpl implements Orchestrator { @Override public void suspend(final String hostName) { UpdateHostResponse response; try { var params = new ConfigServerApi.Params().setConnectionTimeout(CONNECTION_TIMEOUT); response = configServerApi.put(getSuspendPath(hostName), Optional.empty(), UpdateHostResponse.class, params); } catch (HttpException.NotFoundException n) { throw new OrchestratorNotFoundException("Failed to suspend " + hostName + ", host not found"); } catch (HttpException e) { throw new OrchestratorException("Failed to suspend " + hostName + ": " + e.toString()); } catch (ConnectionException e) { throw new ConvergenceException("Failed to suspend " + hostName + ": " + e.getMessage()); } catch (RuntimeException e) { throw new RuntimeException("Got error on suspend", e); } Optional.ofNullable(response.reason()).ifPresent(reason -> { throw new OrchestratorException(reason.message()); }); } OrchestratorImpl(ConfigServerApi configServerApi); }
OrchestratorImpl implements Orchestrator { @Override public void suspend(final String hostName) { UpdateHostResponse response; try { var params = new ConfigServerApi.Params().setConnectionTimeout(CONNECTION_TIMEOUT); response = configServerApi.put(getSuspendPath(hostName), Optional.empty(), UpdateHostResponse.class, params); } catch (HttpException.NotFoundException n) { throw new OrchestratorNotFoundException("Failed to suspend " + hostName + ", host not found"); } catch (HttpException e) { throw new OrchestratorException("Failed to suspend " + hostName + ": " + e.toString()); } catch (ConnectionException e) { throw new ConvergenceException("Failed to suspend " + hostName + ": " + e.getMessage()); } catch (RuntimeException e) { throw new RuntimeException("Got error on suspend", 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); }
OrchestratorImpl implements Orchestrator { @Override public void suspend(final String hostName) { UpdateHostResponse response; try { var params = new ConfigServerApi.Params().setConnectionTimeout(CONNECTION_TIMEOUT); response = configServerApi.put(getSuspendPath(hostName), Optional.empty(), UpdateHostResponse.class, params); } catch (HttpException.NotFoundException n) { throw new OrchestratorNotFoundException("Failed to suspend " + hostName + ", host not found"); } catch (HttpException e) { throw new OrchestratorException("Failed to suspend " + hostName + ": " + e.toString()); } catch (ConnectionException e) { throw new ConvergenceException("Failed to suspend " + hostName + ": " + e.getMessage()); } catch (RuntimeException e) { throw new RuntimeException("Got error on suspend", 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);  }