@Test public void returns_200_on_success() { HostResource hostResource = new HostResource(alwaysAllowOrchestrator, uriInfo); final String hostName = "hostname"; UpdateHostResponse response = hostResource.suspend(hostName); assertEquals(hostName, response.hostname()); }
@Override public UpdateHostResponse suspend(String hostNameString) { HostName hostName = new HostName(hostNameString); try { orchestrator.suspend(hostName); } catch (HostNameNotFoundException e) { log.log(Level.FINE, "Host not found: " + hostName); throw new NotFoundException(e); } catch (UncheckedTimeoutException e) { log.log(Level.FINE, "Failed to suspend " + hostName + ": " + e.getMessage()); throw webExceptionFromTimeout("suspend", hostName, e); } catch (HostStateChangeDeniedException e) { log.log(Level.FINE, "Failed to suspend " + hostName + ": " + e.getMessage()); throw webExceptionWithDenialReason("suspend", hostName, e); } return new UpdateHostResponse(hostName.s(), null); }
HostResource implements HostApi { @Override public UpdateHostResponse suspend(String hostNameString) { HostName hostName = new HostName(hostNameString); try { orchestrator.suspend(hostName); } catch (HostNameNotFoundException e) { log.log(Level.FINE, "Host not found: " + hostName); throw new NotFoundException(e); } catch (UncheckedTimeoutException e) { log.log(Level.FINE, "Failed to suspend " + hostName + ": " + e.getMessage()); throw webExceptionFromTimeout("suspend", hostName, e); } catch (HostStateChangeDeniedException e) { log.log(Level.FINE, "Failed to suspend " + hostName + ": " + e.getMessage()); throw webExceptionWithDenialReason("suspend", hostName, e); } return new UpdateHostResponse(hostName.s(), null); } }
HostResource implements HostApi { @Override public UpdateHostResponse suspend(String hostNameString) { HostName hostName = new HostName(hostNameString); try { orchestrator.suspend(hostName); } catch (HostNameNotFoundException e) { log.log(Level.FINE, "Host not found: " + hostName); throw new NotFoundException(e); } catch (UncheckedTimeoutException e) { log.log(Level.FINE, "Failed to suspend " + hostName + ": " + e.getMessage()); throw webExceptionFromTimeout("suspend", hostName, e); } catch (HostStateChangeDeniedException e) { log.log(Level.FINE, "Failed to suspend " + hostName + ": " + e.getMessage()); throw webExceptionWithDenialReason("suspend", hostName, e); } return new UpdateHostResponse(hostName.s(), null); } @Inject  HostResource(@Component Orchestrator orchestrator, @Context UriInfo uriInfo); }
HostResource implements HostApi { @Override public UpdateHostResponse suspend(String hostNameString) { HostName hostName = new HostName(hostNameString); try { orchestrator.suspend(hostName); } catch (HostNameNotFoundException e) { log.log(Level.FINE, "Host not found: " + hostName); throw new NotFoundException(e); } catch (UncheckedTimeoutException e) { log.log(Level.FINE, "Failed to suspend " + hostName + ": " + e.getMessage()); throw webExceptionFromTimeout("suspend", hostName, e); } catch (HostStateChangeDeniedException e) { log.log(Level.FINE, "Failed to suspend " + hostName + ": " + e.getMessage()); throw webExceptionWithDenialReason("suspend", hostName, e); } return new UpdateHostResponse(hostName.s(), null); } @Inject  HostResource(@Component Orchestrator orchestrator, @Context UriInfo uriInfo); @Override GetHostResponse getHost(String hostNameString); @Override PatchHostResponse patch(String hostNameString, PatchHostRequest request); @Override UpdateHostResponse suspend(String hostNameString); @Override UpdateHostResponse resume(final String hostNameString); }
HostResource implements HostApi { @Override public UpdateHostResponse suspend(String hostNameString) { HostName hostName = new HostName(hostNameString); try { orchestrator.suspend(hostName); } catch (HostNameNotFoundException e) { log.log(Level.FINE, "Host not found: " + hostName); throw new NotFoundException(e); } catch (UncheckedTimeoutException e) { log.log(Level.FINE, "Failed to suspend " + hostName + ": " + e.getMessage()); throw webExceptionFromTimeout("suspend", hostName, e); } catch (HostStateChangeDeniedException e) { log.log(Level.FINE, "Failed to suspend " + hostName + ": " + e.getMessage()); throw webExceptionWithDenialReason("suspend", hostName, e); } return new UpdateHostResponse(hostName.s(), null); } @Inject  HostResource(@Component Orchestrator orchestrator, @Context UriInfo uriInfo); @Override GetHostResponse getHost(String hostNameString); @Override PatchHostResponse patch(String hostNameString, PatchHostRequest request); @Override UpdateHostResponse suspend(String hostNameString); @Override UpdateHostResponse resume(final String hostNameString);  }