@Test
public void testUsesServerRequestIdOnMismatch() throws Exception {

  final String responseRequestId = "foobar";
  when(client.send(any())).thenReturn(CompletableFuture.completedFuture(
      responseBuilder(HTTP_INTERNAL_ERROR, Collections.emptyList())
          .addHeader("X-Request-Id", responseRequestId).build()));
  try {
    styx.workflows().toCompletableFuture().get();
    fail();
  } catch (ExecutionException e) {
    assertThat(e.getCause(), instanceOf(ApiErrorException.class));
    final ApiErrorException apiError = (ApiErrorException) e.getCause();
    assertThat(apiError.getRequestId(), is(responseRequestId));
  }
}