@Test
public void fetchingNonExistingWorkflowReturnsNotFound() {

  when(workflowInstances.getWorkflowInstance(42, emptySet(), null))
      .thenThrow(new NflowNotFoundException("Workflow instance", 42, new Exception()));
  try (Response response = resource.fetchWorkflowInstance(42, null, null)) {
    assertThat(response.getStatus(), is(equalTo(NOT_FOUND.getStatusCode())));
    assertThat(response.readEntity(ErrorResponse.class).error, is(equalTo("Workflow instance 42 not found")));
  }
}