@Test
  public void badRequestsTest() throws Exception {
    ThrowingBiConsumer<String, RestServiceErrorCode> testAction = (requestBody, expectedErrorCode) -> {
      TestUtils.assertException(RestServiceException.class,
          () -> sendRequestGetResponse(requestBody, new MockRestResponseChannel()),
          e -> assertEquals("Unexpected error code", expectedErrorCode, e.getErrorCode()));
    };
    // non json input
    testAction.accept("ABC", RestServiceErrorCode.BadRequest);
    // invalid json
    testAction.accept(new JSONObject().append("accounts", "ABC").toString(), RestServiceErrorCode.BadRequest);
    // AccountService update failure
    accountService.setShouldUpdateSucceed(false);
    testAction.accept(new String(AccountCollectionSerde.serializeAccountsInJson(Collections.emptyList(), false)),
        RestServiceErrorCode.InternalServerError);
  }
Test bad request cases.
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/PostAccountsHandlerTest.java