### Question:
WorkflowResource { private Response<Workflow> workflow(String componentId, String id) { var workflowId = WorkflowId.create(componentId, id); try { return storage.workflow(workflowId) .map(Response::forPayload) .orElse(Response.forStatus(Status.NOT_FOUND)); } catch (IOException e) { throw new RuntimeException("Failed get workflow " + workflowId.toKey(), e); } } WorkflowResource(Storage storage, WorkflowValidator workflowValidator,
                          WorkflowInitializer workflowInitializer,
                          BiConsumer<Optional<Workflow>, Optional<Workflow>> workflowConsumer,
                          WorkflowActionAuthorizer workflowActionAuthorizer); Stream<Route<AsyncHandler<Response<ByteString>>>> routes(RequestAuthenticator requestAuthenticator);  }### Answer:
@Test public void shouldFailToReturnWorkflow() throws Exception { sinceVersion(Api.Version.V3); when(storage.workflow(WorkflowId.create("foo", "bar"))).thenThrow(new IOException()); Response<ByteString> response = awaitResponse( serviceHelper.request("GET", path("/foo/bar"))); assertThat(response, hasStatus(withCode(Status.INTERNAL_SERVER_ERROR))); }
@Test public void shouldReturnErrorWhenFailedToGetWorkflow() throws Exception { sinceVersion(Api.Version.V3); doThrow(new IOException()).when(storage).workflow(WORKFLOW.id()); var response = awaitResponse(serviceHelper.request("GET", path("/foo/bar"))); assertThat(response, hasStatus(withCode(Status.INTERNAL_SERVER_ERROR))); verify(storage, never()).delete(WORKFLOW.id()); }