@Test public void testGetBinaryDataForNonExistingVariableInstance() { String nonExistingId = "nonExistingId"; when(variableInstanceQueryMock.variableId(nonExistingId)).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.singleResult()).thenReturn(null); given().pathParam("id", nonExistingId) .then().expect().statusCode(Status.NOT_FOUND.getStatusCode()) .body(containsString("Historic variable instance with Id 'nonExistingId' does not exist.")) .when().get(VARIABLE_INSTANCE_BINARY_DATA_URL); verify(variableInstanceQueryMock, never()).disableBinaryFetching(); }
public Void execute(CommandContext commandContext) { HistoricVariableInstanceEntity historicVariableInstanceEntity = (HistoricVariableInstanceEntity) historyService.createHistoricVariableInstanceQuery().singleResult(); commandContext.getDbEntityManager().delete(historicVariableInstanceEntity); return null; } });
public Void execute(CommandContext commandContext) { HistoricVariableInstanceEntity historicVariableInstanceEntity = (HistoricVariableInstanceEntity) historyService.createHistoricVariableInstanceQuery().singleResult(); commandContext.getDbEntityManager().delete(historicVariableInstanceEntity); return null; } });
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); }
public Void execute(CommandContext commandContext) { historyService.createHistoricVariableInstanceQuery() .singleResult() .getId(); // cache monitor.sync(); commandContext.getProcessEngineConfiguration() .getRuntimeService() .setVariable(processInstanceId, VARIABLE_NAME, ANOTHER_VARIABLE_VALUE); return null; }
public Void execute(CommandContext commandContext) { historyService.createHistoricVariableInstanceQuery() .singleResult() .getId(); // cache monitor.sync(); commandContext.getProcessEngineConfiguration() .getRuntimeService() .setVariable(processInstanceId, VARIABLE_NAME, ANOTHER_VARIABLE_VALUE); return null; }
@Test public void deleteHistoricVariableInstanceWithAuthenticatedTenant() { testRule.deployForTenant(TENANT_ONE, BPMN_ONETASK_PROCESS); String processInstanceId = startProcessInstance(null); runtimeService.setVariable(processInstanceId, "myVariable", "testValue"); HistoricVariableInstanceQuery variableQuery = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId); assertThat(variableQuery.count(), is(1L)); String variableInstanceId = variableQuery.singleResult().getId(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); historyService.deleteHistoricVariableInstance(variableInstanceId); assertThat(variableQuery.count(), is(0L)); cleanUpAfterVariableInstanceTest(processInstanceId); }
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); }
@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 public void testNestedJoinParallelGatewayLocalVariableOnLastJoiningExecution() { // when runtimeService.startProcessInstanceByKey("process"); // then assertEquals(0, runtimeService.createVariableInstanceQuery().count()); HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().singleResult(); assertNotNull(historicVariable); assertEquals("testVar", historicVariable.getName()); }
@Deployment public void testNestedJoinInclusiveGatewayLocalVariableOnLastJoiningExecution() { // when runtimeService.startProcessInstanceByKey("process"); // then assertEquals(0, runtimeService.createVariableInstanceQuery().count()); HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().singleResult(); assertNotNull(historicVariable); assertEquals("testVar", historicVariable.getName()); }
@Deployment public void testJoinParallelGatewayLocalVariableOnLastJoiningExecution() { // when runtimeService.startProcessInstanceByKey("process"); // then assertEquals(0, runtimeService.createVariableInstanceQuery().count()); HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().singleResult(); assertNotNull(historicVariable); assertEquals("testVar", historicVariable.getName()); }
@Deployment public void testJoinInclusiveGatewayLocalVariableOnLastJoiningExecution() { // when runtimeService.startProcessInstanceByKey("process"); // then assertEquals(0, runtimeService.createVariableInstanceQuery().count()); HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().singleResult(); assertNotNull(historicVariable); assertEquals("testVar", historicVariable.getName()); }
@Deployment public void testSetVariableOnServiceTaskInsideSubProcess() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("process"); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery(); assertEquals(1, query.count()); HistoricVariableInstance variable = query.singleResult(); // the variable is in the process instance scope assertEquals(pi.getId(), variable.getActivityInstanceId()); assertProcessEnded(pi.getId()); }
@Test public void testDeployProcessArchive() { // the process can successfully be executed ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess"); HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery() .processInstanceId(pi.getId()) .singleResult(); assertNotNull(variable); assertEquals("executed", variable.getName()); assertEquals(true, variable.getValue()); }
@Deployment public void testSetVariableOnServiceTaskInsideParallelBranch() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("process"); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery(); assertEquals(1, query.count()); HistoricVariableInstance variable = query.singleResult(); // the variable is in the process instance scope assertEquals(pi.getId(), variable.getActivityInstanceId()); assertProcessEnded(pi.getId()); }
public void testDeleteHistoricCaseVariableInstance() { // given createCaseInstanceByKey(CASE_KEY, getVariables()); disableAuthorization(); String variableInstanceId = historyService.createHistoricVariableInstanceQuery().singleResult().getId(); assertEquals(1L, historyService.createHistoricDetailQuery().count()); enableAuthorization(); // when historyService.deleteHistoricVariableInstance(variableInstanceId); // then verifyVariablesDeleted(); }
@Deployment(resources = {"org/camunda/bpm/engine/test/api/twoTasksProcess.bpmn20.xml"}) public void testQueryByProcessDefinitionKey() { // given runtimeService.startProcessInstanceByKey("twoTasksProcess", Variables.createVariables().putValue("initial", "foo")); // when HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery() .processDefinitionKey("twoTasksProcess").singleResult(); // then assertNotNull(variable); assertEquals("initial", variable.getName()); assertEquals("foo", variable.getValue()); }
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); }