Search in sources :

Example 1 with TestMonkey

use of com.netflix.simianarmy.TestMonkey in project SimianArmy by Netflix.

the class TestBasicCalendar method testMonkeyTime.

@Test
void testMonkeyTime() {
    Calendar test = Calendar.getInstance();
    Monkey monkey = new TestMonkey();
    // using leap day b/c it is not a holiday & not a weekend
    test.set(Calendar.YEAR, 2012);
    test.set(Calendar.MONTH, Calendar.FEBRUARY);
    test.set(Calendar.DAY_OF_MONTH, 29);
    // 8am leap day
    test.set(Calendar.HOUR_OF_DAY, 8);
    setNow(test);
    Assert.assertFalse(isMonkeyTime(monkey));
    // 10am leap day
    test.set(Calendar.HOUR_OF_DAY, 10);
    setNow(test);
    Assert.assertTrue(isMonkeyTime(monkey));
    // 5pm leap day
    test.set(Calendar.HOUR_OF_DAY, 17);
    setNow(test);
    Assert.assertFalse(isMonkeyTime(monkey));
    // set to the following Saturday so we can test we dont run on weekends
    // even though within "business hours"
    test.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
    test.set(Calendar.HOUR_OF_DAY, 10);
    setNow(test);
    Assert.assertFalse(isMonkeyTime(monkey));
    // test config overrides
    PROPS.setProperty("simianarmy.calendar.isMonkeyTime", Boolean.toString(true));
    Assert.assertTrue(isMonkeyTime(monkey));
    PROPS.setProperty("simianarmy.calendar.isMonkeyTime", Boolean.toString(false));
    Assert.assertFalse(isMonkeyTime(monkey));
}
Also used : TestMonkey(com.netflix.simianarmy.TestMonkey) Calendar(java.util.Calendar) Monkey(com.netflix.simianarmy.Monkey) TestMonkey(com.netflix.simianarmy.TestMonkey) Test(org.testng.annotations.Test)

Aggregations

Monkey (com.netflix.simianarmy.Monkey)1 TestMonkey (com.netflix.simianarmy.TestMonkey)1 Calendar (java.util.Calendar)1 Test (org.testng.annotations.Test)1