@Test
  public void injectionAccountAndContainerForGetHeadDeleteBlobIdTest() throws Exception {
    List<Short> blobIdVersions = Arrays.stream(BlobId.getAllValidVersions())
        .filter(version -> version >= BlobId.BLOB_ID_V2)
        .collect(Collectors.toList());
    for (short version : blobIdVersions) {
      populateAccountService();

      // aid=refAId, cid=refCId
      String blobId =
          new BlobId(version, BlobId.BlobIdType.NATIVE, ClusterMap.UNKNOWN_DATACENTER_ID, refAccount.getId(),
              refContainer.getId(), clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0),
              false, BlobId.BlobDataType.DATACHUNK).getID();
      verifyAccountAndContainerFromBlobId(blobId, refAccount, refContainer, RestServiceErrorCode.NotFound);

      // aid=refAId, cid=unknownCId
      blobId = new BlobId(version, BlobId.BlobIdType.NATIVE, ClusterMap.UNKNOWN_DATACENTER_ID, refAccount.getId(),
          Container.UNKNOWN_CONTAINER_ID,
          clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0), false,
          BlobId.BlobDataType.DATACHUNK).getID();
      verifyAccountAndContainerFromBlobId(blobId, null, null, RestServiceErrorCode.InvalidContainer);

      // aid=refAId, cid=nonExistCId
      blobId = new BlobId(version, BlobId.BlobIdType.NATIVE, ClusterMap.UNKNOWN_DATACENTER_ID, refAccount.getId(),
          (short) -1234, clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0), false,
          BlobId.BlobDataType.DATACHUNK).getID();
      verifyAccountAndContainerFromBlobId(blobId, null, null, RestServiceErrorCode.InvalidContainer);

      // aid=unknownAId, cid=refCId
      blobId =
          new BlobId(version, BlobId.BlobIdType.NATIVE, ClusterMap.UNKNOWN_DATACENTER_ID, Account.UNKNOWN_ACCOUNT_ID,
              refContainer.getId(), clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0),
              false, BlobId.BlobDataType.DATACHUNK).getID();
      verifyAccountAndContainerFromBlobId(blobId, null, null, RestServiceErrorCode.InvalidContainer);

      // aid=unknownAId, cid=unknownCId
      blobId =
          new BlobId(version, BlobId.BlobIdType.NATIVE, ClusterMap.UNKNOWN_DATACENTER_ID, Account.UNKNOWN_ACCOUNT_ID,
              Container.UNKNOWN_CONTAINER_ID,
              clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0), false,
              BlobId.BlobDataType.DATACHUNK).getID();
      verifyAccountAndContainerFromBlobId(blobId, InMemAccountService.UNKNOWN_ACCOUNT, Container.UNKNOWN_CONTAINER,
          RestServiceErrorCode.NotFound);

      // aid=unknownAId, cid=nonExistCId
      blobId =
          new BlobId(version, BlobId.BlobIdType.NATIVE, ClusterMap.UNKNOWN_DATACENTER_ID, Account.UNKNOWN_ACCOUNT_ID,
              (short) -1234, clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0), false,
              BlobId.BlobDataType.DATACHUNK).getID();
      verifyAccountAndContainerFromBlobId(blobId, null, null, RestServiceErrorCode.InvalidContainer);

      // aid=nonExistAId, cid=refCId
      blobId = new BlobId(version, BlobId.BlobIdType.NATIVE, ClusterMap.UNKNOWN_DATACENTER_ID, (short) -1234,
          refContainer.getId(), clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0),
          false, BlobId.BlobDataType.DATACHUNK).getID();
      verifyAccountAndContainerFromBlobId(blobId, null, null, RestServiceErrorCode.InvalidAccount);

      // aid=nonExistAId, cid=unknownCId
      blobId = new BlobId(version, BlobId.BlobIdType.NATIVE, ClusterMap.UNKNOWN_DATACENTER_ID, (short) -1234,
          Container.UNKNOWN_CONTAINER_ID,
          clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0), false,
          BlobId.BlobDataType.DATACHUNK).getID();
      verifyAccountAndContainerFromBlobId(blobId, null, null, RestServiceErrorCode.InvalidAccount);

      // aid=nonExistAId, cid=nonExistCId
      blobId =
          new BlobId(version, BlobId.BlobIdType.NATIVE, ClusterMap.UNKNOWN_DATACENTER_ID, (short) -1234, (short) -11,
              clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0), false,
              BlobId.BlobDataType.DATACHUNK).getID();
      verifyAccountAndContainerFromBlobId(blobId, null, null, RestServiceErrorCode.InvalidAccount);
    }
  }
Tests injecting target {@link Account} and {@link Container} for GET/HEAD/DELETE blobId string in {@link BlobId#BLOB_ID_V2}.
The {@link AccountService} is prepopulated with a reference account and {@link InMemAccountService#UNKNOWN_ACCOUNT}. The expected
behavior should be:

<pre>
  AId in blobId    CId in blobId     expected Error      injected account      injected container
   realAId           realCId          NotFound            refAccount            refContainer       This can succeed if the blob exists in backend.
   realAId           UNKNOWN          InvalidContainer    null                  null
   realAId           nonExistCId      InvalidContainer    null                  null
   UNKNOWN           realCId          InvalidContainer    null                  null
   UNKNOWN           UNKNOWN          NotFound            UNKNOWN               UNKNOWN            This can succeed if the blob exists in backend.
   UNKNOWN           nonExistCId      InvalidContainer    null                  null
   nonExistAId       realCId          InvalidAccount      null                  null
   nonExistAId       UNKNOWN          InvalidAccount      null                  null
   nonExistAId       nonExistCId      InvalidAccount      null                  null
</pre>

@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java