@Override
  @SuppressWarnings("assignment")
  public ComputeMessageStatsResponse computeMessageStats(Offset offset) throws ApiException {
    try {
      return client
          .computeMessageStats(topicPath, partition, offset, Offset.of(Long.MAX_VALUE))
          .get(1, MINUTES);
    } catch (Throwable t) {
      throw toCanonical(t).underlying;
    }
  }
@SuppressWarnings("incompatible")
  @Test
  public void computeMessageStats_failure() {
    when(mockClient.computeMessageStats(
            example(TopicPath.class),
            example(Partition.class),
            example(Offset.class),
            Offset.of(Long.MAX_VALUE)))
        .thenReturn(
            ApiFutures.immediateFailedFuture(new CheckedApiException(Code.UNAVAILABLE).underlying));

    ApiException e =
        assertThrows(ApiException.class, () -> reader.computeMessageStats(example(Offset.class)));
    assertEquals(Code.UNAVAILABLE, e.getStatusCode().getCode());
  }