Search in sources :

Example 16 with DefaultClockImpl

use of org.activiti.engine.impl.util.DefaultClockImpl in project Activiti by Activiti.

the class DurationHelperTest method shouldNotExceedNumberNegative.

@Test
public void shouldNotExceedNumberNegative() throws Exception {
    Clock testingClock = new DefaultClockImpl();
    testingClock.setCurrentTime(parse("19700101-00:00:00"));
    DurationHelper dh = new DurationHelper("R2/PT10S/1970-01-01T00:00:50", testingClock);
    testingClock.setCurrentTime(parse("19700101-00:00:20"));
    assertEquals(parse("19700101-00:00:30"), dh.getDateAfter());
    testingClock.setCurrentTime(parse("19700101-00:00:35"));
    assertEquals(parse("19700101-00:00:35"), dh.getDateAfter());
}
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 17 with DefaultClockImpl

use of org.activiti.engine.impl.util.DefaultClockImpl in project Activiti by Activiti.

the class DurationHelperTest method daylightSavingSpringObserved.

@Test
public void daylightSavingSpringObserved() throws Exception {
    Clock testingClock = new DefaultClockImpl();
    testingClock.setCurrentCalendar(parseCalendar("20140309-01:45:00", TimeZone.getTimeZone("US/Eastern")));
    DurationHelper dh = new DurationHelper("R2/2014-03-09T01:45:00/PT1H", testingClock);
    Calendar expected = parseCalendar("20140309-03:45:00", TimeZone.getTimeZone("US/Eastern"));
    assertEquals(expected, dh.getCalendarAfter());
}
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 18 with DefaultClockImpl

use of org.activiti.engine.impl.util.DefaultClockImpl in project Activiti by Activiti.

the class DurationHelperTest method daylightSavingSpring.

@Test
public void daylightSavingSpring() throws Exception {
    Clock testingClock = new DefaultClockImpl();
    testingClock.setCurrentCalendar(parseCalendar("20140309-05:45:00", TimeZone.getTimeZone("UTC")));
    DurationHelper dh = new DurationHelper("R2/2014-03-09T00:45:00-05:00/PT1H", testingClock);
    assertEquals(parseCalendar("20140309-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 19 with DefaultClockImpl

use of org.activiti.engine.impl.util.DefaultClockImpl in project Activiti by Activiti.

the class DurationHelperTest method daylightSavingFallObservedFirstHour.

@Test
public void daylightSavingFallObservedFirstHour() 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/PT1H", testingClock);
    Calendar expected = parseCalendarWithOffset("20131103-01:45:00 -04: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 20 with DefaultClockImpl

use of org.activiti.engine.impl.util.DefaultClockImpl in project Activiti by Activiti.

the class CycleBusinessCalendarTest method testSimpleDuration.

public void testSimpleDuration() throws Exception {
    Clock testingClock = new DefaultClockImpl();
    CycleBusinessCalendar businessCalendar = new CycleBusinessCalendar(testingClock);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy MM dd - HH:mm");
    Date now = simpleDateFormat.parse("2010 06 11 - 17:23");
    testingClock.setCurrentTime(now);
    Date duedate = businessCalendar.resolveDuedate("R/P2DT5H70M");
    Date expectedDuedate = simpleDateFormat.parse("2010 06 13 - 23:33");
    assertEquals(expectedDuedate, duedate);
}
Also used : DefaultClockImpl(org.activiti.engine.impl.util.DefaultClockImpl) CycleBusinessCalendar(org.activiti.engine.impl.calendar.CycleBusinessCalendar) Clock(org.activiti.engine.runtime.Clock) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

DefaultClockImpl (org.activiti.engine.impl.util.DefaultClockImpl)26 Clock (org.activiti.engine.runtime.Clock)26 DurationHelper (org.activiti.engine.impl.calendar.DurationHelper)14 Test (org.junit.Test)14 Calendar (java.util.Calendar)9 Date (java.util.Date)6 Task (org.activiti.engine.task.Task)6 GregorianCalendar (java.util.GregorianCalendar)5 ActivitiEvent (org.activiti.engine.delegate.event.ActivitiEvent)5 Job (org.activiti.engine.runtime.Job)5 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)5 SimpleDateFormat (java.text.SimpleDateFormat)3 ThreadLocalClock (org.activiti.crystalball.simulator.impl.clock.ThreadLocalClock)3 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)3 CycleBusinessCalendar (org.activiti.engine.impl.calendar.CycleBusinessCalendar)2 Deployment (org.activiti.engine.test.Deployment)2 HashMap (java.util.HashMap)1 RecordableProcessEngineFactory (org.activiti.crystalball.simulator.impl.RecordableProcessEngineFactory)1 ProcessEngineConfiguration (org.activiti.engine.ProcessEngineConfiguration)1 DurationBusinessCalendar (org.activiti.engine.impl.calendar.DurationBusinessCalendar)1