@Test
public void getSecretSeries() {

  // Create multiple secret series
  long now = OffsetDateTime.now().toEpochSecond();
  long firstExpiry = now + 10000;
  long secondExpiry = now + 20000;
  long thirdExpiry = now + 30000;
  long fourthExpiry = now + 40000;
  long firstId = secretSeriesDAO.createSecretSeries("expiringFirst",
      "creator", "", null, null, now);
  long firstContentId = secretContentDAO.createSecretContent(firstId,
      "blah", "checksum", "creator", null, firstExpiry, now);
  secretSeriesDAO.setCurrentVersion(firstId, firstContentId, "creator", now);
  long secondId = secretSeriesDAO.createSecretSeries("expiringSecond",
      "creator", "", null, null, now);
  long secondContentId = secretContentDAO.createSecretContent(secondId, "blah",
      "checksum", "creator", null, secondExpiry, now);
  secretSeriesDAO.setCurrentVersion(secondId, secondContentId, "creator", now);
  // Make sure the rows aren't ordered by expiry
  long fourthId = secretSeriesDAO.createSecretSeries("expiringFourth",
      "creator", "", null, null, now);
  long fourthContentId = secretContentDAO.createSecretContent(fourthId, "blah",
      "checksum", "creator", null, fourthExpiry, now);
  secretSeriesDAO.setCurrentVersion(fourthId, fourthContentId, "creator", now);
  long thirdId = secretSeriesDAO.createSecretSeries("expiringThird",
      "creator", "", null, null, now);
  long thirdContentId = secretContentDAO.createSecretContent(thirdId, "blah",
      "checksum", "creator", null, thirdExpiry, now);
  secretSeriesDAO.setCurrentVersion(thirdId, thirdContentId, "creator", now);
  long fifthId = secretSeriesDAO.createSecretSeries("laterInAlphabetExpiringFourth",
      "creator", "", null, null, now);
  long fifthContentId = secretContentDAO.createSecretContent(fifthId, "blah",
      "checksum", "creator", null, fourthExpiry, now);
  secretSeriesDAO.setCurrentVersion(fifthId, fifthContentId, "creator", now);
  // Retrieving secrets with no parameters should retrieve all created secrets (although given
  // the shared database, it's likely to also retrieve others)
  ImmutableList<SecretSeries>
      retrievedSeries = secretSeriesDAO.getSecretSeries(null, null, null, null, null);
  assertListContainsSecretsWithIds(retrievedSeries, ImmutableList.of(firstId, secondId, thirdId, fourthId, fifthId));
  // Restrict expireMaxTime to exclude the last secrets
  retrievedSeries = secretSeriesDAO.getSecretSeries(fourthExpiry - 100, null, null,null, null);
  assertListContainsSecretsWithIds(retrievedSeries, ImmutableList.of(firstId, secondId, thirdId));
  assertListDoesNotContainSecretsWithIds(retrievedSeries, ImmutableList.of(fourthId, fifthId));
  // Restrict expireMinTime to exclude the first secret
  retrievedSeries = secretSeriesDAO.getSecretSeries(fourthExpiry - 100, null, firstExpiry + 10, null,null);
  assertListContainsSecretsWithIds(retrievedSeries, ImmutableList.of(secondId, thirdId));
  assertListDoesNotContainSecretsWithIds(retrievedSeries, ImmutableList.of(firstId, fourthId, fifthId));
  // Adjust the limit to exclude the third secret
  retrievedSeries = secretSeriesDAO.getSecretSeries(fourthExpiry - 100, null, firstExpiry + 10, null,1);
  assertListContainsSecretsWithIds(retrievedSeries, ImmutableList.of(secondId));
  assertListDoesNotContainSecretsWithIds(retrievedSeries, ImmutableList.of(firstId, thirdId, fourthId, fifthId));
  // Restrict the minName to exclude the fourth secret
  retrievedSeries = secretSeriesDAO.getSecretSeries(null, null, fourthExpiry, "laterInAlphabetExpiringFourth", null);
  assertListContainsSecretsWithIds(retrievedSeries, ImmutableList.of(fifthId));
  assertListDoesNotContainSecretsWithIds(retrievedSeries, ImmutableList.of(firstId, secondId, thirdId, fourthId));
}