private void doBadStateTransitionTest(TestingUri uri, Class exceptionClass) throws Exception {
    EmbeddedChannel channel = createEmbeddedChannel();
    MockNettyMessageProcessor processor = channel.pipeline().get(MockNettyMessageProcessor.class);
    try {
      channel.writeInbound(RestTestUtils.createRequest(HttpMethod.GET, uri.toString(), null));
      verifyCallbacks(processor);
      fail("This test was expecting the handler in the channel to throw an exception");
    } catch (Exception e) {
      if (!exceptionClass.isInstance(e)) {
        throw e;
      }
    }
  }
Creates a channel and sends the request to the {@link EmbeddedChannel}. Checks for an exception and verifies the
exception class matches. If {@code exceptionClass} is {@link RestServiceException}, then checks the provided
{@link RestServiceErrorCode}.
@param uri the uri to hit.
@param exceptionClass the class of the exception expected.
@throws Exception
ambry-rest/src/test/java/com/github/ambry/rest/NettyResponseChannelTest.java