use of com.sequenceiq.periscope.domain.TimeAlert in project cloudbreak by hortonworks.
the class DateUtilsTest method testIsTriggerWhenTheCurrentTimeEqualsWithTheNextTriggerThenItShouldTriggerAnEvent.
@Test
public void testIsTriggerWhenTheCurrentTimeEqualsWithTheNextTriggerThenItShouldTriggerAnEvent() {
String timeZone = "America/New_York";
ZoneId zoneId = ZoneId.of(timeZone);
ZonedDateTime currentTime = ZonedDateTime.of(2017, 12, 20, 20, 0, 0, 0, ZoneId.systemDefault());
ZonedDateTime currentZonedTime = ZonedDateTime.of(2017, 12, 20, 12, 0, 0, 0, zoneId);
long monitorUpdateRate = 60000;
when(dateTimeUtils.getDefaultZonedDateTime()).thenReturn(currentTime);
when(dateTimeUtils.getZonedDateTime(currentTime.toInstant(), timeZone)).thenReturn(currentZonedTime);
TimeAlert timeAlert = createTimeAlert("0 0 12 * * ?", timeZone);
assertTrue(underTest.isTrigger(timeAlert, monitorUpdateRate));
}
use of com.sequenceiq.periscope.domain.TimeAlert in project cloudbreak by hortonworks.
the class DateUtilsTest method testIsTriggerWhenTheCurrentTimeEqualsWithTheNextTriggerAndZonesAreEquivalentThenItShouldTriggerAnEvent.
@Test
public void testIsTriggerWhenTheCurrentTimeEqualsWithTheNextTriggerAndZonesAreEquivalentThenItShouldTriggerAnEvent() {
ZoneId zone = ZoneId.systemDefault();
String timeZone = zone.getId();
ZonedDateTime currentZonedTime = ZonedDateTime.of(2017, 12, 20, 12, 0, 0, 0, zone.normalized());
long monitorUpdateRate = 60000;
when(dateTimeUtils.getDefaultZonedDateTime()).thenReturn(currentZonedTime);
when(dateTimeUtils.getZonedDateTime(currentZonedTime.toInstant(), timeZone)).thenReturn(currentZonedTime);
TimeAlert timeAlert = createTimeAlert("0 0 12 * * ?", timeZone);
assertTrue(underTest.isTrigger(timeAlert, monitorUpdateRate));
}
use of com.sequenceiq.periscope.domain.TimeAlert in project cloudbreak by hortonworks.
the class DateUtilsTest method testIsTriggerWhenTheCurrentTimeIsAfterTheNextTriggerWithSizeOfTheMonitorUpdateRateThenItShouldNotTriggerAnEvent.
@Test
public void testIsTriggerWhenTheCurrentTimeIsAfterTheNextTriggerWithSizeOfTheMonitorUpdateRateThenItShouldNotTriggerAnEvent() {
String timeZone = "America/New_York";
ZoneId zoneId = ZoneId.of(timeZone);
ZonedDateTime currentZonedTime = ZonedDateTime.of(2017, 12, 20, 12, 0, 10, 0, zoneId);
long monitorUpdateRate = 10000;
when(dateTimeUtils.getDefaultZonedDateTime()).thenReturn(currentZonedTime);
when(dateTimeUtils.getZonedDateTime(currentZonedTime.toInstant(), timeZone)).thenReturn(currentZonedTime);
TimeAlert timeAlert = createTimeAlert("0 0 12 * * ?", timeZone);
assertFalse(underTest.isTrigger(timeAlert, monitorUpdateRate));
}
use of com.sequenceiq.periscope.domain.TimeAlert in project cloudbreak by hortonworks.
the class DateUtilsTest method testIsTriggerWhenTheCurrentTimeIsBeforeTheNextTriggerMoreThanTheMonitorUpdateRateThenItShouldNotTriggerAnEvent.
@Test
public void testIsTriggerWhenTheCurrentTimeIsBeforeTheNextTriggerMoreThanTheMonitorUpdateRateThenItShouldNotTriggerAnEvent() {
String timeZone = "America/Denver";
ZoneId zoneId = ZoneId.of(timeZone);
ZonedDateTime currentTime = ZonedDateTime.of(2017, 12, 19, 13, 15, 0, 0, zoneId);
long monitorUpdateRate = 1000;
when(dateTimeUtils.getDefaultZonedDateTime()).thenReturn(currentTime);
when(dateTimeUtils.getZonedDateTime(currentTime.toInstant(), timeZone)).thenReturn(currentTime);
TimeAlert timeAlert = createTimeAlert("0 0 12 * * ?", timeZone);
assertFalse(underTest.isTrigger(timeAlert, monitorUpdateRate));
}
Aggregations