Search in sources :

Example 1 with DefaultClockImpl

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

the class AbstractPlaybackTest method initializeProcessEngine.

@Override
protected void initializeProcessEngine() {
    Clock clock = new DefaultClockImpl();
    ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
    processEngineConfiguration.setClock(clock);
    this.processEngine = (new RecordableProcessEngineFactory((ProcessEngineConfigurationImpl) processEngineConfiguration, listener)).getObject();
}
Also used : ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) DefaultClockImpl(org.activiti.engine.impl.util.DefaultClockImpl) ThreadLocalClock(org.activiti.crystalball.simulator.impl.clock.ThreadLocalClock) Clock(org.activiti.engine.runtime.Clock) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) RecordableProcessEngineFactory(org.activiti.crystalball.simulator.impl.RecordableProcessEngineFactory)

Example 2 with DefaultClockImpl

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

the class CycleBusinessCalendarTest method testSimpleCron.

public void testSimpleCron() throws Exception {
    Clock testingClock = new DefaultClockImpl();
    CycleBusinessCalendar businessCalendar = new CycleBusinessCalendar(testingClock);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy MM dd - HH:mm");
    Date now = simpleDateFormat.parse("2011 03 11 - 17:23");
    testingClock.setCurrentTime(now);
    Date duedate = businessCalendar.resolveDuedate("0 0 0 1 * ?");
    Date expectedDuedate = simpleDateFormat.parse("2011 04 1 - 00:00");
    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)

Example 3 with DefaultClockImpl

use of org.activiti.engine.impl.util.DefaultClockImpl 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 4 with DefaultClockImpl

use of org.activiti.engine.impl.util.DefaultClockImpl 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 5 with DefaultClockImpl

use of org.activiti.engine.impl.util.DefaultClockImpl 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)

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