@Test
  public void testListNamedBlobsWithPrefix() throws Exception {
    final int NUM_RECORD = 100;
    ListOperationTestParam param = setupTestParamForListOperation(NUM_RECORD);
    // Test two different case with different page sizes.
    // First page size equals to the number of records, so we expect all blob names returned in one list operation.
    // Second page size is less than the number of records, so we expect pagination.
    for (int pageSize : new int[]{NUM_RECORD, NUM_RECORD / 10}) {
      List<NamedBlobRecord> obtainedRecords = new ArrayList<>();
      Page<NamedBlobRecord> page = null;
      String token = null;
      int nextRecord = 0;
      do {
        page =
            namedBlobDb.list(param.account.getName(), param.container.getName(), param.blobNamePrefix, token, pageSize)
                .get();
        obtainedRecords.addAll(page.getEntries());
        token = page.getNextPageToken();
        if (pageSize == NUM_RECORD) {
          assertNull(token);
          break;
        } else {
          if (token != null) {
            nextRecord += pageSize;
            String expectedToken = param.blobNamePrefix + String.format("%02d", nextRecord);
            assertEquals(expectedToken, token);
          }
        }
      } while (page.getNextPageToken() != null);
      validateListResult(obtainedRecords, param.records);
    }
  }
Test case for list named blobs with prefix.
@throws Exception
ambry-named-mysql/src/integration-test/java/com/github/ambry/named/MySqlNamedBlobDbListOperationIntegrationTest.java