HostResource implements HostApi { @Override public UpdateHostResponse resume(final String hostNameString) { HostName hostName = new HostName(hostNameString); try { orchestrator.resume(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 resume " + hostName + ": " + e.getMessage()); throw webExceptionFromTimeout("resume", hostName, e); } catch (HostStateChangeDeniedException e) { log.log(Level.FINE, "Failed to resume " + hostName + ": " + e.getMessage()); throw webExceptionWithDenialReason("resume", 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);  }
@Test public void throws_409_on_timeout() throws HostNameNotFoundException, HostStateChangeDeniedException { Orchestrator orchestrator = mock(Orchestrator.class); doThrow(new UncheckedTimeoutException("Timeout Message")).when(orchestrator).resume(any(HostName.class)); try { HostResource hostResource = new HostResource(orchestrator, uriInfo); hostResource.resume("hostname"); fail(); } catch (WebApplicationException w) { assertEquals(409, w.getResponse().getStatus()); assertEquals("resume failed: Timeout Message [deadline]", w.getMessage()); } }