@Test
  public void getFactoryTestWithBadInputTest() throws IOException {
    VerifiableProperties verifiableProperties = new VerifiableProperties(new Properties());
    Router router = new InMemoryRouter(verifiableProperties, new MockClusterMap(), null);
    RestRequestService restRequestService = new MockRestRequestService(verifiableProperties, router);

    // RestResponseHandlerFactory constructor.
    // handlerCount = 0
    try {
      new AsyncRequestResponseHandlerFactory(0, new MetricRegistry(), restRequestService);
      fail("Instantiation should have failed because response handler count is 0");
    } catch (IllegalArgumentException e) {
      // expected. Nothing to do.
    }
    // handlerCount < 0
    try {
      new AsyncRequestResponseHandlerFactory(-1, new MetricRegistry(), restRequestService);
      fail("Instantiation should have failed because response handler count is less than 0");
    } catch (IllegalArgumentException e) {
      // expected. Nothing to do.
    }

    // MetricRegistry null.
    try {
      new AsyncRequestResponseHandlerFactory(1, null, restRequestService);
      fail("Instantiation should have failed because one of the arguments was null");
    } catch (IllegalArgumentException e) {
      // expected. Nothing to do.
    }

    // RestRequestHandlerFactory constructor.
    // handlerCount = 0
    try {
      new AsyncRequestResponseHandlerFactory(0, new MetricRegistry(), restRequestService);
      fail("Instantiation should have failed because request handler count is 0");
    } catch (IllegalArgumentException e) {
      // expected. Nothing to do.
    }

    // handlerCount < 0
    try {
      new AsyncRequestResponseHandlerFactory(-1, new MetricRegistry(), restRequestService);
      fail("Instantiation should have failed because request handler count is less than 0");
    } catch (IllegalArgumentException e) {
      // expected. Nothing to do.
    }

    // MetricRegistry null.
    try {
      new AsyncRequestResponseHandlerFactory(1, null, restRequestService);
      fail("Instantiation should have failed because one of the arguments was null");
    } catch (IllegalArgumentException e) {
      // expected. Nothing to do.
    }

    // RestRequestService null.
    try {
      new AsyncRequestResponseHandlerFactory(1, new MetricRegistry(), null);
      fail("Instantiation should have failed because one of the arguments was null");
    } catch (IllegalArgumentException e) {
      // expected. Nothing to do.
    }
  }
Tests instantiation of {@link AsyncRequestResponseHandlerFactory} with bad input.
ambry-rest/src/test/java/com/github/ambry/rest/AsyncRequestResponseHandlerFactoryTest.java