private void verifyAccountAndContainerFromBlobId(String blobId, Account expectedAccount, Container expectedContainer,
      RestServiceErrorCode expectedRestErrorCode) throws Exception {
    if (blobId.startsWith("/")) {
      blobId = blobId.substring(1);
    }
    // PUT is verified in the tests of the individual handlers.
    for (RestMethod restMethod : Lists.newArrayList(RestMethod.GET, RestMethod.HEAD, RestMethod.DELETE)) {
      RestRequest restRequest = createRestRequest(restMethod, "/" + blobId, null, null);
      MockRestResponseChannel restResponseChannel = new MockRestResponseChannel();
      try {
        doOperation(restRequest, restResponseChannel);
        if (expectedRestErrorCode != null) {
          fail("Should have thrown");
        }
      } catch (RestServiceException e) {
        assertEquals("Wrong RestServiceErrorCode", expectedRestErrorCode, e.getErrorCode());
      }
      BlobId deserializedId = new BlobId(blobId, clusterMap);
      // Because BlobInfo is not fetched on deletes, V1 Blob IDs will never be reassigned to a known account/container.
      boolean alwaysExpectUnknown =
          restMethod == RestMethod.DELETE && deserializedId.getAccountId() == Account.UNKNOWN_ACCOUNT_ID
              && deserializedId.getContainerId() == Container.UNKNOWN_CONTAINER_ID;
      assertEquals("Wrong account object in RestRequest's args",
          alwaysExpectUnknown ? InMemAccountService.UNKNOWN_ACCOUNT : expectedAccount,
          restRequest.getArgs().get(RestUtils.InternalKeys.TARGET_ACCOUNT_KEY));
      assertEquals("Wrong container object in RestRequest's args",
          alwaysExpectUnknown ? Container.UNKNOWN_CONTAINER : expectedContainer,
          restRequest.getArgs().get(RestUtils.InternalKeys.TARGET_CONTAINER_KEY));
    }
  }
Verifies presence of {@link Account} and {@link Container} injected into {@link RestRequest} using a
blobId string, for get/head/delete operations.
@param blobId The blobId string to get/head/delete.
@param expectedAccount The expected {@link Account} to verify its presence in {@link RestRequest}.
@param expectedContainer The expected {@link Container} to verify its presence in {@link RestRequest}.
@param expectedRestErrorCode The expected {@link RestServiceErrorCode} to verify.
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java