Search in sources :

Example 6 with ExecutionWindow

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);
}
Also used : ExecutionWindowHelper(com.emc.storageos.db.client.util.ExecutionWindowHelper) ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow) Calendar(java.util.Calendar) Test(org.junit.Test)

Example 7 with ExecutionWindow

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;
}
Also used : ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow)

Example 8 with ExecutionWindow

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;
}
Also used : ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow)

Example 9 with ExecutionWindow

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));
}
Also used : ExecutionWindowHelper(com.emc.storageos.db.client.util.ExecutionWindowHelper) ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow) Calendar(java.util.Calendar) Test(org.junit.Test)

Example 10 with ExecutionWindow

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);
}
Also used : ExecutionWindowHelper(com.emc.storageos.db.client.util.ExecutionWindowHelper) ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow) Calendar(java.util.Calendar) Test(org.junit.Test)

Aggregations

ExecutionWindow (com.emc.storageos.db.client.model.uimodels.ExecutionWindow)25 ExecutionWindowHelper (com.emc.storageos.db.client.util.ExecutionWindowHelper)11 Test (org.junit.Test)11 Calendar (java.util.Calendar)10 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)3 BaseModelTest (com.emc.sa.model.BaseModelTest)2 Order (com.emc.storageos.db.client.model.uimodels.Order)2 URI (java.net.URI)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 ModelClient (com.emc.sa.model.dao.ModelClient)1 DbClient (com.emc.storageos.db.client.DbClient)1 TimeSeriesConstraint (com.emc.storageos.db.client.constraint.TimeSeriesConstraint)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 ScheduledEvent (com.emc.storageos.db.client.model.uimodels.ScheduledEvent)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1