Search in sources :

Example 11 with ExpirationTime

use of org.kie.kogito.jobs.ExpirationTime in project kogito-runtimes by kiegroup.

the class DeadlineHelperTest method testRepetitionWithEndDateAndLimit.

@Test
public void testRepetitionWithEndDateAndLimit() {
    Collection<DeadlineInfo<Map<String, Object>>> deadlines = DeadlineHelper.parseDeadlines("[subject:5secs]@[R2/PT5S/2021-03-18T18:55:01+01:00]");
    assertEquals(1, deadlines.size());
    DeadlineInfo<Map<String, Object>> deadlineInfo = deadlines.iterator().next();
    assertEquals("5secs", deadlineInfo.getNotification().get("subject"));
    Collection<ScheduleInfo> scheduling = deadlineInfo.getScheduleInfo();
    assertEquals(1, scheduling.size());
    ScheduleInfo scheduleInfo = scheduling.iterator().next();
    assertEquals(Duration.ofSeconds(5), scheduleInfo.getDuration());
    assertEquals(2, scheduleInfo.getNumRepetitions());
    assertEquals(ZonedDateTime.parse("2021-03-18T18:55:01+01:00"), scheduleInfo.getEndDate());
    assertNull(scheduleInfo.getStartDate());
    ExpirationTime time = DeadlineHelper.getExpirationTime(scheduleInfo);
    assertEquals(5000L, time.repeatInterval());
    assertEquals(2, time.repeatLimit());
    assertEqualsDate(ZonedDateTime.parse("2021-03-18T18:54:51+01:00"), time.get());
}
Also used : ExpirationTime(org.kie.kogito.jobs.ExpirationTime) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

ExpirationTime (org.kie.kogito.jobs.ExpirationTime)11 Map (java.util.Map)8 Test (org.junit.jupiter.api.Test)8 ZonedDateTime (java.time.ZonedDateTime)3 KogitoNodeInstance (org.kie.kogito.internal.process.runtime.KogitoNodeInstance)2 ExactExpirationTime (org.kie.kogito.jobs.ExactExpirationTime)2 JobsService (org.kie.kogito.jobs.JobsService)2 ProcessInstanceJobDescription (org.kie.kogito.jobs.ProcessInstanceJobDescription)2 ChronoUnit (java.time.temporal.ChronoUnit)1 Date (java.util.Date)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 InternalProcessRuntime (org.jbpm.process.instance.InternalProcessRuntime)1 ASYNC_WAITING (org.jbpm.ruleflow.core.Metadata.ASYNC_WAITING)1 NodeImpl (org.jbpm.workflow.core.impl.NodeImpl)1 NodeInstanceContainer (org.jbpm.workflow.instance.NodeInstanceContainer)1 EventNodeInstance (org.jbpm.workflow.instance.node.EventNodeInstance)1 Node (org.kie.api.definition.process.Node)1 NodeInstance (org.kie.api.runtime.process.NodeInstance)1 KogitoEventListener (org.kie.kogito.internal.process.event.KogitoEventListener)1