@Test
public void testResourceWithExpectedTerminationTimeSet() {
int ageThreshold = 5;
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("snap123").withResourceType(AWSResourceType.EBS_SNAPSHOT)
.withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
((AWSResource) resource).setAWSResourceState("completed");
Date oldTermDate = new Date(now.plusDays(10).getMillis());
String oldTermReason = "Foo";
int retentionDays = 4;
NoGeneratedAMIRule rule = new NoGeneratedAMIRule(new TestMonkeyCalendar(),
ageThreshold, retentionDays);
resource.setExpectedTerminationTime(oldTermDate);
resource.setTerminationReason(oldTermReason);
Assert.assertFalse(rule.isValid(resource));
Assert.assertEquals(oldTermDate, resource.getExpectedTerminationTime());
Assert.assertEquals(oldTermReason, resource.getTerminationReason());
}