private void verifyStringParameterQueryInvocations() { Map<String, String> stringQueryParameters = getCompleteStringQueryParameters(); verify(mockedQuery).processInstanceId(stringQueryParameters.get("processInstanceId")); verify(mockedQuery).variableName(stringQueryParameters.get("variableName")); verify(mockedQuery).variableValueEquals(stringQueryParameters.get("variableName"), stringQueryParameters.get("variableValue")); }
public void execute(DelegateExecution execution) throws Exception { HistoryService historyService = execution.getProcessEngineServices().getHistoryService(); HistoricVariableInstance variableInstance = historyService .createHistoricVariableInstanceQuery() .variableName("listVar") .singleResult(); List<String> list = (List<String>) variableInstance.getValue(); // implicit update of the list, should not trigger an update // of the value since we deal with historic variables list.add(NEW_ELEMENT); }
@Test @Deployment(resources={"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testHistoricDetailQueryByVariableInstanceId() throws Exception { Map<String, Object> params = new HashMap<String, Object>(); params.put("testVar", "testValue"); runtimeService.startProcessInstanceByKey("oneTaskProcess", params); HistoricVariableInstance testVariable = historyService.createHistoricVariableInstanceQuery() .variableName("testVar") .singleResult(); HistoricDetailQuery query = historyService.createHistoricDetailQuery(); query.variableInstanceId(testVariable.getId()); assertEquals(1, query.count()); assertEquals(1, query.list().size()); }
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventTest.testCompensationInEventSubProcessActivityRef.bpmn20.xml" }) public void testCompensateActivityRefInEventSubprocess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess"); assertProcessEnded(processInstance.getId()); HistoricVariableInstanceQuery historicVariableInstanceQuery = historyService.createHistoricVariableInstanceQuery().variableName("undoBookSecondHotel"); if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) { assertEquals(1, historicVariableInstanceQuery.count()); assertEquals("undoBookSecondHotel", historicVariableInstanceQuery.list().get(0).getVariableName()); assertEquals(5, historicVariableInstanceQuery.list().get(0).getValue()); assertEquals(0, historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("undoBookFlight").count()); assertEquals(0, historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("undoBookHotel").count()); } }
public void testBinaryFetchingEnabled() { // by default, binary fetching is enabled Task newTask = taskService.newTask(); taskService.saveTask(newTask); String variableName = "binaryVariableName"; taskService.setVariable(newTask.getId(), variableName, "some bytes".getBytes()); HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery() .variableName(variableName) .singleResult(); assertNotNull(variableInstance.getValue()); taskService.deleteTask(newTask.getId(), true); }
public void testBinaryFetchingDisabled() { Task newTask = taskService.newTask(); taskService.saveTask(newTask); String variableName = "binaryVariableName"; taskService.setVariable(newTask.getId(), variableName, "some bytes".getBytes()); HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery() .variableName(variableName) .disableBinaryFetching() .singleResult(); assertNull(variableInstance.getValue()); taskService.deleteTask(newTask.getId(), true); }
public void execute(DelegateExecution execution) throws Exception { HistoryService historyService = execution.getProcessEngineServices().getHistoryService(); HistoricVariableInstance variableInstance = historyService .createHistoricVariableInstanceQuery() .variableName("listVar") .singleResult(); HistoricVariableUpdate initialUpdate = (HistoricVariableUpdate) historyService .createHistoricDetailQuery() .variableUpdates() .variableInstanceId(variableInstance.getId()) .orderPartiallyByOccurrence().asc() .list() .get(0); List<String> list = (List<String>) initialUpdate.getValue(); // implicit update of the list, should not trigger an update // of the value since we deal with historic variables list.add(NEW_ELEMENT); }
@Deployment(resources = { DEFAULT_MAPPING_BPMN, TEST_DECISION }) public void testTransientDecisionResult() { // when a decision is evaluated and the result is stored in a transient variable "decisionResult" ProcessInstance processInstance = startTestProcess("single entry"); // then the variable should not be available outside the business rule task assertNull(runtimeService.getVariable(processInstance.getId(), "decisionResult")); // and should not create an entry in history since it is not persistent assertNull(historyService.createHistoricVariableInstanceQuery().variableName("decisionResult").singleResult()); }
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventTest.testCompensationTriggeredByEventSubProcessActivityRef.bpmn20.xml" }) public void testCompensateActivityRefTriggeredByEventSubprocess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess"); assertProcessEnded(processInstance.getId()); HistoricVariableInstanceQuery historicVariableInstanceQuery = historyService.createHistoricVariableInstanceQuery() .processInstanceId(processInstance.getId()).variableName("undoBookHotel"); if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) { assertEquals(1, historicVariableInstanceQuery.count()); assertEquals("undoBookHotel", historicVariableInstanceQuery.list().get(0).getVariableName()); assertEquals(5, historicVariableInstanceQuery.list().get(0).getValue()); assertEquals(0, historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("undoBookFlight").count()); } }
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventTest.testCompensationTriggeredByEventSubProcessInSubProcessActivityRef.bpmn20.xml" }) public void testCompensateActivityRefTriggeredByEventSubprocessInSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess"); assertProcessEnded(processInstance.getId()); HistoricVariableInstanceQuery historicVariableInstanceQuery = historyService.createHistoricVariableInstanceQuery() .processInstanceId(processInstance.getId()).variableName("undoBookHotel"); if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) { assertEquals(1, historicVariableInstanceQuery.count()); assertEquals("undoBookHotel", historicVariableInstanceQuery.list().get(0).getVariableName()); assertEquals(5, historicVariableInstanceQuery.list().get(0).getValue()); assertEquals(0, historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("undoBookFlight").count()); } }
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcessWithIoMappings.bpmn20.xml" }) @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) @Test public void testDeleteProcessInstanceWithoutSkipIoMappings() { // given a process instance ProcessInstance instance = runtimeService.startProcessInstanceByKey("ioMappingProcess"); // when the process instance is deleted and we do not skip the io mappings runtimeService.deleteProcessInstance(instance.getId(), null, false, true, false); // then testRule.assertProcessEnded(instance.getId()); assertEquals(2, historyService.createHistoricVariableInstanceQuery().processInstanceId(instance.getId()).list().size()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("inputMappingExecuted").count()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("outputMappingExecuted").count()); }
/** * CAM-3708 */ @Deployment public void testDeleteInScopeShouldNotInvokeOutputMapping() { // given ProcessInstance instance = runtimeService.startProcessInstanceByKey("asyncOutputMappingSubProcess"); assertEquals(1, managementService.createJobQuery().count()); // when runtimeService.deleteProcessInstance(instance.getId(), ""); // then if (processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_AUDIT.getId()) { // the output mapping of the task has not been executed because the // activity was not active yet assertEquals(0, historyService.createHistoricVariableInstanceQuery().variableName("taskOutputMappingExecuted").count()); // but the containing sub process output mapping was executed assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("subProcessOutputMappingExecuted").count()); } }
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) @Deployment public void testNonInterruptingVariableConditionWithHistory() { // given process with event sub process conditional start event ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY, Variables.createVariables() .putValue(VARIABLE_NAME, 1) .putValue("donotloseme", "here")); // assume tasksAfterVariableIsSet = taskService.createTaskQuery().processInstanceId(procInst.getId()).list(); assertEquals(2, tasksAfterVariableIsSet.size()); assertEquals(1, conditionEventSubscriptionQuery.list().size()); // then assertEquals(2, historyService.createHistoricVariableInstanceQuery().count()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName(VARIABLE_NAME).count()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("donotloseme").count()); } }
public void testTaskIdProperty() { // given String taskId = "myTask"; Task task = taskService.newTask(taskId); taskService.saveTask(task); taskService.setVariable(taskId, "aVariable", "anotherValue"); // when HistoricVariableInstance instance = historyService .createHistoricVariableInstanceQuery() .taskIdIn(taskId) .variableName("aVariable") .singleResult(); // then assertEquals(taskId, instance.getTaskId()); taskService.deleteTask(taskId, true); }
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) @Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/conditional/EventSubProcessStartConditionalEventTest.testVariableCondition.bpmn20.xml") public void testVariableConditionWithHistory() { // given process with event sub process conditional start event ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY, Variables.createVariables() .putValue(VARIABLE_NAME, 1) .putValue("donotloseme", "here")); // assume tasksAfterVariableIsSet = taskService.createTaskQuery().processInstanceId(procInst.getId()).list(); assertEquals(1, tasksAfterVariableIsSet.size()); // then assertEquals(2, historyService.createHistoricVariableInstanceQuery().count()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName(VARIABLE_NAME).count()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("donotloseme").count()); }
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/RuntimeServiceTest.testCascadingDeleteSubprocessInstanceSkipIoMappings.Calling.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/RuntimeServiceTest.testCascadingDeleteSubprocessInstanceSkipIoMappings.Called.bpmn20.xml" }) @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) @Test public void testCascadingDeleteSubprocessInstanceWithoutSkipIoMappings() { // given a process instance ProcessInstance instance = runtimeService.startProcessInstanceByKey("callingProcess"); ProcessInstance instance2 = runtimeService.createProcessInstanceQuery().superProcessInstanceId(instance.getId()).singleResult(); // when the process instance is deleted and we do not skip the io mappings runtimeService.deleteProcessInstance(instance.getId(), "test_purposes", false, true, false); // then testRule.assertProcessEnded(instance.getId()); assertEquals(2, historyService.createHistoricVariableInstanceQuery().processInstanceId(instance2.getId()).list().size()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("inputMappingExecuted").count()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("outputMappingExecuted").count()); }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/oneTaskProcessWithIoMappings.bpmn20.xml" }) @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) @Test public void testDeleteProcessInstanceSkipIoMappings() { // given a process instance ProcessInstance instance = runtimeService.startProcessInstanceByKey("ioMappingProcess"); // when the process instance is deleted and we do skip the io mappings runtimeService.deleteProcessInstance(instance.getId(), null, false, true, true); // then testRule.assertProcessEnded(instance.getId()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().processInstanceId(instance.getId()).list().size()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("inputMappingExecuted").count()); }
public void testErrorMessage() { Task newTask = taskService.newTask(); taskService.saveTask(newTask); String variableName = "failingSerializable"; taskService.setVariable(newTask.getId(), variableName, new FailingSerializable()); HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery() .variableName(variableName) .singleResult(); assertNull(variableInstance.getValue()); assertNotNull(variableInstance.getErrorMessage()); taskService.deleteTask(newTask.getId(), true); }
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/RuntimeServiceTest.testCascadingDeleteSubprocessInstanceSkipIoMappings.Calling.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/RuntimeServiceTest.testCascadingDeleteSubprocessInstanceSkipIoMappings.Called.bpmn20.xml" }) @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) @Test public void testCascadingDeleteSubprocessInstanceSkipIoMappings() { // given a process instance ProcessInstance instance = runtimeService.startProcessInstanceByKey("callingProcess"); ProcessInstance instance2 = runtimeService.createProcessInstanceQuery().superProcessInstanceId(instance.getId()).singleResult(); // when the process instance is deleted and we do skip the io mappings runtimeService.deleteProcessInstance(instance.getId(), "test_purposes", false, true, true); // then testRule.assertProcessEnded(instance.getId()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().processInstanceId(instance2.getId()).list().size()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("inputMappingExecuted").count()); }
@Test @Deployment public void testScriptListener() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); assertTrue(processInstance.isEnded()); if (processEngineRule.getProcessEngineConfiguration().getHistoryLevel().getId() >= HISTORYLEVEL_AUDIT) { HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery(); long count = query.count(); assertEquals(5, count); HistoricVariableInstance variableInstance = null; String[] variableNames = new String[]{"start-start", "start-end", "start-take", "end-start", "end-end"}; for (String variableName : variableNames) { variableInstance = query.variableName(variableName).singleResult(); assertNotNull("Unable ot find variable with name '" + variableName + "'", variableInstance); assertTrue("Variable '" + variableName + "' should be set to true", (Boolean) variableInstance.getValue()); } } }