@Test
  public void testListNamedBlobs() throws Exception {
    Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));

    time.setCurrentMilliseconds(calendar.getTimeInMillis());
    Account account = accountService.getAllAccounts().iterator().next();
    Container container = account.getAllContainers().iterator().next();

    final String blobNamePrefix = "blobNameForList";

    // Create expired records
    final long expiredTimeMs = calendar.getTimeInMillis() - TimeUnit.HOURS.toMillis(1);
    final Set<String> expiredNames = new HashSet<>(Arrays.asList("name1", "name2", "name3", "name4", "name5"));
    expiredNames.forEach(name -> {
      final NamedBlobRecord record = new NamedBlobRecord(account.getName(), container.getName(), blobNamePrefix + name,
          getBlobId(account, container), expiredTimeMs);
      try {
        namedBlobDb.put(record, NamedBlobState.READY, true).get();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    });

    // Create valid records
    final long validimeMs = calendar.getTimeInMillis() + TimeUnit.HOURS.toMillis(1);
    final Set<String> validNames = new HashSet<>(Arrays.asList("name6", "name7", "name8", "name9", "name10"));
    final Set<NamedBlobRecord> validRecords = new HashSet<>();
    validNames.forEach(name -> {
      final NamedBlobRecord record = new NamedBlobRecord(account.getName(), container.getName(), blobNamePrefix + name,
          getBlobId(account, container), validimeMs);
      validRecords.add(record);
      try {
        namedBlobDb.put(record, NamedBlobState.READY, true).get();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    });

    // List named blob should only put out valid ones without empty entries.
    Page<NamedBlobRecord> page =
        namedBlobDb.list(account.getName(), container.getName(), blobNamePrefix, null, null).get();
    assertEquals("List named blob entries should match the valid records", validRecords,
        new HashSet<>(page.getEntries()));
    assertNull("Next page token should be null", page.getNextPageToken());
  }
Test behavior with list named blob
ambry-named-mysql/src/integration-test/java/com/github/ambry/named/MySqlNamedBlobDbListOperationIntegrationTest.java