Assert.assertNull(resource.getExpectedTerminationTime());
}
@Test
public void testResourceWithExpectedTerminationTimeSet() {
Resource resource = new AWSResource().withId("launchConfig1").withResourceType(AWSResourceType.LAUNCH_CONFIG);
resource.setAdditionalField(LaunchConfigJanitorCrawler.LAUNCH_CONFIG_FIELD_USED_BY_ASG, "false");
MonkeyCalendar calendar = new TestMonkeyCalendar();
int ageThreshold = 3;
DateTime now = new DateTime(calendar.now().getTimeInMillis());
resource.setLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
Date oldTermDate = new Date(now.minusDays(10).getMillis());
String oldTermReason = "Foo";
resource.setExpectedTerminationTime(oldTermDate);
resource.setTerminationReason(oldTermReason);
int retentionDays = 3;
OldUnusedLaunchConfigRule rule = new OldUnusedLaunchConfigRule(calendar, ageThreshold, retentionDays);
Assert.assertFalse(rule.isValid(resource));
Assert.assertEquals(oldTermDate, resource.getExpectedTerminationTime());
Assert.assertEquals(oldTermReason, resource.getTerminationReason());
}