@Test
  public void validRequestsTest() throws Exception {
    String accountName = theAccount.getName();
    short accountId = theAccount.getId();
    ThrowingConsumer<Collection<Container>> testAction = inputContainers -> {
      String requestBody = new String(AccountCollectionSerde.serializeContainersInJson(inputContainers));
      RestResponseChannel restResponseChannel = new MockRestResponseChannel();
      RestRequest request = createRestRequest(requestBody, accountName, null);
      ReadableStreamChannel responseChannel = sendRequestGetResponse(request, restResponseChannel);
      assertNotNull("Date has not been set", restResponseChannel.getHeader(RestUtils.Headers.DATE));
      assertEquals("Content-length is not as expected", responseChannel.getSize(),
          Integer.parseInt((String) restResponseChannel.getHeader(RestUtils.Headers.CONTENT_LENGTH)));
      assertEquals("Account id in response header is not as expected", accountId,
          Short.parseShort((String) restResponseChannel.getHeader(RestUtils.Headers.TARGET_ACCOUNT_ID)));
      RetainingAsyncWritableChannel asyncWritableChannel =
          new RetainingAsyncWritableChannel((int) responseChannel.getSize());
      responseChannel.readInto(asyncWritableChannel, null).get();
      Collection<Container> outputContainers =
          AccountCollectionSerde.containersFromInputStreamInJson(asyncWritableChannel.consumeContentAsInputStream(),
              accountId);
      assertEquals("Unexpected count returned", inputContainers.size(), outputContainers.size());
      for (Container container : outputContainers) {
        assertEquals("Container in account service not as expected", container,
            accountService.getContainerByName(accountName, container.getName()));
      }
    };

    // add new container
    testAction.accept(Collections.singleton(accountService.getRandomContainer(accountId)));

    // add multiple containers
    List<Container> containerList = new ArrayList<>();
    for (int j = 0; j < 10; j++) {
      containerList.add(
          new ContainerBuilder(Container.UNKNOWN_CONTAINER_ID, "Test-" + j, Container.ContainerStatus.ACTIVE, "",
              accountId).build());
    }
    testAction.accept(containerList);

    // TODO: update existing containers when support is added
  }
Test valid request cases.
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/PostAccountContainersHandlerTest.java