/// <summary> /// Tests that the PA-local data format applies when a variable is set in /// the context of it /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPaLocalFormatApplies() throws com.fasterxml.jackson.core.JsonProcessingException, java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testPaLocalFormatApplies() { // given a process instance //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.runtime.ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess"); // when setting a variable in the context of a process application DateTime date = new DateTime(JsonSerializable.ONE_DAY_IN_MILLIS * 10); // 10th of January 1970 JsonSerializable jsonSerializable = new JsonSerializable(date); try { ProcessApplicationContext.CurrentProcessApplication = ReferenceStoringProcessApplication.INSTANCE; runtimeService.setVariable(pi.Id, "jsonSerializable", Variables.objectValue(jsonSerializable).serializationDataFormat(Variables.SerializationDataFormats.JSON).create()); } finally { ProcessApplicationContext.clear(); } // then the process-application-local data format has been used to serialize the value ObjectValue objectValue = runtimeService.getVariableTyped(pi.Id, "jsonSerializable", false); string serializedValue = objectValue.ValueSerialized; string expectedSerializedValue = jsonSerializable.toExpectedJsonString(JsonDataFormatConfigurator.DATE_FORMAT); ObjectMapper objectMapper = new ObjectMapper(); JsonNode actualJsonTree = objectMapper.readTree(serializedValue); JsonNode expectedJsonTree = objectMapper.readTree(expectedSerializedValue); // JsonNode#equals makes a deep comparison Assert.assertEquals(expectedJsonTree, actualJsonTree); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testExecutionInPAContextByName() throws Exception public virtual void testExecutionInPAContextByName() { Assert.assertNull(Context.CurrentProcessApplication); ProcessApplicationReference contextPA = ProcessApplicationContext.withProcessApplicationContext(new CallableAnonymousInnerClass(this) , pa.Name); Assert.assertEquals(contextPA.ProcessApplication, pa); Assert.assertNull(Context.CurrentProcessApplication); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testCannotExecuteInUnregisteredPaContext() throws Exception public virtual void testCannotExecuteInUnregisteredPaContext() { string nonExistingName = pa.Name + pa.Name; try { ProcessApplicationContext.withProcessApplicationContext(new CallableAnonymousInnerClass4(this) , nonExistingName); fail("should not succeed"); } catch (ProcessEngineException e) { assertTextPresent("A process application with name '" + nonExistingName + "' is not registered", e.Message); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testSetPAContextByName() throws org.camunda.bpm.application.ProcessApplicationUnavailableException public virtual void testSetPAContextByName() { Assert.assertNull(Context.CurrentProcessApplication); try { ProcessApplicationContext.CurrentProcessApplication = pa.Name; Assert.assertEquals(CurrentContextApplication.ProcessApplication, pa); } finally { ProcessApplicationContext.clear(); } Assert.assertNull(Context.CurrentProcessApplication); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testSetPAContextByRawPA() throws org.camunda.bpm.application.ProcessApplicationUnavailableException public virtual void testSetPAContextByRawPA() { Assert.assertNull(Context.CurrentProcessApplication); try { ProcessApplicationContext.CurrentProcessApplication = pa; Assert.assertEquals(pa, CurrentContextApplication.ProcessApplication); } finally { ProcessApplicationContext.clear(); } Assert.assertNull(Context.CurrentProcessApplication); }
/// <summary> /// Tests that an implicit object value update happens in the context of the /// process application. /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testExecutionVariableImplicitObjectValueUpdate() throws com.fasterxml.jackson.core.JsonProcessingException, java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testExecutionVariableImplicitObjectValueUpdate() { // given a process instance and a task ProcessInstance pi = runtimeService.startProcessInstanceByKey("implicitProcessVariableUpdate"); // when setting a variable such that the process-application-local dataformat applies DateTime date = new DateTime(JsonSerializable.ONE_DAY_IN_MILLIS * 10); // 10th of January 1970 JsonSerializable jsonSerializable = new JsonSerializable(date); try { ProcessApplicationContext.CurrentProcessApplication = ReferenceStoringProcessApplication.INSTANCE; runtimeService.setVariable(pi.Id, ImplicitObjectValueUpdateHandler.VARIABLE_NAME, Variables.objectValue(jsonSerializable).serializationDataFormat(Variables.SerializationDataFormats.JSON).create()); } finally { ProcessApplicationContext.clear(); } // and triggering an implicit update of the object value variable Task task = taskService.createTaskQuery().processInstanceId(pi.Id).singleResult(); taskService.complete(task.Id); // then the process-application-local format was used for making the update ObjectValue objectValue = runtimeService.getVariableTyped(pi.Id, ImplicitObjectValueUpdateHandler.VARIABLE_NAME, false); ImplicitObjectValueUpdateHandler.addADay(jsonSerializable); string serializedValue = objectValue.ValueSerialized; string expectedSerializedValue = jsonSerializable.toExpectedJsonString(JsonDataFormatConfigurator.DATE_FORMAT); ObjectMapper objectMapper = new ObjectMapper(); JsonNode actualJsonTree = objectMapper.readTree(serializedValue); JsonNode expectedJsonTree = objectMapper.readTree(expectedSerializedValue); // JsonNode#equals makes a deep comparison Assert.assertEquals(expectedJsonTree, actualJsonTree); // and it is also correct in the history HistoricVariableInstance historicObjectValue = historyService.createHistoricVariableInstanceQuery().processInstanceId(pi.Id).variableName(ImplicitObjectValueUpdateHandler.VARIABLE_NAME).disableCustomObjectDeserialization().singleResult(); serializedValue = ((ObjectValue)historicObjectValue.TypedValue).ValueSerialized; actualJsonTree = objectMapper.readTree(serializedValue); Assert.assertEquals(expectedJsonTree, actualJsonTree); }
public virtual void testCannotSetUnregisteredProcessApplicationName() { string nonExistingName = pa.Name + pa.Name; try { ProcessApplicationContext.CurrentProcessApplication = nonExistingName; try { CurrentContextApplication; fail("should not succeed"); } catch (ProcessEngineException e) { assertTextPresent("A process application with name '" + nonExistingName + "' is not registered", e.Message); } } finally { ProcessApplicationContext.clear(); } }