public static HalVariableValue generateVariableValue(VariableInstance variableInstance, String variableScopeId) { if (variableScopeId.equals(variableInstance.getTaskId())) { return generateTaskVariableValue(variableInstance, variableScopeId); } else if (variableScopeId.equals(variableInstance.getProcessInstanceId())) { return generateProcessInstanceVariableValue(variableInstance, variableScopeId); } else if (variableScopeId.equals(variableInstance.getExecutionId())) { return generateExecutionVariableValue(variableInstance, variableScopeId); } else if (variableScopeId.equals(variableInstance.getCaseInstanceId())) { return generateCaseInstanceVariableValue(variableInstance, variableScopeId); } else if (variableScopeId.equals(variableInstance.getCaseExecutionId())) { return generateCaseExecutionVariableValue(variableInstance, variableScopeId); } else { throw new RestException("Variable scope id '" + variableScopeId + "' does not match with variable instance '" + variableInstance + "'"); } }
public static HalVariableValue generateVariableValue(VariableInstance variableInstance, String variableScopeId) { if (variableScopeId.equals(variableInstance.getTaskId())) { return generateTaskVariableValue(variableInstance, variableScopeId); } else if (variableScopeId.equals(variableInstance.getProcessInstanceId())) { return generateProcessInstanceVariableValue(variableInstance, variableScopeId); } else if (variableScopeId.equals(variableInstance.getExecutionId())) { return generateExecutionVariableValue(variableInstance, variableScopeId); } else if (variableScopeId.equals(variableInstance.getCaseInstanceId())) { return generateCaseInstanceVariableValue(variableInstance, variableScopeId); } else if (variableScopeId.equals(variableInstance.getCaseExecutionId())) { return generateCaseExecutionVariableValue(variableInstance, variableScopeId); } else { throw new RestException("Variable scope id '" + variableScopeId + "' does not match with variable instance '" + variableInstance + "'"); } }
protected <T extends VariableInstance> T build(T mockVariable) { when(mockVariable.getId()).thenReturn(id); when(mockVariable.getName()).thenReturn(name); when(mockVariable.getTypeName()).thenReturn(typedValue.getType().getName()); if (ObjectValue.class.isAssignableFrom(typedValue.getClass())) { ObjectValue objectValue = (ObjectValue) typedValue; if (objectValue.isDeserialized()) { when(mockVariable.getValue()).thenReturn(typedValue.getValue()); } else { when(mockVariable.getValue()).thenReturn(null); } } else { when(mockVariable.getValue()).thenReturn(typedValue.getValue()); } when(mockVariable.getTypedValue()).thenReturn(typedValue); when(mockVariable.getProcessInstanceId()).thenReturn(processInstanceId); when(mockVariable.getExecutionId()).thenReturn(executionId); when(mockVariable.getCaseInstanceId()).thenReturn(caseInstanceId); when(mockVariable.getCaseExecutionId()).thenReturn(caseExecutionId); when(mockVariable.getTaskId()).thenReturn(taskId); when(mockVariable.getActivityInstanceId()).thenReturn(activityInstanceId); when(mockVariable.getTenantId()).thenReturn(tenantId); when(mockVariable.getErrorMessage()).thenReturn(errorMessage); return mockVariable; }
public static DelegateCaseVariableInstanceImpl fromVariableInstance(VariableInstance variableInstance) { DelegateCaseVariableInstanceImpl delegateInstance = new DelegateCaseVariableInstanceImpl(); delegateInstance.variableId = variableInstance.getId(); delegateInstance.processInstanceId = variableInstance.getProcessInstanceId(); delegateInstance.executionId = variableInstance.getExecutionId(); delegateInstance.caseExecutionId = variableInstance.getCaseExecutionId(); delegateInstance.caseInstanceId = variableInstance.getCaseInstanceId(); delegateInstance.taskId = variableInstance.getTaskId(); delegateInstance.activityInstanceId = variableInstance.getActivityInstanceId(); delegateInstance.tenantId = variableInstance.getTenantId(); delegateInstance.errorMessage = variableInstance.getErrorMessage(); delegateInstance.name = variableInstance.getName(); delegateInstance.value = variableInstance.getTypedValue(); return delegateInstance; }
public static DelegateCaseVariableInstanceImpl fromVariableInstance(VariableInstance variableInstance) { DelegateCaseVariableInstanceImpl delegateInstance = new DelegateCaseVariableInstanceImpl(); delegateInstance.variableId = variableInstance.getId(); delegateInstance.processInstanceId = variableInstance.getProcessInstanceId(); delegateInstance.executionId = variableInstance.getExecutionId(); delegateInstance.caseExecutionId = variableInstance.getCaseExecutionId(); delegateInstance.caseInstanceId = variableInstance.getCaseInstanceId(); delegateInstance.taskId = variableInstance.getTaskId(); delegateInstance.activityInstanceId = variableInstance.getActivityInstanceId(); delegateInstance.tenantId = variableInstance.getTenantId(); delegateInstance.errorMessage = variableInstance.getErrorMessage(); delegateInstance.name = variableInstance.getName(); delegateInstance.value = variableInstance.getTypedValue(); return delegateInstance; }
@Test @Deployment(resources = SINGLE_CONDITIONAL_START_EVENT_XML) public void testStartInstanceWithVariableCondition() { // given a deployed process // when List<ProcessInstance> instances = runtimeService .createConditionEvaluation() .setVariable("foo", 1) .evaluateStartConditions(); // then assertEquals(1, instances.size()); VariableInstance vars = runtimeService.createVariableInstanceQuery().singleResult(); assertEquals(vars.getProcessInstanceId(), instances.get(0).getId()); assertEquals(1, vars.getValue()); }
public static VariableInstanceDto fromVariableInstance(VariableInstance variableInstance) { VariableInstanceDto dto = new VariableInstanceDto(); dto.id = variableInstance.getId(); dto.name = variableInstance.getName(); dto.processInstanceId = variableInstance.getProcessInstanceId(); dto.executionId = variableInstance.getExecutionId(); dto.caseExecutionId = variableInstance.getCaseExecutionId(); dto.caseInstanceId = variableInstance.getCaseInstanceId(); dto.taskId = variableInstance.getTaskId(); dto.activityInstanceId = variableInstance.getActivityInstanceId(); dto.tenantId = variableInstance.getTenantId(); if(variableInstance.getErrorMessage() == null) { VariableValueDto.fromTypedValue(dto, variableInstance.getTypedValue()); } else { dto.errorMessage = variableInstance.getErrorMessage(); dto.type = VariableValueDto.toRestApiTypeName(variableInstance.getTypeName()); } return dto; }
public void testProcessVariableQueryWithReadPermissionOnProcessInstance() { // given String processInstanceId = startProcessInstanceByKey(PROCESS_KEY, getVariables()).getId(); createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ); // when VariableInstanceQuery query = runtimeService.createVariableInstanceQuery(); // then verifyQueryResults(query, 1); VariableInstance variable = query.singleResult(); assertNotNull(variable); assertEquals(processInstanceId, variable.getProcessInstanceId()); }
@Test public void testStartInstanceWithBeanCondition() { List<EventSubscription> eventSubscriptions = runtimeService.createEventSubscriptionQuery().list(); assertEquals(1, eventSubscriptions.size()); assertEquals(EventType.CONDITONAL.name(), eventSubscriptions.get(0).getEventType()); List<ProcessInstance> instances = runtimeService .createConditionEvaluation() .setVariable("foo", 1) .evaluateStartConditions(); assertEquals(1, instances.size()); assertNotNull(runtimeService.createProcessInstanceQuery().processDefinitionKey("conditionalEventProcess").singleResult()); VariableInstance vars = runtimeService.createVariableInstanceQuery().singleResult(); assertEquals(vars.getProcessInstanceId(), instances.get(0).getId()); assertEquals(1, vars.getValue()); } }
public void testProcessVariableQueryWithReadInstancesPermissionOnOneTaskProcess() { // given String processInstanceId = startProcessInstanceByKey(PROCESS_KEY, getVariables()).getId(); createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_INSTANCE); // when VariableInstanceQuery query = runtimeService.createVariableInstanceQuery(); // then verifyQueryResults(query, 1); VariableInstance variable = query.singleResult(); assertNotNull(variable); assertEquals(processInstanceId, variable.getProcessInstanceId()); }
public static VariableInstanceDto fromVariableInstance(VariableInstance variableInstance) { VariableInstanceDto dto = new VariableInstanceDto(); dto.id = variableInstance.getId(); dto.name = variableInstance.getName(); dto.processInstanceId = variableInstance.getProcessInstanceId(); dto.executionId = variableInstance.getExecutionId(); dto.caseExecutionId = variableInstance.getCaseExecutionId(); dto.caseInstanceId = variableInstance.getCaseInstanceId(); dto.taskId = variableInstance.getTaskId(); dto.activityInstanceId = variableInstance.getActivityInstanceId(); dto.tenantId = variableInstance.getTenantId(); if(variableInstance.getErrorMessage() == null) { VariableValueDto.fromTypedValue(dto, variableInstance.getTypedValue()); } else { dto.errorMessage = variableInstance.getErrorMessage(); dto.type = VariableValueDto.toRestApiTypeName(variableInstance.getTypeName()); } return dto; }
public void testProcessLocalTaskVariableQueryWithReadPermissionOnOneProcessTask() { // given String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId(); String taskId = selectSingleTask().getId(); setTaskVariableLocal(taskId, VARIABLE_NAME, VARIABLE_VALUE); createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_INSTANCE); // when VariableInstanceQuery query = runtimeService.createVariableInstanceQuery(); // then verifyQueryResults(query, 1); VariableInstance variable = query.singleResult(); assertNotNull(variable); assertEquals(processInstanceId, variable.getProcessInstanceId()); }
public void testProcessLocalTaskVariableQueryWithReadPermissionOnProcessInstance() { // given String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId(); String taskId = selectSingleTask().getId(); setTaskVariableLocal(taskId, VARIABLE_NAME, VARIABLE_VALUE); createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ); // when VariableInstanceQuery query = runtimeService.createVariableInstanceQuery(); // then verifyQueryResults(query, 1); VariableInstance variable = query.singleResult(); assertNotNull(variable); assertEquals(processInstanceId, variable.getProcessInstanceId()); }
public void assertVariableMigratedToExecution(VariableInstance variableBefore, String executionId, String activityInstanceId) { VariableInstance variableAfter = snapshotAfterMigration.getVariable(variableBefore.getId()); Assert.assertNotNull("Variable with id " + variableBefore.getId() + " does not exist", variableAfter); Assert.assertEquals(activityInstanceId, variableAfter.getActivityInstanceId()); Assert.assertEquals(variableBefore.getCaseExecutionId(), variableAfter.getCaseExecutionId()); Assert.assertEquals(variableBefore.getCaseInstanceId(), variableAfter.getCaseInstanceId()); Assert.assertEquals(variableBefore.getErrorMessage(), variableAfter.getErrorMessage()); Assert.assertEquals(executionId, variableAfter.getExecutionId()); Assert.assertEquals(variableBefore.getId(), variableAfter.getId()); Assert.assertEquals(variableBefore.getName(), variableAfter.getName()); Assert.assertEquals(variableBefore.getProcessInstanceId(), variableAfter.getProcessInstanceId()); Assert.assertEquals(variableBefore.getTaskId(), variableAfter.getTaskId()); Assert.assertEquals(variableBefore.getTenantId(), variableAfter.getTenantId()); Assert.assertEquals(variableBefore.getTypeName(), variableAfter.getTypeName()); Assert.assertEquals(variableBefore.getValue(), variableAfter.getValue()); }
@Test @Deployment(resources = {"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testQueryByCaseExecutionId() { CaseInstance instance = caseService .withCaseDefinitionByKey("oneTaskCase") .setVariable("aVariableName", "abc") .create(); VariableInstanceQuery query = runtimeService.createVariableInstanceQuery(); query .caseExecutionIdIn(instance.getId()); VariableInstance result = query.singleResult(); assertNotNull(result); assertEquals("aVariableName", result.getName()); assertEquals("abc", result.getValue()); assertEquals(instance.getId(), result.getCaseExecutionId()); assertEquals(instance.getId(), result.getCaseInstanceId()); assertNull(result.getExecutionId()); assertNull(result.getProcessInstanceId()); }
@Test @Deployment(resources = {"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testQueryByCaseInstanceId() { CaseInstance instance = caseService .withCaseDefinitionByKey("oneTaskCase") .setVariable("aVariableName", "abc") .create(); VariableInstanceQuery query = runtimeService.createVariableInstanceQuery(); query .caseInstanceIdIn(instance.getId()); VariableInstance result = query.singleResult(); assertNotNull(result); assertEquals("aVariableName", result.getName()); assertEquals("abc", result.getValue()); assertEquals(instance.getId(), result.getCaseExecutionId()); assertEquals(instance.getId(), result.getCaseInstanceId()); assertNull(result.getExecutionId()); assertNull(result.getProcessInstanceId()); }
@Test @Deployment(resources = {"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testQueryByCaseActivityInstanceId() { CaseInstance instance = caseService .withCaseDefinitionByKey("oneTaskCase") .setVariable("aVariableName", "abc") .create(); VariableInstanceQuery query = runtimeService.createVariableInstanceQuery(); query .activityInstanceIdIn(instance.getId()); VariableInstance result = query.singleResult(); assertNotNull(result); assertEquals("aVariableName", result.getName()); assertEquals("abc", result.getValue()); assertEquals(instance.getId(), result.getCaseExecutionId()); assertEquals(instance.getId(), result.getCaseInstanceId()); assertNull(result.getExecutionId()); assertNull(result.getProcessInstanceId()); }
public void testProcessVariableQueryWithReadInstancesPermissionOnOneTaskProcess() { // given String processInstanceId = startProcessInstanceByKey(PROCESS_KEY, getVariables()).getId(); createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_INSTANCE); // when VariableInstanceQuery query = runtimeService.createVariableInstanceQuery(); // then verifyQueryResults(query, 1); VariableInstance variable = query.singleResult(); assertNotNull(variable); assertEquals(processInstanceId, variable.getProcessInstanceId()); }
public void testProcessVariableQueryWithReadPermissionOnProcessInstance() { // given String processInstanceId = startProcessInstanceByKey(PROCESS_KEY, getVariables()).getId(); createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ); // when VariableInstanceQuery query = runtimeService.createVariableInstanceQuery(); // then verifyQueryResults(query, 1); VariableInstance variable = query.singleResult(); assertNotNull(variable); assertEquals(processInstanceId, variable.getProcessInstanceId()); }
public void testProcessLocalTaskVariableQueryWithReadPermissionOnOneProcessTask() { // given String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId(); String taskId = selectSingleTask().getId(); setTaskVariableLocal(taskId, VARIABLE_NAME, VARIABLE_VALUE); createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_INSTANCE); // when VariableInstanceQuery query = runtimeService.createVariableInstanceQuery(); // then verifyQueryResults(query, 1); VariableInstance variable = query.singleResult(); assertNotNull(variable); assertEquals(processInstanceId, variable.getProcessInstanceId()); }