@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldResolveHistoricDecisionInstance() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask() .camundaDecisionRef("dish-decision") .endEvent().done()); // when runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list(); // assume assertThat(historicDecisionInstances.size(), is(3)); Date removalTime = addDays(START_DATE, 5); // then assertThat(historicDecisionInstances.get(0).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(1).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(2).getRemovalTime(), is(removalTime)); }
.camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask()
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldResolveHistoricDecisionInputInstance() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask() .camundaDecisionRef("dish-decision") .endEvent().done()); // when runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery() .rootDecisionInstancesOnly() .includeInputs() .singleResult(); // assume assertThat(historicDecisionInstance, notNullValue()); List<HistoricDecisionInputInstance> historicDecisionInputInstances = historicDecisionInstance.getInputs(); Date removalTime = addDays(START_DATE, 5); // then assertThat(historicDecisionInputInstances.get(0).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInputInstances.get(1).getRemovalTime(), is(removalTime)); }
/** * See https://app.camunda.com/jira/browse/CAM-9505 */ @Test public void shouldResolveExternalTaskLogWithTimestampPreserved() { // given testRule.deploy(Bpmn.createExecutableProcess("calledProcess") .startEvent() .serviceTask().camundaExternalTask("anExternalTaskTopic") .endEvent().done()); testRule.deploy(Bpmn.createExecutableProcess("callingProcess") .camundaHistoryTimeToLive(5) .startEvent() .callActivity() .calledElement("calledProcess") .endEvent().done()); ClockUtil.setCurrentTime(START_DATE); runtimeService.startProcessInstanceByKey("callingProcess"); LockedExternalTask externalTask = externalTaskService.fetchAndLock(1, "aWorkerId") .topic("anExternalTaskTopic", 3000) .execute() .get(0); // when externalTaskService.complete(externalTask.getId(), "aWorkerId"); List<HistoricExternalTaskLog> externalTaskLogs = historyService.createHistoricExternalTaskLogQuery().list(); // then assertThat(externalTaskLogs.get(0).getTimestamp(), is(START_DATE)); assertThat(externalTaskLogs.get(1).getTimestamp(), is(START_DATE)); }
@Test public void shouldCleanupExternalTaskLog() { // given testRule.deploy(Bpmn.createExecutableProcess("calledProcess") .startEvent() .serviceTask().camundaExternalTask("anExternalTaskTopic") .endEvent().done()); testRule.deploy(Bpmn.createExecutableProcess("callingProcess") .camundaHistoryTimeToLive(5) .startEvent() .callActivity() .calledElement("calledProcess") .endEvent().done()); runtimeService.startProcessInstanceByKey("callingProcess"); LockedExternalTask externalTask = externalTaskService.fetchAndLock(1, "aWorkerId") .topic("anExternalTaskTopic", 3000) .execute() .get(0); List<HistoricExternalTaskLog> externalTaskLogs = historyService.createHistoricExternalTaskLogQuery().list(); // assume assertThat(externalTaskLogs.size(), is(1)); ClockUtil.setCurrentTime(END_DATE); externalTaskService.complete(externalTask.getId(), "aWorkerId"); ClockUtil.setCurrentTime(addDays(END_DATE, 5)); // when runHistoryCleanup(); externalTaskLogs = historyService.createHistoricExternalTaskLogQuery().list(); // then assertThat(externalTaskLogs.size(), is(0)); }
.camundaHistoryTimeToLive(5) .startEvent() .callActivity()
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldResolveHistoricDecisionOutputInstance() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask() .camundaDecisionRef("dish-decision") .endEvent().done()); // when runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery() .rootDecisionInstancesOnly() .includeOutputs() .singleResult(); // assume assertThat(historicDecisionInstance, notNullValue()); List<HistoricDecisionOutputInstance> historicDecisionOutputInstances = historicDecisionInstance.getOutputs(); Date removalTime = addDays(START_DATE, 5); // then assertThat(historicDecisionOutputInstances.get(0).getRemovalTime(), is(removalTime)); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldResolveStandaloneHistoricDecisionOutputInstance() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask() .camundaDecisionRef("dish-decision") .endEvent().done()); // when runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery() .rootDecisionInstancesOnly() .includeOutputs() .singleResult(); // assume assertThat(historicDecisionInstance, notNullValue()); List<HistoricDecisionOutputInstance> historicDecisionOutputInstances = historicDecisionInstance.getOutputs(); Date removalTime = addDays(START_DATE, 5); // then assertThat(historicDecisionOutputInstances.get(0).getRemovalTime(), is(removalTime)); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/api/history/testDmnWithPojo.dmn11.xml" }) public void shouldResolveByteArray_DecisionInput() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask().camundaDecisionRef("testDecision") .endEvent().done()); // when ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("pojo", new TestPojo("okay", 13.37))); HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery() .rootDecisionInstancesOnly() .includeInputs() .singleResult(); // assume assertThat(historicDecisionInstance, notNullValue()); HistoricDecisionInputInstanceEntity historicDecisionInputInstanceEntity = (HistoricDecisionInputInstanceEntity) historicDecisionInstance.getInputs().get(0); ByteArrayEntity byteArrayEntity = findByteArrayById(historicDecisionInputInstanceEntity.getByteArrayValueId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArrayEntity.getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveExternalTaskLog() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess("calledProcess") .startEvent() .serviceTask().camundaExternalTask("anExternalTaskTopic") .endEvent().done()); testRule.deploy(Bpmn.createExecutableProcess("callingProcess") .camundaHistoryTimeToLive(5) .startEvent() .callActivity() .calledElement("calledProcess") .endEvent().done()); // when runtimeService.startProcessInstanceByKey("callingProcess"); HistoricExternalTaskLog externalTaskLog = historyService.createHistoricExternalTaskLogQuery().singleResult(); // assume assertThat(externalTaskLog, notNullValue()); Date removalTime = addDays(START_DATE, 5); // then assertThat(externalTaskLog.getRemovalTime(), is(removalTime)); }
@Test @Deployment( resources = { "org/camunda/bpm/engine/test/api/history/removaltime/HistoricRootProcessInstanceTest.shouldResolveByteArray_DecisionOutputLiteralExpression.dmn" }) public void shouldResolveByteArray_DecisionOutputLiteralExpression() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask().camundaDecisionRef("testDecision") .endEvent().done()); // when ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("pojo", new TestPojo("okay", 13.37))); HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery() .rootDecisionInstancesOnly() .includeOutputs() .singleResult(); // assume assertThat(historicDecisionInstance, notNullValue()); HistoricDecisionOutputInstanceEntity historicDecisionOutputInstanceEntity = (HistoricDecisionOutputInstanceEntity) historicDecisionInstance.getOutputs().get(0); ByteArrayEntity byteArrayEntity = findByteArrayById(historicDecisionOutputInstanceEntity.getByteArrayValueId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArrayEntity.getRemovalTime(), is(removalTime)); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/api/history/testDmnWithPojo.dmn11.xml" }) public void shouldResolveByteArray_DecisionOutput() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask().camundaDecisionRef("testDecision") .endEvent().done()); // when ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("pojo", new TestPojo("okay", 13.37))); HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery() .rootDecisionInstancesOnly() .includeOutputs() .singleResult(); // assume assertThat(historicDecisionInstance, notNullValue()); HistoricDecisionOutputInstanceEntity historicDecisionOutputInstanceEntity = (HistoricDecisionOutputInstanceEntity) historicDecisionInstance.getOutputs().get(0); ByteArrayEntity byteArrayEntity = findByteArrayById(historicDecisionOutputInstanceEntity.getByteArrayValueId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArrayEntity.getRemovalTime(), is(removalTime)); } @Test
@Test public void shouldResolveByteArray_ExternalTaskLog() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess("calledProcess") .startEvent() .serviceTask().camundaExternalTask("aTopicName") .endEvent().done()); testRule.deploy(Bpmn.createExecutableProcess("callingProcess") .camundaHistoryTimeToLive(5) .startEvent() .callActivity() .calledElement("calledProcess") .endEvent().done()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callingProcess"); List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(5, "aWorkerId") .topic("aTopicName", Integer.MAX_VALUE) .execute(); // when externalTaskService.handleFailure(tasks.get(0).getId(), "aWorkerId", null, "errorDetails", 5, 3000L); HistoricExternalTaskLogEntity externalTaskLog = (HistoricExternalTaskLogEntity) historyService.createHistoricExternalTaskLogQuery() .failureLog() .singleResult(); // assume assertThat(externalTaskLog, notNullValue()); ByteArrayEntity byteArrayEntity = findByteArrayById(externalTaskLog.getErrorDetailsByteArrayId()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArrayEntity.getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveUserOperationLog_SetExternalTaskRetries() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess("calledProcess") .startEvent() .serviceTask().camundaExternalTask("anExternalTaskTopic") .endEvent().done()); testRule.deploy(Bpmn.createExecutableProcess("callingProcess") .camundaHistoryTimeToLive(5) .startEvent() .callActivity() .calledElement("calledProcess") .endEvent().done()); runtimeService.startProcessInstanceByKey("callingProcess"); // when identityService.setAuthenticatedUserId("aUserId"); externalTaskService.setRetries(externalTaskService.createExternalTaskQuery().singleResult().getId(), 65); identityService.clearAuthentication(); UserOperationLogEntry userOperationLog = historyService.createUserOperationLogQuery().singleResult(); // assume assertThat(userOperationLog, notNullValue()); Date removalTime = addDays(START_DATE, 5); // then assertThat(userOperationLog.getRemovalTime(), is(removalTime)); }
@Test public void shouldScheduleToNow() { // given testRule.deploy(Bpmn.createExecutableProcess("process") .camundaHistoryTimeToLive(5) .startEvent() .serviceTask().camundaExternalTask("anExternalTaskTopic") .multiInstance() .cardinality("5") .multiInstanceDone() .endEvent().done()); ClockUtil.setCurrentTime(END_DATE); runtimeService.startProcessInstanceByKey("process"); for (int i = 0; i < 5; i++) { LockedExternalTask externalTask = externalTaskService.fetchAndLock(1, "aWorkerId") .topic("anExternalTaskTopic", 2000) .execute() .get(0); externalTaskService.complete(externalTask.getId(), "aWorkerId"); } engineConfiguration.setHistoryCleanupBatchSize(5); engineConfiguration.initHistoryCleanup(); Date removalTime = addDays(END_DATE, 5); ClockUtil.setCurrentTime(removalTime); // when runHistoryCleanup(); Job job = historyService.findHistoryCleanupJobs().get(0); // then assertThat(job.getDuedate(), is(removalTime)); }
@Test public void shouldScheduleToLater() { // given testRule.deploy(Bpmn.createExecutableProcess("process") .camundaHistoryTimeToLive(5) .startEvent() .serviceTask().camundaExternalTask("anExternalTaskTopic") .multiInstance() .cardinality("5") .multiInstanceDone() .endEvent().done()); ClockUtil.setCurrentTime(END_DATE); runtimeService.startProcessInstanceByKey("process"); for (int i = 0; i < 5; i++) { LockedExternalTask externalTask = externalTaskService.fetchAndLock(1, "aWorkerId") .topic("anExternalTaskTopic", 2000) .execute() .get(0); externalTaskService.complete(externalTask.getId(), "aWorkerId"); } engineConfiguration.setHistoryCleanupBatchSize(6); engineConfiguration.initHistoryCleanup(); Date removalTime = addDays(END_DATE, 5); ClockUtil.setCurrentTime(removalTime); // when runHistoryCleanup(); Job job = historyService.findHistoryCleanupJobs().get(0); // then assertThat(job.getDuedate(), is(addSeconds(removalTime, START_DELAY))); }
.camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask().camundaDecisionRef("testDecision")
.camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask().camundaDecisionRef("testDecision")
.camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask().camundaDecisionRef("testDecision")
.camundaHistoryTimeToLive(5) .startEvent() .callActivity()