@Test
public void testConsumeCompletionWithChangeVisibilityFailure() {

  urlSetup("visibilityFailure", "visibilityFailureUrl");
  ChangeMessageVisibilityRequest changeVisibilityReq =
      ChangeMessageVisibilityRequest.builder()
          .queueUrl("visibilityFailureUrl")
          .receiptHandle("visibilityFailure")
          .visibilityTimeout(0)
          .build();
  CompletableFuture<ChangeMessageVisibilityResponse> visibilityResponse =
      new CompletableFuture<>();
  visibilityResponse.completeExceptionally(new Exception());
  when(awsAsyncSqsClient.changeMessageVisibility(changeVisibilityReq))
      .thenReturn(visibilityResponse);
  CompletableFuture<Void> future = new CompletableFuture<>();
  future.completeExceptionally(new Exception("async consumer completing exceptionally"));
  AsyncConsumer<String> function = (str, threadpool) -> future;
  // ensure future is completed when exception in changeMessageVisibility
  CompletableFuture<Boolean> result = asyncClient.consume(function, "visibilityFailure");
  try {
    result.get(1000, TimeUnit.MICROSECONDS);
  } catch (TimeoutException timeout) {
    fail("Future does not seem to complete when failure in changeMessageVisibility.");
  } catch (Exception ex) {
  }
  urlFailureSetup("visibilityFailure");
  // ensure future is completed when exception in get URL within changeMessageVisibility
  result = asyncClient.consume(function, "visibilityFailure");
  try {
    result.get(1000, TimeUnit.MILLISECONDS);
  } catch (TimeoutException timeout) {
    fail(
        "Future does not seem to complete when failure in getQueueUrl within changeMessageVisibility.");
  } catch (Exception ex) {
  }
}