@Test
  public void addContentForGetTest() throws RestServiceException {
    byte[] content = TestUtils.getRandomBytes(16);
    // adding non LastHttpContent to nettyRequest
    NettyRequest nettyRequest = createNettyRequest(HttpMethod.GET, "/", null, new MockChannel());
    try {
      nettyRequest.addContent(new DefaultHttpContent(Unpooled.wrappedBuffer(content)));
      fail("GET requests should not accept non-LastHTTPContent");
    } catch (IllegalStateException e) {
      // expected. nothing to do.
    }

    // adding LastHttpContent with some content to nettyRequest
    nettyRequest = createNettyRequest(HttpMethod.GET, "/", null, new MockChannel());
    try {
      nettyRequest.addContent(new DefaultLastHttpContent(Unpooled.wrappedBuffer(content)));
      fail("GET requests should not accept actual content in LastHTTPContent");
    } catch (IllegalStateException e) {
      // expected. nothing to do.
    }

    // should accept LastHttpContent just fine.
    nettyRequest = createNettyRequest(HttpMethod.GET, "/", null, new MockChannel());
    nettyRequest.addContent(new DefaultLastHttpContent());

    // should not accept LastHttpContent after close
    nettyRequest = createNettyRequest(HttpMethod.GET, "/", null, new MockChannel());
    nettyRequest.close();
    try {
      nettyRequest.addContent(new DefaultLastHttpContent());
      fail("Request channel has been closed, so addContent() should have thrown ClosedChannelException");
    } catch (RestServiceException e) {
      assertEquals("Unexpected RestServiceErrorCode", RestServiceErrorCode.RequestChannelClosed, e.getErrorCode());
    }
  }
Tests different state transitions that can happen with {@link NettyRequest#addContent(HttpContent)} for GET
requests. Some transitions are valid and some should necessarily throw exceptions.
@throws RestServiceException
ambry-rest/src/test/java/com/github/ambry/rest/NettyRequestTest.java