use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.
the class ExecutionWindowTest method testMultiTenant.
@Test
public void testMultiTenant() throws Exception {
_logger.info("Starting multi tenant ExecutionWindow test");
ModelClient modelClient = getModelClient();
ExecutionWindow ew1 = create("t1", "foo1");
modelClient.save(ew1);
ExecutionWindow ew2 = create("t1", "bar2");
modelClient.save(ew2);
ExecutionWindow ew3 = create("t2", "foo3");
modelClient.save(ew3);
ExecutionWindow ew4 = create("t2", "bar4");
modelClient.save(ew4);
ExecutionWindow ew5 = create("t2", "foo5");
modelClient.save(ew5);
ExecutionWindow ew6 = create("t3", "bar6");
modelClient.save(ew6);
List<ExecutionWindow> executionWindows = modelClient.executionWindows().findAll("t1");
Assert.assertNotNull(executionWindows);
Assert.assertEquals(2, executionWindows.size());
executionWindows = modelClient.executionWindows().findAll("t2");
Assert.assertNotNull(executionWindows);
Assert.assertEquals(3, executionWindows.size());
executionWindows = modelClient.executionWindows().findAll("t3");
Assert.assertNotNull(executionWindows);
Assert.assertEquals(1, executionWindows.size());
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.
the class ExecutionWindowHelperTest method testDailySpanningMidnight.
@Test
public void testDailySpanningMidnight() {
// Daily at 11:30pm
ExecutionWindow window = createDailyWindow(23, 30);
setLengthInHours(window, 1);
ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
Calendar beforeTime = getDateTimeUTC(2013, Calendar.MAY, 6, 23, 0, 0);
assertDateTime(helper.calculateNext(beforeTime), 2013, Calendar.MAY, 6, 23, 30, 0);
assertDateTime(helper.calculateCurrentOrNext(beforeTime), 2013, Calendar.MAY, 6, 23, 30, 0);
Calendar duringTime = getDateTimeUTC(2013, Calendar.MAY, 6, 23, 45, 0);
assertDateTime(helper.calculateNext(duringTime), 2013, Calendar.MAY, 7, 23, 30, 0);
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2013, Calendar.MAY, 6, 23, 30, 0);
duringTime = getDateTimeUTC(2013, Calendar.MAY, 7, 0, 15, 0);
assertDateTime(helper.calculateNext(duringTime), 2013, Calendar.MAY, 7, 23, 30, 0);
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2013, Calendar.MAY, 6, 23, 30, 0);
Calendar afterTime = getDateTimeUTC(2013, Calendar.MAY, 7, 1, 0, 0);
assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 7, 23, 30, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 7, 23, 30, 0);
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.
the class ExecutionWindowHelperTest method testWeeklyAfterTime.
@Test
public void testWeeklyAfterTime() {
// Weekly on Sunday at 1:15am
ExecutionWindow window = createWeeklyWindow(Calendar.SUNDAY, 1, 15);
setLengthInHours(window, 1);
ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
Calendar afterTime = getDateTimeUTC(2013, Calendar.MAY, 5, 3, 15, 0);
assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
afterTime = getDateTimeUTC(2013, Calendar.MAY, 6, 1, 10, 0);
assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
afterTime = getDateTimeUTC(2013, Calendar.MAY, 7, 1, 10, 0);
assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
afterTime = getDateTimeUTC(2013, Calendar.MAY, 8, 1, 10, 0);
assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
afterTime = getDateTimeUTC(2013, Calendar.MAY, 9, 1, 10, 0);
assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
}
use of com.emc.storageos.db.client.model.uimodels.ExecutionWindow in project coprhd-controller by CoprHD.
the class ExecutionWindowHelperTest method testDailyWindowAfterTime.
@Test
public void testDailyWindowAfterTime() {
// Daily at 1:15am
ExecutionWindow window = createDailyWindow(1, 15);
setLengthInHours(window, 1);
ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
// Right after the window ends
Calendar afterTime = getDateTimeUTC(2000, Calendar.FEBRUARY, 5, 2, 16, 0);
assertDateTime(helper.calculateNext(afterTime), 2000, Calendar.FEBRUARY, 6, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2000, Calendar.FEBRUARY, 6, 1, 15, 0);
// Should be the next day
afterTime = getDateTimeUTC(2000, Calendar.FEBRUARY, 5, 10, 16, 0);
assertDateTime(helper.calculateNext(afterTime), 2000, Calendar.FEBRUARY, 6, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2000, Calendar.FEBRUARY, 6, 1, 15, 0);
// Last day of the month, check for rollover
afterTime = getDateTimeUTC(2000, Calendar.JANUARY, 31, 5, 0, 0);
assertDateTime(helper.calculateNext(afterTime), 2000, Calendar.FEBRUARY, 1, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2000, Calendar.FEBRUARY, 1, 1, 15, 0);
// Last day of the year, check for rollover
afterTime = getDateTimeUTC(2000, Calendar.DECEMBER, 31, 5, 0, 0);
assertDateTime(helper.calculateNext(afterTime), 2001, Calendar.JANUARY, 1, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2001, 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 testDailyWindowDuringTime.
@Test
public void testDailyWindowDuringTime() {
// Daily at 1:15am
ExecutionWindow window = createDailyWindow(1, 15);
setLengthInHours(window, 1);
ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
// Right at the start of the window
Calendar duringTime = getDateTimeUTC(2000, Calendar.JANUARY, 10, 1, 15, 0);
// Next will be the day after
assertDateTime(helper.calculateNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
// Current or next will be today
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2000, Calendar.JANUARY, 10, 1, 15, 0);
Assert.assertTrue(helper.isActive(duringTime));
// One minute after the start of the window
duringTime = getDateTimeUTC(2000, Calendar.JANUARY, 10, 1, 16, 0);
// Next will be the day after
assertDateTime(helper.calculateNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
// Current or next will be today
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2000, Calendar.JANUARY, 10, 1, 15, 0);
Assert.assertTrue(helper.isActive(duringTime));
// One minute before the end of the window
duringTime = getDateTimeUTC(2000, Calendar.JANUARY, 10, 2, 14, 0);
// Next will be the day after
assertDateTime(helper.calculateNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
// Current or next will be today
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2000, Calendar.JANUARY, 10, 1, 15, 0);
Assert.assertTrue(helper.isActive(duringTime));
// Right at the end of the window
duringTime = getDateTimeUTC(2000, Calendar.JANUARY, 10, 2, 15, 0);
// Next will be the day after
assertDateTime(helper.calculateNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
// Current or next will be tomorrow
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
Assert.assertFalse(helper.isActive(duringTime));
}
Aggregations