@Test
  public void ttlUpdateErrorCasesTest() throws Exception {
    // ID that does not exist
    verifyTtlUpdateFailure(getUniqueId(), Utils.Infinite_Time, StoreErrorCodes.IDNotFound);
    // ID that has expired
    MockId expiredId = null;
    for (MockId expired : expiredKeys) {
      verifyTtlUpdateFailure(expired, Utils.Infinite_Time, StoreErrorCodes.UpdateNotAllowed);
      expiredId = expired;
    }
    // If the ttl update request comes from replication, then it should succeed
    assertNotNull(expiredId);
    MessageInfo info = new MessageInfo(expiredId, TTL_UPDATE_RECORD_SIZE, false, true, false, Utils.Infinite_Time, null,
        expiredId.getAccountId(), expiredId.getContainerId(), time.milliseconds(), (short) 1);
    store.updateTtl(Arrays.asList(info));

    // ID that has not expired but is within the "no updates" period
    inNoTtlUpdatePeriodTest();
    // ID that is already updated
    for (MockId ttlUpdated : ttlUpdatedKeys) {
      if (!deletedKeys.contains(ttlUpdated)) {
        verifyTtlUpdateFailure(ttlUpdated, Utils.Infinite_Time, StoreErrorCodes.AlreadyUpdated);
      }
    }
    // ID that is already deleted
    for (MockId deleted : deletedKeys) {
      verifyTtlUpdateFailure(deleted, Utils.Infinite_Time, StoreErrorCodes.IDDeleted);
    }
    // Attempt to set expiry time to anything other than infinity
    MockId id = getIdToTtlUpdate(liveKeys);
    verifyTtlUpdateFailure(id, time.milliseconds() + 5, StoreErrorCodes.UpdateNotAllowed);
    // authorization failure
    ttlUpdateAuthorizationFailureTest();
    // duplicates
    id = getUniqueId();
    info = new MessageInfo(id, TTL_UPDATE_RECORD_SIZE, false, true, Utils.Infinite_Time, id.getAccountId(),
        id.getContainerId(), time.milliseconds());
    try {
      store.updateTtl(Arrays.asList(info, info));
      fail("Store TTL UPDATE should have failed");
    } catch (IllegalArgumentException e) {
      // expected. Nothing to do
    }
  }
Tests different possible error cases for TTL update
@throws Exception
ambry-store/src/test/java/com/github/ambry/store/BlobStoreTest.java