//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testSerializeFileVariable() public virtual void testSerializeFileVariable() { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("process").startEvent().userTask().endEvent().done(); org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addModelInstance("process.bpmn", modelInstance).deploy(); VariableMap variables = Variables.createVariables(); string filename = "test.txt"; string type = "text/plain"; FileValue fileValue = Variables.fileValue(filename).file("ABC".GetBytes()).encoding("UTF-8").mimeType(type).create(); variables.put("file", fileValue); runtimeService.startProcessInstanceByKey("process", variables); Task task = taskService.createTaskQuery().singleResult(); VariableInstance result = runtimeService.createVariableInstanceQuery().processInstanceIdIn(task.ProcessInstanceId).singleResult(); FileValue value = (FileValue)result.TypedValue; assertThat(value.Filename, @is(filename)); assertThat(value.MimeType, @is(type)); assertThat(value.Encoding, @is("UTF-8")); assertThat(value.EncodingAsCharset, @is(Charset.forName("UTF-8"))); using (Scanner scanner = new Scanner(value.Value)) { assertThat(scanner.nextLine(), @is("ABC")); } // clean up repositoryService.deleteDeployment(deployment.Id, true); }
public static VariableInstanceDto fromVariableInstance(VariableInstance variableInstance) { VariableInstanceDto dto = new VariableInstanceDto(); dto.id = variableInstance.Id; dto.name = variableInstance.Name; dto.processInstanceId = variableInstance.ProcessInstanceId; dto.executionId = variableInstance.ExecutionId; dto.caseExecutionId = variableInstance.CaseExecutionId; dto.caseInstanceId = variableInstance.CaseInstanceId; dto.taskId = variableInstance.TaskId; dto.activityInstanceId = variableInstance.ActivityInstanceId; dto.tenantId = variableInstance.TenantId; if (string.ReferenceEquals(variableInstance.ErrorMessage, null)) { VariableValueDto.fromTypedValue(dto, variableInstance.TypedValue); } else { dto.errorMessage = variableInstance.ErrorMessage; dto.type = VariableValueDto.toRestApiTypeName(variableInstance.TypeName); } return(dto); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeletesOnlyVariablesFromRemovingScope() public virtual void testDeletesOnlyVariablesFromRemovingScope() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.DOUBLE_SUBPROCESS_MODEL); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("innerSubProcess", "subProcess").mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build(); ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(sourceProcessDefinition.Id); Execution innerSubProcessExecution = rule.RuntimeService.createExecutionQuery().activityId("userTask1").singleResult(); string outerSubProcessExecutionId = ((ExecutionEntity)innerSubProcessExecution).ParentId; rule.RuntimeService.setVariableLocal(outerSubProcessExecutionId, "outerVariable", "outerValue"); rule.RuntimeService.setVariableLocal(innerSubProcessExecution.Id, "innerVariable", "innerValue"); testHelper.completeTask("userTask1"); // when testHelper.migrateProcessInstance(migrationPlan, processInstance); // then Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().Count); VariableInstance migratedVariable = testHelper.snapshotAfterMigration.getSingleVariable("innerVariable"); Assert.assertNotNull(migratedVariable); Assert.assertEquals("innerValue", migratedVariable.Value); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNullElResolverIsIgnored() public virtual void testNullElResolverIsIgnored() { runtimeService.startProcessInstanceByKey("testProcess"); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); VariableInstance decisionResult = runtimeService.createVariableInstanceQuery().variableName("result").singleResult(); assertNotNull("The variable 'result' should exist", decisionResult); assertNotNull("The value of the variable 'result' should not be null", decisionResult.Value); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testBinaryDataForNonBinaryVariable() public virtual void testBinaryDataForNonBinaryVariable() { VariableInstance variableInstanceMock = MockProvider.createMockVariableInstance(); when(variableInstanceQueryMock.variableId(variableInstanceMock.Id)).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock); given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).then().expect().statusCode(Status.BAD_REQUEST.StatusCode).body(containsString("Value of variable with id aVariableInstanceId is not a binary value")).when().get(VARIABLE_INSTANCE_BINARY_DATA_URL); verify(variableInstanceQueryMock, never()).disableBinaryFetching(); verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); }
public virtual void testCatchErrorFromCallActivitySetsErrorVariable() { runtimeService.startProcessInstanceByKey("Process_1"); //the name used in "camunda:errorCodeVariable" in the BPMN string variableName = "errorCode"; VariableInstance errorVariable = runtimeService.createVariableInstanceQuery().variableName(variableName).singleResult(); assertThat(errorVariable, @is(notNullValue())); //the code we gave the thrown error object errorCode = "error"; assertThat(errorVariable.Value, @is(errorCode)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGetSingleVariableInstance() public virtual void testGetSingleVariableInstance() { MockVariableInstanceBuilder builder = MockProvider.mockVariableInstance(); VariableInstance variableInstanceMock = builder.build(); when(variableInstanceQueryMock.variableId(variableInstanceMock.Id)).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock); given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).then().expect().statusCode(Status.OK.StatusCode).and().body("id", equalTo(builder.Id)).body("name", equalTo(builder.Name)).body("type", equalTo(VariableTypeHelper.toExpectedValueTypeName(builder.TypedValue.Type))).body("value", equalTo(builder.TypedValue.Value)).body("processInstanceId", equalTo(builder.ProcessInstanceId)).body("executionId", equalTo(builder.ExecutionId)).body("caseInstanceId", equalTo(builder.CaseInstanceId)).body("caseExecutionId", equalTo(builder.CaseExecutionId)).body("taskId", equalTo(builder.TaskId)).body("activityInstanceId", equalTo(builder.ActivityInstanceId)).body("tenantId", equalTo(builder.TenantId)).body("errorMessage", equalTo(builder.ErrorMessage)).when().get(VARIABLE_INSTANCE_URL); verify(variableInstanceQueryMock, times(1)).disableBinaryFetching(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGetSingleVariableInstanceForBinaryVariable() public virtual void testGetSingleVariableInstanceForBinaryVariable() { MockVariableInstanceBuilder builder = MockProvider.mockVariableInstance(); VariableInstance variableInstanceMock = builder.typedValue(Variables.byteArrayValue(null)).build(); when(variableInstanceQueryMock.variableId(variableInstanceMock.Id)).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock); given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).then().expect().statusCode(Status.OK.StatusCode).and().body("type", equalTo(VariableTypeHelper.toExpectedValueTypeName(ValueType.BYTES))).body("value", nullValue()).when().get(VARIABLE_INSTANCE_URL); verify(variableInstanceQueryMock, times(1)).disableBinaryFetching(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGetBinaryDataForNullFileVariable() public virtual void testGetBinaryDataForNullFileVariable() { string filename = "test.txt"; sbyte[] byteContent = null; FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.ToString()).create(); MockVariableInstanceBuilder builder = MockProvider.mockVariableInstance(); VariableInstance variableInstanceMock = builder.typedValue(variableValue).build(); when(variableInstanceQueryMock.variableId(variableInstanceMock.Id)).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock); given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).then().expect().statusCode(Status.OK.StatusCode).and().contentType(ContentType.TEXT).and().body(@is(equalTo(""))).when().get(VARIABLE_INSTANCE_BINARY_DATA_URL); }
public virtual void testCatchBpmnErrorFromJavaDelegateInsideCallActivitySetsErrorVariable() { runtimeService.startProcessInstanceByKey("Process_1"); Task task = taskService.createTaskQuery().singleResult(); taskService.complete(task.Id); //the name used in "camunda:errorCodeVariable" in the BPMN string variableName = "errorCode"; //the code we gave the thrown error object errorCode = "errorCode"; VariableInstance errorVariable = runtimeService.createVariableInstanceQuery().variableName(variableName).singleResult(); assertThat(errorVariable.Value, @is(errorCode)); errorVariable = runtimeService.createVariableInstanceQuery().variableName("errorMessageVariable").singleResult(); assertThat(errorVariable.Value, @is((object)"ouch!")); }
public static DelegateCaseVariableInstanceImpl fromVariableInstance(VariableInstance variableInstance) { DelegateCaseVariableInstanceImpl delegateInstance = new DelegateCaseVariableInstanceImpl(); delegateInstance.variableId = variableInstance.Id; delegateInstance.processInstanceId = variableInstance.ProcessInstanceId; delegateInstance.executionId = variableInstance.ExecutionId; delegateInstance.caseExecutionId = variableInstance.CaseExecutionId; delegateInstance.caseInstanceId = variableInstance.CaseInstanceId; delegateInstance.taskId = variableInstance.TaskId; delegateInstance.activityInstanceId = variableInstance.ActivityInstanceId; delegateInstance.tenantId = variableInstance.TenantId; delegateInstance.errorMessage = variableInstance.ErrorMessage; delegateInstance.name = variableInstance.Name; delegateInstance.value = variableInstance.TypedValue; return(delegateInstance); }
public virtual void testProcessVariableQueryWithReadInstancesPermissionOnOneTaskProcess() { // given string processInstanceId = startProcessInstanceByKey(PROCESS_KEY, Variables).Id; 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.ProcessInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testBinaryDataForBinaryVariable() public virtual void testBinaryDataForBinaryVariable() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final byte[] byteContent = "some bytes".getBytes(); sbyte[] byteContent = "some bytes".GetBytes(); VariableInstance variableInstanceMock = MockProvider.mockVariableInstance().typedValue(Variables.byteArrayValue(byteContent)).build(); when(variableInstanceQueryMock.variableId(variableInstanceMock.Id)).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock); Response response = given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).then().expect().statusCode(Status.OK.StatusCode).contentType(ContentType.BINARY.ToString()).when().get(VARIABLE_INSTANCE_BINARY_DATA_URL); sbyte[] responseBytes = response.Body.asByteArray(); Assert.assertEquals(StringHelper.NewString(byteContent), StringHelper.NewString(responseBytes)); verify(variableInstanceQueryMock, never()).disableBinaryFetching(); verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); }
public virtual void testTreeCompactionAndExpansionWithScopeExecutionVariables() { // given ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); Task task2 = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult(); runtimeService.setVariableLocal(processInstance.Id, "var", "value"); // when compacting the tree taskService.complete(task2.Id); // and expanding again runtimeService.createProcessInstanceModification(processInstance.Id).startBeforeActivity("task2").execute(); // then the variable is still assigned to the scope execution execution VariableInstance variable = runtimeService.createVariableInstanceQuery().singleResult(); assertEquals(processInstance.Id, variable.ExecutionId); }
public virtual void testProcessLocalTaskVariableQueryWithReadPermissionOnOneProcessTask() { // given string processInstanceId = startProcessInstanceByKey(PROCESS_KEY).Id; string taskId = selectSingleTask().Id; 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.ProcessInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testTreeCompactionForkParallelGateway() public virtual void testTreeCompactionForkParallelGateway() { // given ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); Task task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult(); Execution task2Execution = runtimeService.createExecutionQuery().activityId("task2").singleResult(); // when runtimeService.setVariableLocal(task2Execution.Id, "foo", "bar"); // and completing the other task, thereby pruning the concurrent execution taskService.complete(task1.Id); // then the variable still exists VariableInstance variable = runtimeService.createVariableInstanceQuery().singleResult(); assertNotNull(variable); assertEquals("foo", variable.Name); assertEquals(processInstance.Id, variable.ExecutionId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToPerformModification() public virtual void shouldBeAbleToPerformModification() { // given BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("TestProcess").startEvent().intermediateCatchEvent("TimerEvent").timerWithDate("${calculateTimerDate.execute(execution)}").camundaExecutionListenerDelegateExpression("end", "${deleteVariableListener}").endEvent().done(); deployModelInstance(modelInstance); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.runtime.ProcessInstance procInst = runtimeService.startProcessInstanceByKey("TestProcess"); ProcessInstance procInst = runtimeService.startProcessInstanceByKey("TestProcess"); // when userBean.completeUserTaskAndModifyInstanceInOneTransaction(procInst); // then VariableInstance variable = rule.RuntimeService.createVariableInstanceQuery().processInstanceIdIn(procInst.Id).variableName("createDate").singleResult(); assertNotNull(variable); HistoricVariableInstance historicVariable = rule.HistoryService.createHistoricVariableInstanceQuery().singleResult(); assertEquals(variable.Name, historicVariable.Name); assertEquals(org.camunda.bpm.engine.history.HistoricVariableInstance_Fields.STATE_CREATED, historicVariable.State); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGetBinaryDataForFileVariable() public virtual void testGetBinaryDataForFileVariable() { string filename = "test.txt"; sbyte[] byteContent = "test".GetBytes(); string encoding = "UTF-8"; FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.ToString()).encoding(encoding).create(); MockVariableInstanceBuilder builder = MockProvider.mockVariableInstance(); VariableInstance variableInstanceMock = builder.typedValue(variableValue).build(); when(variableInstanceQueryMock.variableId(variableInstanceMock.Id)).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock); Response response = given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).then().expect().statusCode(Status.OK.StatusCode).and().header("Content-Disposition", "attachment; filename=" + filename).and().body(@is(equalTo(StringHelper.NewString(byteContent)))).when().get(VARIABLE_INSTANCE_BINARY_DATA_URL); //due to some problems with wildfly we gotta check this separately string contentType = response.ContentType; assertThat(contentType, @is(either(CoreMatchers.equalTo <object>(ContentType.TEXT.ToString() + "; charset=UTF-8")).or(CoreMatchers.equalTo <object>(ContentType.TEXT.ToString() + ";charset=UTF-8")))); }
public virtual void testStableVariableInstanceIdsOnCompaction() { runtimeService.startProcessInstanceByKey("process"); Execution innerTaskExecution = runtimeService.createExecutionQuery().activityId("innerTask").singleResult(); Execution subProcessConcurrentExecution = runtimeService.createExecutionQuery().executionId(((ExecutionEntity)innerTaskExecution).ParentId).singleResult(); Task task = taskService.createTaskQuery().taskDefinitionKey("task").singleResult(); // when runtimeService.setVariableLocal(subProcessConcurrentExecution.Id, "foo", "bar"); VariableInstance variableBeforeCompaction = runtimeService.createVariableInstanceQuery().singleResult(); // and completing the concurrent task, thereby pruning the sub process concurrent execution taskService.complete(task.Id); // then the variable still exists VariableInstance variableAfterCompaction = runtimeService.createVariableInstanceQuery().singleResult(); assertEquals(variableBeforeCompaction.Id, variableAfterCompaction.Id); }
public virtual void testStableVariableInstanceIdsOnCompactionAndExpansion() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); Execution task1Execution = runtimeService.createExecutionQuery().activityId("task1").singleResult(); Task task2 = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult(); // when runtimeService.setVariableLocal(task1Execution.Id, "foo", "bar"); VariableInstance variableBeforeCompaction = runtimeService.createVariableInstanceQuery().singleResult(); // compacting the tree taskService.complete(task2.Id); // expanding the tree runtimeService.createProcessInstanceModification(processInstance.Id).startBeforeActivity("task2").execute(); // then the variable still exists VariableInstance variableAfterCompaction = runtimeService.createVariableInstanceQuery().singleResult(); assertEquals(variableBeforeCompaction.Id, variableAfterCompaction.Id); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNoOutputMappingExecuted() public virtual void testNoOutputMappingExecuted() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL).activityBuilder("subProcess").camundaOutputParameter("foo", "${bar}").done()); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build(); ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(sourceProcessDefinition.Id); rule.RuntimeService.setVariable(processInstance.Id, "bar", "value1"); testHelper.completeTask("userTask1"); // => sets "foo" to "value1" rule.RuntimeService.setVariable(processInstance.Id, "bar", "value2"); // when testHelper.migrateProcessInstance(migrationPlan, processInstance); // then "foo" has not been set to "value2" Assert.assertEquals(2, testHelper.snapshotAfterMigration.getVariables().Count); // "foo" and "bar" VariableInstance variableInstance = testHelper.snapshotAfterMigration.getSingleVariable("foo"); Assert.assertEquals("value1", variableInstance.Value); }
public VariableEvent(VariableInstance variableInstance, string eventName, AbstractVariableScope sourceScope) { this.variableInstance = variableInstance; this.eventName = eventName; this.sourceScope = sourceScope; }
public virtual VariableInstance build() { VariableInstance mockVariable = mock(typeof(VariableInstance)); return(build(mockVariable)); }