private void getDigestBeforeAllContentProcessedTest() throws NoSuchAlgorithmException, RestServiceException {
    // all content not added test.
    List<HttpContent> httpContents = new ArrayList<HttpContent>();
    generateContent(httpContents);
    Channel channel = new MockChannel();
    NettyRequest nettyRequest = createNettyRequest(HttpMethod.POST, "/", null, channel);
    nettyRequest.setDigestAlgorithm("MD5");

    // add all except the LastHttpContent
    for (int i = 0; i < httpContents.size() - 1; i++) {
      nettyRequest.addContent(httpContents.get(i));
    }

    ByteBufferAsyncWritableChannel writeChannel = new ByteBufferAsyncWritableChannel();
    ReadIntoCallback callback = new ReadIntoCallback();
    nettyRequest.readInto(writeChannel, callback);
    try {
      nettyRequest.getDigest();
      fail("Getting a digest should have failed because all the content has not been added");
    } catch (IllegalStateException e) {
      // expected. Nothing to do.
    }
    closeRequestAndValidate(nettyRequest, channel);

    // content not processed test.
    httpContents.clear();
    generateContent(httpContents);
    nettyRequest = createNettyRequest(HttpMethod.POST, "/", null, channel);
    nettyRequest.setDigestAlgorithm("MD5");

    for (HttpContent httpContent : httpContents) {
      nettyRequest.addContent(httpContent);
    }
    try {
      nettyRequest.getDigest();
      fail("Getting a digest should have failed because the content has not been processed (readInto() not called)");
    } catch (IllegalStateException e) {
      // expected. Nothing to do.
    }
    closeRequestAndValidate(nettyRequest, channel);
  }
Tests for failure when {@link NettyRequest#getDigest()} is called before
1. All content is added.
2. All content is processed (i.e. before a call to {@link NettyRequest#readInto(AsyncWritableChannel, Callback)}).
@throws NoSuchAlgorithmException
@throws RestServiceException
ambry-rest/src/test/java/com/github/ambry/rest/NettyRequestTest.java