private void doListNamedBlobsTest(String prefix, String pageToken, Page<NamedBlobRecord> pageToReturn,
      RestServiceErrorCode expectedErrorCode) throws Exception {
    reset(namedBlobDb);
    String path = String.join("/", Operations.NAMED_BLOB, refAccount.getName(), refContainer.getName());
    if (prefix != null) {
      path += "?" + NamedBlobPath.PREFIX_PARAM + "=" + prefix;
    }
    if (pageToken != null) {
      path += "&" + NamedBlobPath.PAGE_PARAM + "=" + pageToken;
    }
    RestRequest restRequest = createRestRequest(RestMethod.GET, path, null, null);
    MockRestResponseChannel restResponseChannel = new MockRestResponseChannel();
    if (pageToReturn != null) {
      when(namedBlobDb.list(any(), any(), any(), any(), any())).thenReturn(
          CompletableFuture.completedFuture(pageToReturn));
    } else {
      CompletableFuture<Page<NamedBlobRecord>> future = new CompletableFuture<>();
      future.completeExceptionally(new RestServiceException("NamedBlobDb error", expectedErrorCode));
      when(namedBlobDb.list(any(), any(), any(), any(), any())).thenReturn(future);
    }

    if (expectedErrorCode == null) {
      assertNotNull("pageToReturn should be set", pageToReturn);
      doOperation(restRequest, restResponseChannel);
      verify(namedBlobDb).list(refAccount.getName(), refContainer.getName(), prefix, pageToken, DEFAULT_MAX_KEY_VALUE);
      Page<NamedBlobListEntry> response =
          Page.fromJson(new JSONObject(new String(restResponseChannel.getResponseBody())), NamedBlobListEntry::new);
      assertEquals("Unexpected blobs returned",
          pageToReturn.getEntries().stream().map(NamedBlobListEntry::new).collect(Collectors.toList()),
          response.getEntries());
      assertEquals("Unexpected nextPageToken", pageToReturn.getNextPageToken(), response.getNextPageToken());
    } else {
      TestUtils.assertException(RestServiceException.class, () -> doOperation(restRequest, restResponseChannel),
          rse -> assertEquals("Unexpected error code", expectedErrorCode, rse.getErrorCode()));
    }
  }
@param prefix the prefix to set in the request params.
@param pageToken the page token to set in the request params.
@param pageToReturn the page that {@link NamedBlobDb} should return, or {@code null} if it should throw an error.
@param expectedErrorCode if non-null, check for this error code instead of a successful response.
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java