use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.
the class ExecutionWindowHelperTest method testDailyWindowBeforeTime.
@Test
public void testDailyWindowBeforeTime() {
// Daily at 1:15am
ExecutionWindow window = createDailyWindow(1, 15);
setLengthInHours(window, 1);
ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
// before, different hour
Calendar beforeTime = getDateTimeUTC(2000, Calendar.JANUARY, 1, 0, 10, 0);
// Should be the same date
assertDateTime(helper.calculateNext(beforeTime), 2000, Calendar.JANUARY, 1, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(beforeTime), 2000, Calendar.JANUARY, 1, 1, 15, 0);
// a few minutes before, the same hour
beforeTime = getDateTimeUTC(2000, Calendar.JANUARY, 1, 1, 10, 0);
// Should be the same date
assertDateTime(helper.calculateNext(beforeTime), 2000, Calendar.JANUARY, 1, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(beforeTime), 2000, Calendar.JANUARY, 1, 1, 15, 0);
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.
the class ExecutionWindowHelperTest method createMonthlyWindow.
private static ExecutionWindow createMonthlyWindow(int dayOfMonth, int hour, int minute) {
ExecutionWindow window = new ExecutionWindow();
window.setExecutionWindowType(ExecutionWindowType.MONTHLY.name());
window.setHourOfDayInUTC(hour);
window.setMinuteOfHourInUTC(minute);
window.setDayOfMonth(dayOfMonth);
return window;
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.
the class ExecutionWindowHelperTest method createDailyWindow.
private static ExecutionWindow createDailyWindow(int hour, int minute) {
ExecutionWindow window = new ExecutionWindow();
window.setExecutionWindowType(ExecutionWindowType.DAILY.name());
window.setHourOfDayInUTC(hour);
window.setMinuteOfHourInUTC(minute);
return window;
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.
the class ExecutionWindowHelperTest method testWeeklyDuringTime.
@Test
public void testWeeklyDuringTime() {
// Weekly on Sunday at 1:15am
ExecutionWindow window = createWeeklyWindow(Calendar.SUNDAY, 1, 15);
setLengthInHours(window, 1);
ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
// Start of the window
Calendar duringTime = getDateTimeUTC(2013, Calendar.MAY, 5, 1, 15, 0);
assertDateTime(helper.calculateNext(duringTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2013, Calendar.MAY, 5, 1, 15, 0);
Assert.assertTrue(helper.isActive(duringTime));
// One minute after start
duringTime = getDateTimeUTC(2013, Calendar.MAY, 5, 1, 16, 0);
assertDateTime(helper.calculateNext(duringTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2013, Calendar.MAY, 5, 1, 15, 0);
Assert.assertTrue(helper.isActive(duringTime));
// One minute before end
duringTime = getDateTimeUTC(2013, Calendar.MAY, 5, 2, 14, 0);
assertDateTime(helper.calculateNext(duringTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2013, Calendar.MAY, 5, 1, 15, 0);
Assert.assertTrue(helper.isActive(duringTime));
// End of the window
duringTime = getDateTimeUTC(2013, Calendar.MAY, 5, 2, 15, 0);
assertDateTime(helper.calculateNext(duringTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2013, Calendar.MAY, 12, 1, 15, 0);
Assert.assertFalse(helper.isActive(duringTime));
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.
the class ExecutionWindowHelperTest method testMonthlyNearEndOfMonth.
@Test
public void testMonthlyNearEndOfMonth() {
// Monthly on the 31st at 1:15am
ExecutionWindow window = createMonthlyWindow(31, 1, 15);
setLengthInHours(window, 1);
ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
// February
Calendar february = getDateTimeUTC(2013, Calendar.FEBRUARY, 1, 0, 0, 0);
assertDateTime(helper.calculateNext(february), 2013, Calendar.FEBRUARY, 28, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(february), 2013, Calendar.FEBRUARY, 28, 1, 15, 0);
// March
Calendar march = getDateTimeUTC(2013, Calendar.MARCH, 1, 0, 0, 0);
assertDateTime(helper.calculateNext(march), 2013, Calendar.MARCH, 31, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(march), 2013, Calendar.MARCH, 31, 1, 15, 0);
// April
Calendar april = getDateTimeUTC(2013, Calendar.APRIL, 1, 0, 0, 0);
assertDateTime(helper.calculateNext(april), 2013, Calendar.APRIL, 30, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(april), 2013, Calendar.APRIL, 30, 1, 15, 0);
}
Aggregations