public virtual void testReceivesNoHistoricVariableUpdatesAsDetails() { // given ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); // when string value = "a Variable Value"; runtimeService.setVariable(instance.Id, "aStringVariable", value); runtimeService.setVariable(instance.Id, "aBytesVariable", value.GetBytes()); string newValue = "a new Variable Value"; runtimeService.setVariable(instance.Id, "aStringVariable", newValue); runtimeService.setVariable(instance.Id, "aBytesVariable", newValue.GetBytes()); // then the historic variable instances exist and they have the latest values assertEquals(2, historyService.createHistoricVariableInstanceQuery().count()); HistoricVariableInstance historicStringVariable = historyService.createHistoricVariableInstanceQuery().variableName("aStringVariable").singleResult(); assertNotNull(historicStringVariable); assertEquals(newValue, historicStringVariable.Value); HistoricVariableInstance historicBytesVariable = historyService.createHistoricVariableInstanceQuery().variableName("aBytesVariable").singleResult(); assertNotNull(historicBytesVariable); assertTrue(Arrays.Equals(newValue.GetBytes(), (sbyte[])historicBytesVariable.Value)); // and no historic details exist assertEquals(0, historyService.createHistoricDetailQuery().variableUpdates().count()); }
public virtual void FAILING_testBoundaryCompensationHandlerHistoryVariableInstance() { // given a process instance ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("boundaryHandlerProcess"); // when throwing compensation Task beforeCompensationTask = taskService.createTaskQuery().singleResult(); taskService.complete(beforeCompensationTask.Id); string compensationHandlerActivityInstanceId = runtimeService.getActivityInstance(processInstance.Id).getActivityInstances("compensationHandler")[0].Id; // .. setting a variable via task service API Task compensationHandler = taskService.createTaskQuery().singleResult(); runtimeService.setVariableLocal(compensationHandler.ExecutionId, "apiVariable", "someValue"); // .. and completing compensation taskService.complete(compensationHandler.Id); // then there is a historic variable instance for the variable set by API HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().singleResult(); assertNotNull(historicVariableInstance); assertEquals(compensationHandlerActivityInstanceId, historicVariableInstance.ActivityInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeployProcessArchive() public virtual void testDeployProcessArchive() { // the process can successfully be executed ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess"); HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().processInstanceId(pi.Id).singleResult(); assertNotNull(variable); assertEquals("executed", variable.Name); assertEquals(true, variable.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() { HistoricVariableInstance variableInstanceMock = MockProvider.createMockHistoricVariableInstance(); 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 " + variableInstanceMock.Id + " is not a binary value")).when().get(VARIABLE_INSTANCE_BINARY_DATA_URL); verify(variableInstanceQueryMock, never()).disableBinaryFetching(); }
//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() { MockHistoricVariableInstanceBuilder builder = MockProvider.mockHistoricVariableInstance(); HistoricVariableInstance 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", builder.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.Value)).body("processDefinitionKey", equalTo(builder.ProcessDefinitionKey)).body("processDefinitionId", equalTo(builder.ProcessDefinitionId)).body("processInstanceId", equalTo(builder.ProcessInstanceId)).body("executionId", equalTo(builder.ExecutionId)).body("errorMessage", equalTo(builder.ErrorMessage)).body("activityInstanceId", equalTo(builder.ActivityInstanceId)).body("caseDefinitionKey", equalTo(builder.CaseDefinitionKey)).body("caseDefinitionId", equalTo(builder.CaseDefinitionId)).body("caseInstanceId", equalTo(builder.CaseInstanceId)).body("caseExecutionId", equalTo(builder.CaseExecutionId)).body("taskId", equalTo(builder.TaskId)).body("tenantId", equalTo(builder.TenantId)).body("createTime", equalTo(MockProvider.EXAMPLE_HISTORIC_VARIABLE_INSTANCE_CREATE_TIME)).body("removalTime", equalTo(MockProvider.EXAMPLE_HISTORIC_VARIABLE_INSTANCE_REMOVAL_TIME)).body("rootProcessInstanceId", equalTo(builder.RootProcessInstanceId)).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(); HistoricVariableInstance variableInstanceMock = MockProvider.mockHistoricVariableInstance().typedValue(variableValue).build(); 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.OK.StatusCode).and().contentType(ContentType.TEXT).and().body(@is(equalTo(""))).when().get(VARIABLE_INSTANCE_BINARY_DATA_URL); }
//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() { MockHistoricVariableInstanceBuilder builder = MockProvider.mockHistoricVariableInstance(); HistoricVariableInstance 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(); }
public virtual void testQueryDeleteVariableHistoryOperationOnCase() { // given CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase"); caseService.setVariable(caseInstance.Id, "myVariable", 1); caseService.setVariable(caseInstance.Id, "myVariable", 2); caseService.setVariable(caseInstance.Id, "myVariable", 3); HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().singleResult(); // when historyService.deleteHistoricVariableInstance(variableInstance.Id); // then verifyNoUserOperationLogged(); }
//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(); HistoricVariableInstance variableInstanceMock = MockProvider.mockHistoricVariableInstance().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(); }
public virtual void testQueryDeleteVariableHistoryOperationOnStandaloneTask() { // given Task task = taskService.newTask(); taskService.saveTask(task); taskService.setVariable(task.Id, "testVariable", "testValue"); taskService.setVariable(task.Id, "testVariable", "testValue2"); HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().singleResult(); // when historyService.deleteHistoricVariableInstance(variableInstance.Id); // then verifyNoUserOperationLogged(); taskService.deleteTask(task.Id, true); }
public virtual void testSelectHistoricSerializedValues() { if (processEngineConfiguration.HistoryLevel.Id >= org.camunda.bpm.engine.impl.history.HistoryLevel_Fields.HISTORY_LEVEL_AUDIT.Id) { ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); JsonSerializable bean = new JsonSerializable("a String", 42, false); runtimeService.setVariable(instance.Id, "simpleBean", objectValue(bean).serializationDataFormat(JSON_FORMAT_NAME)); HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().singleResult(); assertNotNull(historicVariable.Value); assertNull(historicVariable.ErrorMessage); ObjectValue typedValue = (ObjectValue)historicVariable.TypedValue; assertEquals(JSON_FORMAT_NAME, typedValue.SerializationDataFormat); JSONAssert.assertEquals(bean.toExpectedJsonString(), new string(typedValue.ValueSerialized), true); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: assertEquals(typeof(JsonSerializable).FullName, typedValue.ObjectTypeName); } }
//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(); HistoricVariableInstance variableInstanceMock = MockProvider.mockHistoricVariableInstance().typedValue(variableValue).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).and().body(@is(equalTo(StringHelper.NewString(byteContent)))).header("Content-Disposition", "attachment; filename=" + filename).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")))); verify(variableInstanceQueryMock, never()).disableBinaryFetching(); }
public virtual void testSelectHistoricVariableInstances() { if (processEngineConfiguration.HistoryLevel.Id >= org.camunda.bpm.engine.impl.history.HistoryLevel_Fields.HISTORY_LEVEL_AUDIT.Id) { ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); JsonSerializable bean = new JsonSerializable("a String", 42, false); runtimeService.setVariable(instance.Id, "simpleBean", objectValue(bean).serializationDataFormat(JSON_FORMAT_NAME).create()); HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().singleResult(); assertNotNull(historicVariable.Value); assertNull(historicVariable.ErrorMessage); assertEquals(ValueType.OBJECT.Name, historicVariable.TypeName); assertEquals(ValueType.OBJECT.Name, historicVariable.VariableTypeName); JsonSerializable historyValue = (JsonSerializable)historicVariable.Value; assertEquals(bean.StringProperty, historyValue.StringProperty); assertEquals(bean.IntProperty, historyValue.IntProperty); assertEquals(bean.BooleanProperty, historyValue.BooleanProperty); } }
//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); }