use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class AlwaysInvalidRule method testWithExclusionRuleNotMatch1.
@Test
void testWithExclusionRuleNotMatch1() {
Resource resource = new AWSResource().withId("id");
DateTime now = DateTime.now();
BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine().addExclusionRule(new AlwaysInvalidRule(now, 1)).addRule(new AlwaysInvalidRule(now, 1));
Assert.assertFalse(engine.isValid(resource));
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class AlwaysInvalidRule method testAllValid.
@Test
public void testAllValid() {
Resource resource = new AWSResource().withId("id");
BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine().addRule(new AlwaysValidRule()).addRule(new AlwaysValidRule()).addRule(new AlwaysValidRule());
Assert.assertTrue(engine.isValid(resource));
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class AlwaysInvalidRule method testIsValidWithNearestTerminationTime.
@Test
public void testIsValidWithNearestTerminationTime() {
int[][] permutaions = { { 1, 2, 3 }, { 1, 3, 2 }, { 2, 1, 3 }, { 2, 3, 1 }, { 3, 1, 2 }, { 3, 2, 1 } };
for (int[] perm : permutaions) {
Resource resource = new AWSResource().withId("id");
DateTime now = DateTime.now();
BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine().addRule(new AlwaysInvalidRule(now, perm[0])).addRule(new AlwaysInvalidRule(now, perm[1])).addRule(new AlwaysInvalidRule(now, perm[2]));
Assert.assertFalse(engine.isValid(resource));
Assert.assertEquals(resource.getExpectedTerminationTime().getTime(), now.plusDays(1).getMillis());
Assert.assertEquals(resource.getTerminationReason(), "1");
}
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class AlwaysInvalidRule method testWithExclusionRuleMatch2.
@Test
void testWithExclusionRuleMatch2() {
Resource resource = new AWSResource().withId("id");
DateTime now = DateTime.now();
BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine().addExclusionRule(new AlwaysValidRule()).addRule(new AlwaysValidRule());
Assert.assertTrue(engine.isValid(resource));
}
use of com.netflix.simianarmy.aws.AWSResource in project SimianArmy by Netflix.
the class AlwaysInvalidRule method testMixed.
@Test
public void testMixed() {
Resource resource = new AWSResource().withId("id");
DateTime now = DateTime.now();
BasicJanitorRuleEngine engine = new BasicJanitorRuleEngine().addRule(new AlwaysValidRule()).addRule(new AlwaysInvalidRule(now, 1)).addRule(new AlwaysValidRule());
Assert.assertFalse(engine.isValid(resource));
}
Aggregations