@Test
  public void instantiationTest() throws RestServiceException {
    HttpMethod[] successMethods = {HttpMethod.POST, HttpMethod.PUT};

    // POST and PUT will succeed.
    for (HttpMethod method : successMethods) {
      NettyRequest.bufferWatermark = 1;
      HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, method, "/");
      MockChannel channel = new MockChannel();
      RecvByteBufAllocator expected = channel.config().getRecvByteBufAllocator();
      NettyMultipartRequest request =
          new NettyMultipartRequest(httpRequest, channel, NETTY_METRICS, Collections.emptySet(), Long.MAX_VALUE);
      assertTrue("Auto-read should not have been changed", channel.config().isAutoRead());
      assertEquals("RecvByteBufAllocator should not have changed", expected,
          channel.config().getRecvByteBufAllocator());
      closeRequestAndValidate(request);
    }

    // Methods that will fail. Can include other methods, but these should be enough.
    HttpMethod[] methods = {HttpMethod.GET, HttpMethod.DELETE, HttpMethod.HEAD};
    for (HttpMethod method : methods) {
      HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, method, "/");
      try {
        new NettyMultipartRequest(httpRequest, new MockChannel(), NETTY_METRICS, Collections.emptySet(),
            Long.MAX_VALUE);
        fail("Creation of NettyMultipartRequest should have failed for " + method);
      } catch (IllegalArgumentException e) {
        // expected. Nothing to do.
      }
    }
  }
Tests instantiation of {@link NettyMultipartRequest} with different {@link HttpMethod} types.
</p>
Only {@link HttpMethod#POST} should succeed.
@throws RestServiceException
ambry-rest/src/test/java/com/github/ambry/rest/NettyMultipartRequestTest.java