BatchedRequestIssuer { public void sendResult() { if (hasResponse) { batchedFuture.set(responseToSend); } else if (throwableToSend != null) { batchedFuture.setException(throwableToSend); } else { throw new IllegalStateException( "Neither response nor exception were set in BatchedRequestIssuer"); } } BatchedRequestIssuer(BatchedFuture<ResponseT> batchedFuture, long messageCount); long getMessageCount(); void setResponse(ResponseT response); void setException(Throwable throwable); void sendResult();  }
@Test public void testNoResult() { try { BatchedFuture<Integer> batchedFuture = BatchedFuture.<Integer>create(); BatchedRequestIssuer<Integer> issuer = new BatchedRequestIssuer<>(batchedFuture, 2); issuer.sendResult(); Assert.fail("BatchedFuture should have thrown an exception"); } catch (IllegalStateException expected) { Truth.assertThat(expected) .hasMessageThat() .contains("Neither response nor exception were set in BatchedRequestIssuer"); } }