@Test
  public void validRequestsTest() throws Exception {
    ThrowingConsumer<Collection<Account>> testAction = accountsToUpdate -> {
      String requestBody = new String(AccountCollectionSerde.serializeAccountsInJson(accountsToUpdate, false));
      RestResponseChannel restResponseChannel = new MockRestResponseChannel();
      sendRequestGetResponse(requestBody, restResponseChannel);
      assertNotNull("Date has not been set", restResponseChannel.getHeader(RestUtils.Headers.DATE));
      assertEquals("Content-length is not as expected", 0,
          Integer.parseInt((String) restResponseChannel.getHeader(RestUtils.Headers.CONTENT_LENGTH)));
      for (Account account : accountsToUpdate) {
        assertEquals("Account in account service not as expected", account,
            accountService.getAccountById(account.getId()));
      }
    };
    testAction.accept(Collections.emptyList());
    // add new account
    testAction.accept(Collections.singleton(accountService.generateRandomAccount()));
    // update multiple accounts
    testAction.accept(IntStream.range(0, 3).mapToObj(i -> {
      Account account = accountService.createAndAddRandomAccount();
      return new AccountBuilder(account).name(account.getName() + i).build();
    }).collect(Collectors.toList()));
  }
Test valid request cases.
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/PostAccountsHandlerTest.java