Search in sources :

Example 1 with DurationHelper

use of org.activiti.engine.impl.calendar.DurationHelper in project Activiti by Activiti.

the class DurationHelperTest method daylightSavingFallObservedSecondHour.

@Test
public void daylightSavingFallObservedSecondHour() throws Exception {
    Clock testingClock = new DefaultClockImpl();
    testingClock.setCurrentCalendar(parseCalendar("20131103-00:45:00", TimeZone.getTimeZone("US/Eastern")));
    DurationHelper dh = new DurationHelper("R2/2013-11-03T00:45:00-04:00/PT2H", testingClock);
    Calendar expected = parseCalendarWithOffset("20131103-01:45:00 -05:00", TimeZone.getTimeZone("US/Eastern"));
    assertTrue(expected.compareTo(dh.getCalendarAfter()) == 0);
}
Also used : DefaultClockImpl(org.activiti.engine.impl.util.DefaultClockImpl) DurationHelper(org.activiti.engine.impl.calendar.DurationHelper) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) Clock(org.activiti.engine.runtime.Clock) Test(org.junit.Test)

Example 2 with DurationHelper

use of org.activiti.engine.impl.calendar.DurationHelper in project Activiti by Activiti.

the class DurationHelperTest method shouldNotExceedNumber.

@Test
public void shouldNotExceedNumber() throws Exception {
    Clock testingClock = new DefaultClockImpl();
    testingClock.setCurrentTime(new Date(0));
    DurationHelper dh = new DurationHelper("R2/PT10S", testingClock);
    testingClock.setCurrentTime(new Date(15000));
    assertEquals(20000, dh.getDateAfter().getTime());
    testingClock.setCurrentTime(new Date(30000));
    assertEquals(30000, dh.getDateAfter().getTime());
}
Also used : DefaultClockImpl(org.activiti.engine.impl.util.DefaultClockImpl) DurationHelper(org.activiti.engine.impl.calendar.DurationHelper) Clock(org.activiti.engine.runtime.Clock) Date(java.util.Date) Test(org.junit.Test)

Example 3 with DurationHelper

use of org.activiti.engine.impl.calendar.DurationHelper in project Activiti by Activiti.

the class DurationHelperTest method daylightSavingFallSecondHour.

@Test
public void daylightSavingFallSecondHour() throws Exception {
    Clock testingClock = new DefaultClockImpl();
    testingClock.setCurrentCalendar(parseCalendar("20131103-06:45:00", TimeZone.getTimeZone("UTC")));
    Calendar easternTime = testingClock.getCurrentCalendar(TimeZone.getTimeZone("US/Eastern"));
    DurationHelper dh = new DurationHelper("R2/2013-11-03T01:45:00-05:00/PT1H", testingClock);
    assertEquals(parseCalendar("20131103-07:45:00", TimeZone.getTimeZone("UTC")), dh.getCalendarAfter(easternTime));
}
Also used : DefaultClockImpl(org.activiti.engine.impl.util.DefaultClockImpl) DurationHelper(org.activiti.engine.impl.calendar.DurationHelper) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) Clock(org.activiti.engine.runtime.Clock) Test(org.junit.Test)

Example 4 with DurationHelper

use of org.activiti.engine.impl.calendar.DurationHelper in project Activiti by Activiti.

the class DurationHelperTest method daylightSavingFall.

@Test
public void daylightSavingFall() throws Exception {
    Clock testingClock = new DefaultClockImpl();
    testingClock.setCurrentCalendar(parseCalendar("20131103-04:45:00", TimeZone.getTimeZone("UTC")));
    DurationHelper dh = new DurationHelper("R2/2013-11-03T00:45:00-04:00/PT1H", testingClock);
    assertEquals(parseCalendar("20131103-05:45:00", TimeZone.getTimeZone("UTC")), dh.getCalendarAfter(testingClock.getCurrentCalendar(TimeZone.getTimeZone("US/Eastern"))));
    testingClock.setCurrentCalendar(parseCalendar("20131103-05:45:00", TimeZone.getTimeZone("UTC")));
    assertEquals(parseCalendar("20131103-06:45:00", TimeZone.getTimeZone("UTC")), dh.getCalendarAfter(testingClock.getCurrentCalendar(TimeZone.getTimeZone("US/Eastern"))));
}
Also used : DefaultClockImpl(org.activiti.engine.impl.util.DefaultClockImpl) DurationHelper(org.activiti.engine.impl.calendar.DurationHelper) Clock(org.activiti.engine.runtime.Clock) Test(org.junit.Test)

Example 5 with DurationHelper

use of org.activiti.engine.impl.calendar.DurationHelper in project Activiti by Activiti.

the class DurationHelperTest method daylightSaving25HourDayEurope.

@Test
public void daylightSaving25HourDayEurope() throws Exception {
    Clock testingClock = new DefaultClockImpl();
    testingClock.setCurrentCalendar(parseCalendar("20131027-00:00:00", TimeZone.getTimeZone("Europe/Amsterdam")));
    DurationHelper dh = new DurationHelper("R2/2013-10-27T00:00:00/P1D", testingClock);
    assertEquals(parseCalendar("20131028-00:00:00", TimeZone.getTimeZone("Europe/Amsterdam")), dh.getCalendarAfter(testingClock.getCurrentCalendar()));
}
Also used : DefaultClockImpl(org.activiti.engine.impl.util.DefaultClockImpl) DurationHelper(org.activiti.engine.impl.calendar.DurationHelper) Clock(org.activiti.engine.runtime.Clock) Test(org.junit.Test)

Aggregations

DurationHelper (org.activiti.engine.impl.calendar.DurationHelper)15 DefaultClockImpl (org.activiti.engine.impl.util.DefaultClockImpl)14 Clock (org.activiti.engine.runtime.Clock)14 Test (org.junit.Test)14 Calendar (java.util.Calendar)5 GregorianCalendar (java.util.GregorianCalendar)5 Date (java.util.Date)1 ActivitiException (org.activiti.engine.ActivitiException)1 ProcessEngineConfiguration (org.activiti.engine.ProcessEngineConfiguration)1 ActivitiEventDispatcher (org.activiti.engine.delegate.event.ActivitiEventDispatcher)1 TransactionContext (org.activiti.engine.impl.cfg.TransactionContext)1 JobAddedNotification (org.activiti.engine.impl.jobexecutor.JobAddedNotification)1 JobExecutor (org.activiti.engine.impl.jobexecutor.JobExecutor)1 JobEntity (org.activiti.engine.impl.persistence.entity.JobEntity)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1