### Question:
TimeRetentionStrategy implements RetentionStrategy { @Override public boolean isPurgeable(String tableNameWithType, SegmentZKMetadata segmentZKMetadata) { TimeUnit timeUnit = segmentZKMetadata.getTimeUnit(); if (timeUnit == null) { LOGGER.warn("Time unit is not set for {} segment: {} of table: {}", segmentZKMetadata.getSegmentType(), segmentZKMetadata.getSegmentName(), tableNameWithType); return false; } long endTime = segmentZKMetadata.getEndTime(); long endTimeMs = timeUnit.toMillis(endTime); if (!TimeUtils.timeValueInValidRange(endTimeMs)) { LOGGER.warn("{} segment: {} of table: {} has invalid end time: {} {}", segmentZKMetadata.getSegmentType(), segmentZKMetadata.getSegmentName(), tableNameWithType, endTime, timeUnit); return false; } return System.currentTimeMillis() - endTimeMs > _retentionMs; } TimeRetentionStrategy(TimeUnit timeUnit, long timeValue); @Override boolean isPurgeable(String tableNameWithType, SegmentZKMetadata segmentZKMetadata);  }### Answer:
@Test public void testTimeRetention() { String tableNameWithType = "myTable_OFFLINE"; TimeRetentionStrategy retentionStrategy = new TimeRetentionStrategy(TimeUnit.DAYS, 30L); SegmentZKMetadata metadata = new OfflineSegmentZKMetadata(); assertFalse(retentionStrategy.isPurgeable(tableNameWithType, metadata)); metadata.setTimeUnit(TimeUnit.DAYS); assertFalse(retentionStrategy.isPurgeable(tableNameWithType, metadata)); metadata.setEndTime(1L); assertFalse(retentionStrategy.isPurgeable(tableNameWithType, metadata)); long today = TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis()); metadata.setEndTime(today); assertFalse(retentionStrategy.isPurgeable(tableNameWithType, metadata)); metadata.setEndTime(today - 14); assertFalse(retentionStrategy.isPurgeable(tableNameWithType, metadata)); metadata.setEndTime(today - 60); assertTrue(retentionStrategy.isPurgeable(tableNameWithType, metadata)); metadata.setEndTime(today + (365 * 200)); assertFalse(retentionStrategy.isPurgeable(tableNameWithType, metadata)); }