private void verifyExecutedActivityParameterQueryInvocations() { Map<String, Date> startDateParameters = getCompleteExecutedActivityDateQueryParameters(); verify(mockedQuery).executedActivityBefore(startDateParameters.get(QUERY_PARAM_EXECUTED_ACTIVITY_BEFORE)); verify(mockedQuery).executedActivityAfter(startDateParameters.get(QUERY_PARAM_EXECUTED_ACTIVITY_AFTER)); verify(mockedQuery).list(); }
private void verifyStringExecutedActivityParameterQueryInvocations() { Map<String, String> startDateParameters = getCompleteExecutedActivityDateAsStringQueryParameters(); verify(mockedQuery).executedActivityBefore(DateTimeUtil.parseDate(startDateParameters.get(QUERY_PARAM_EXECUTED_ACTIVITY_BEFORE))); verify(mockedQuery).executedActivityAfter(DateTimeUtil.parseDate(startDateParameters.get(QUERY_PARAM_EXECUTED_ACTIVITY_AFTER))); verify(mockedQuery).list(); }
@Test public void testHistoricProcInstExecutedActivityBefore() { // given Calendar now = Calendar.getInstance(); ClockUtil.setCurrentTime(now.getTime()); BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().endEvent().done(); deployment(model); Calendar hourBeforeNow = (Calendar) now.clone(); hourBeforeNow.add(Calendar.HOUR, -1); runtimeService.startProcessInstanceByKey("proc"); //when query historic process instance which has executed an activity before the start time HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityBefore(now.getTime()).singleResult(); //then query returns result, since the query is less-then-equal assertNotNull(historicProcessInstance); //when query historic proc inst which executes an activity an hour before the starting time historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourBeforeNow.getTime()).singleResult(); //then query returns no result assertNull(historicProcessInstance); }
@Test public void testHistoricProcInstExecutedActivityWithEmptyInterval() { // given Calendar now = Calendar.getInstance(); ClockUtil.setCurrentTime(now.getTime()); BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().endEvent().done(); deployment(model); Calendar hourBeforeNow = (Calendar) now.clone(); hourBeforeNow.add(Calendar.HOUR, -1); runtimeService.startProcessInstanceByKey("proc"); //when query historic proc inst which executes an activity an hour before and after the starting time HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .executedActivityBefore(hourBeforeNow.getTime()) .executedActivityAfter(hourBeforeNow.getTime()).singleResult(); //then query returns no result assertNull(historicProcessInstance); }
historyService.createHistoricProcessInstanceQuery() .executedActivityAfter(now.getTime()) .executedActivityBefore(hourFromNow.getTime()) .singleResult(); historyService.createHistoricProcessInstanceQuery() .executedActivityAfter(hourFromNow.getTime()) .executedActivityBefore(sixHoursFromNow.getTime()) .singleResult();
@Test public void testHistoricProcInstExecutedActivityWithTwoProcInsts() { // given BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().endEvent().done(); deployment(model); Calendar now = Calendar.getInstance(); Calendar hourBeforeNow = (Calendar) now.clone(); hourBeforeNow.add(Calendar.HOUR, -1); ClockUtil.setCurrentTime(hourBeforeNow.getTime()); runtimeService.startProcessInstanceByKey("proc"); ClockUtil.setCurrentTime(now.getTime()); runtimeService.startProcessInstanceByKey("proc"); //when query execute activity between now and an hour ago List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery() .executedActivityAfter(hourBeforeNow.getTime()) .executedActivityBefore(now.getTime()).list(); //then two historic process instance have to be returned assertEquals(2, list.size()); //when query execute activity after an half hour before now Calendar halfHour = (Calendar) now.clone(); halfHour.add(Calendar.MINUTE, -30); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .executedActivityAfter(halfHour.getTime()).singleResult(); //then only the latest historic process instance is returned assertNotNull(historicProcessInstance); }
query.executedActivityBefore(executedActivityBefore);
query.executedActivityBefore(executedActivityBefore);
assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourAgo.getTime()).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourFromNow.getTime()).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityAfter(hourFromNow.getTime()).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourAgo.getTime()).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourFromNow.getTime()).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityAfter(hourFromNow.getTime()).count());
@Test public void testHistoricProcInstExecutedActivityBefore() { // given Calendar now = Calendar.getInstance(); ClockUtil.setCurrentTime(now.getTime()); BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().endEvent().done(); deployment(model); Calendar hourBeforeNow = (Calendar) now.clone(); hourBeforeNow.add(Calendar.HOUR, -1); runtimeService.startProcessInstanceByKey("proc"); //when query historic process instance which has executed an activity before the start time HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityBefore(now.getTime()).singleResult(); //then query returns result, since the query is less-then-equal assertNotNull(historicProcessInstance); //when query historic proc inst which executes an activity an hour before the starting time historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourBeforeNow.getTime()).singleResult(); //then query returns no result assertNull(historicProcessInstance); }
@Test public void testHistoricProcInstExecutedActivityWithEmptyInterval() { // given Calendar now = Calendar.getInstance(); ClockUtil.setCurrentTime(now.getTime()); BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().endEvent().done(); deployment(model); Calendar hourBeforeNow = (Calendar) now.clone(); hourBeforeNow.add(Calendar.HOUR, -1); runtimeService.startProcessInstanceByKey("proc"); //when query historic proc inst which executes an activity an hour before and after the starting time HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .executedActivityBefore(hourBeforeNow.getTime()) .executedActivityAfter(hourBeforeNow.getTime()).singleResult(); //then query returns no result assertNull(historicProcessInstance); }
historyService.createHistoricProcessInstanceQuery() .executedActivityAfter(now.getTime()) .executedActivityBefore(hourFromNow.getTime()) .singleResult(); historyService.createHistoricProcessInstanceQuery() .executedActivityAfter(hourFromNow.getTime()) .executedActivityBefore(sixHoursFromNow.getTime()) .singleResult();
@Test public void testHistoricProcInstExecutedActivityWithTwoProcInsts() { // given BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().endEvent().done(); deployment(model); Calendar now = Calendar.getInstance(); Calendar hourBeforeNow = (Calendar) now.clone(); hourBeforeNow.add(Calendar.HOUR, -1); ClockUtil.setCurrentTime(hourBeforeNow.getTime()); runtimeService.startProcessInstanceByKey("proc"); ClockUtil.setCurrentTime(now.getTime()); runtimeService.startProcessInstanceByKey("proc"); //when query execute activity between now and an hour ago List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery() .executedActivityAfter(hourBeforeNow.getTime()) .executedActivityBefore(now.getTime()).list(); //then two historic process instance have to be returned assertEquals(2, list.size()); //when query execute activity after an half hour before now Calendar halfHour = (Calendar) now.clone(); halfHour.add(Calendar.MINUTE, -30); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .executedActivityAfter(halfHour.getTime()).singleResult(); //then only the latest historic process instance is returned assertNotNull(historicProcessInstance); }
query.executedActivityBefore(executedActivityBefore);
assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourAgo.getTime()).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourFromNow.getTime()).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityAfter(hourFromNow.getTime()).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourAgo.getTime()).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourFromNow.getTime()).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityAfter(hourFromNow.getTime()).count());