//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void testVariablesWithoutDeserialization(String processDefinitionKey) throws Exception private void testVariablesWithoutDeserialization(string processDefinitionKey) { //given serializable variable JavaSerializable javaSerializable = new JavaSerializable("foo"); MemoryStream baos = new MemoryStream(); (new ObjectOutputStream(baos)).writeObject(javaSerializable); string serializedObject = StringUtil.fromBytes(Base64.encodeBase64(baos.toByteArray()), engineRule.ProcessEngine); //when execute process with serialized variable and wait state //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: ProcessInstanceWithVariables procInstance = engineRule.RuntimeService.createProcessInstanceByKey(processDefinitionKey).setVariable("serializedVar", serializedObjectValue(serializedObject).serializationDataFormat(Variables.SerializationDataFormats.JAVA).objectTypeName(typeof(JavaSerializable).FullName).create()).executeWithVariablesInReturn(false, false); //then returned instance contains serialized variable VariableMap map = procInstance.Variables; assertNotNull(map); ObjectValue serializedVar = (ObjectValue)map.getValueTyped("serializedVar"); assertFalse(serializedVar.Deserialized); assertObjectValueSerializedJava(serializedVar, javaSerializable); //access on value should fail because variable is not deserialized try { serializedVar.Value; Assert.fail("Deserialization should fail!"); } catch (System.InvalidOperationException ise) { assertTrue(ise.Message.Equals("Object is not deserialized.")); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeleteProcessDefinitionAndRefillDeploymentCache() public virtual void testDeleteProcessDefinitionAndRefillDeploymentCache() { // given a deployment with two process definitions in one xml model file deployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/repository/twoProcesses.bpmn20.xml").deploy(); ProcessDefinition processDefinitionOne = repositoryService.createProcessDefinitionQuery().processDefinitionKey("one").singleResult(); ProcessDefinition processDefinitionTwo = repositoryService.createProcessDefinitionQuery().processDefinitionKey("two").singleResult(); string idOne = processDefinitionOne.Id; //one is deleted from the deployment repositoryService.deleteProcessDefinition(idOne); //when clearing the deployment cache processEngineConfiguration.DeploymentCache.discardProcessDefinitionCache(); //then creating process instance from the existing process definition ProcessInstanceWithVariables procInst = runtimeService.createProcessInstanceByKey("two").executeWithVariablesInReturn(); assertNotNull(procInst); assertTrue(procInst.ProcessDefinitionId.Contains("two")); //should refill the cache Cache cache = processEngineConfiguration.DeploymentCache.ProcessDefinitionCache; assertNotNull(cache.get(processDefinitionTwo.Id)); //The deleted process definition should not be recreated after the cache is refilled assertNull(cache.get(processDefinitionOne.Id)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUpHttpClientAndRuntimeData() public virtual void setUpHttpClientAndRuntimeData() { client = HttpClients.createDefault(); reqConfig = RequestConfig.custom().setConnectTimeout(3 * 60 * 1000).setSocketTimeout(10 * 60 * 1000).build(); ProcessDefinition mockDefinition = MockProvider.createMockDefinition(); runtimeServiceMock = mock(typeof(RuntimeService)); when(processEngine.RuntimeService).thenReturn(runtimeServiceMock); mockInstantiationBuilder = mock(typeof(ProcessInstantiationBuilder)); when(mockInstantiationBuilder.setVariables(any(typeof(System.Collections.IDictionary)))).thenReturn(mockInstantiationBuilder); when(mockInstantiationBuilder.businessKey(anyString())).thenReturn(mockInstantiationBuilder); when(mockInstantiationBuilder.caseInstanceId(anyString())).thenReturn(mockInstantiationBuilder); when(runtimeServiceMock.createProcessInstanceById(anyString())).thenReturn(mockInstantiationBuilder); ProcessInstanceWithVariables resultInstanceWithVariables = MockProvider.createMockInstanceWithVariables(); when(mockInstantiationBuilder.executeWithVariablesInReturn(anyBoolean(), anyBoolean())).thenReturn(resultInstanceWithVariables); ProcessDefinitionQuery processDefinitionQueryMock = mock(typeof(ProcessDefinitionQuery)); when(processDefinitionQueryMock.processDefinitionKey(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY)).thenReturn(processDefinitionQueryMock); when(processDefinitionQueryMock.withoutTenantId()).thenReturn(processDefinitionQueryMock); when(processDefinitionQueryMock.latestVersion()).thenReturn(processDefinitionQueryMock); when(processDefinitionQueryMock.singleResult()).thenReturn(mockDefinition); RepositoryService repositoryServiceMock = mock(typeof(RepositoryService)); when(processEngine.RepositoryService).thenReturn(repositoryServiceMock); when(repositoryServiceMock.createProcessDefinitionQuery()).thenReturn(processDefinitionQueryMock); }
public virtual void testExpressionRecalculateCreationDateBased() { // Set the clock fixed Dictionary <string, object> variables = new Dictionary <string, object>(); variables["duration"] = "PT1H"; // After process start, there should be timer created ProcessInstanceWithVariables pi1 = (ProcessInstanceWithVariables)runtimeService.startProcessInstanceByKey("intermediateTimerEventExample", variables); JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi1.Id); assertEquals(1, jobQuery.count()); Job job = jobQuery.singleResult(); DateTime firstDate = job.Duedate; // After variable change and recalculation, there should still be one timer only, with a changed due date moveByMinutes(65); // move past first due date runtimeService.setVariable(pi1.ProcessInstanceId, "duration", "PT15M"); processEngine.ManagementService.recalculateJobDuedate(job.Id, true); assertEquals(1, jobQuery.count()); job = jobQuery.singleResult(); assertNotEquals(firstDate, job.Duedate); assertTrue(firstDate > job.Duedate); DateTime expectedDate = LocalDateTime.fromDateFields(job.CreateTime).plusMinutes(15).toDate(); assertEquals(expectedDate, job.Duedate); // After waiting for sixteen minutes the timer should fire ClockUtil.CurrentTime = new DateTime(firstDate.Ticks + TimeUnit.MINUTES.toMillis(16L)); waitForJobExecutorToProcessAllJobs(5000L); assertEquals(0, managementService.createJobQuery().processInstanceId(pi1.Id).count()); assertProcessEnded(pi1.ProcessInstanceId); }
public static ProcessInstanceDto fromProcessInstance(ProcessInstanceWithVariables instance) { ProcessInstanceWithVariablesDto result = new ProcessInstanceWithVariablesDto(instance); VariableMap variables = instance.Variables; result.variables = VariableValueDto.fromMap(variables, true); return(result); }
public virtual void testReturnVariablesFromStartAndExecution() { //given executed process which sets variables in java delegate ProcessInstanceWithVariables procInstance = engineRule.RuntimeService.createProcessInstanceByKey("variableProcess").setVariable("aVariable1", "aValue1").setVariableLocal("aVariable2", "aValue2").setVariables(Variables.createVariables().putValue("aVariable3", "aValue3")).setVariablesLocal(Variables.createVariables().putValue("aVariable4", new sbyte[] { 127, 34, 64 })).executeWithVariablesInReturn(); //when returned instance contains variables VariableMap map = procInstance.Variables; assertNotNull(map); // then variables equal to variables which are accessible via query checkVariables(map, 12); }
public virtual void testReturnVariablesFromExecutionWithWaitstate() { //given executed process which sets variables in java delegate ProcessInstanceWithVariables procInstance = engineRule.RuntimeService.createProcessInstanceByKey("variableProcess").executeWithVariablesInReturn(); //when returned instance contains variables VariableMap map = procInstance.Variables; assertNotNull(map); // then variables equal to variables which are accessible via query checkVariables(map, 8); }
public virtual void testReturnVariablesFromStartAndExecutionWithWaitstate() { //given executed process which overwrites these four variables in java delegate // and adds four additional variables ProcessInstanceWithVariables procInstance = engineRule.RuntimeService.createProcessInstanceByKey("variableProcess").setVariable("stringVar", "aValue1").setVariableLocal("integerVar", 56789).setVariables(Variables.createVariables().putValue("longVar", 123L)).setVariablesLocal(Variables.createVariables().putValue("byteVar", new sbyte[] { 127, 34, 64 })).executeWithVariablesInReturn(false, false); //when returned instance contains variables VariableMap map = procInstance.Variables; assertNotNull(map); // then variables equal to variables which are accessible via query checkVariables(map, 8); }
public virtual void testReturnVariablesFromStartWithWaitstateStartInSubProcess() { //given execute process with variables and wait state in sub process ProcessInstanceWithVariables procInstance = engineRule.RuntimeService.createProcessInstanceByKey("subprocess").setVariable("aVariable1", "aValue1").setVariableLocal("aVariable2", "aValue2").setVariables(Variables.createVariables().putValue("aVariable3", "aValue3")).setVariablesLocal(Variables.createVariables().putValue("aVariable4", new sbyte[] { 127, 34, 64 })).startBeforeActivity("innerTask").executeWithVariablesInReturn(true, true); //when returned instance contains variables VariableMap map = procInstance.Variables; assertNotNull(map); // then variables equal to variables which are accessible via query checkVariables(map, 4); }
public virtual ProcessInstanceDto startProcessInstance(UriInfo context, StartProcessInstanceDto parameters) { ProcessInstanceWithVariables instance = null; try { instance = startProcessInstanceAtActivities(parameters); } catch (AuthorizationException e) { throw e; } catch (ProcessEngineException e) { string errorMessage = string.Format("Cannot instantiate process definition {0}: {1}", processDefinitionId, e.Message); throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, e, errorMessage); } catch (RestException e) { string errorMessage = string.Format("Cannot instantiate process definition {0}: {1}", processDefinitionId, e.Message); throw new InvalidRequestException(e.Status, e, errorMessage); } ProcessInstanceDto result; if (parameters.WithVariablesInReturn) { result = ProcessInstanceWithVariablesDto.fromProcessInstance(instance); } else { result = ProcessInstanceDto.fromProcessInstance(instance); } URI uri = context.BaseUriBuilder.path(rootResourcePath).path(org.camunda.bpm.engine.rest.ProcessInstanceRestService_Fields.PATH).path(instance.Id).build(); result.addReflexiveLink(uri, HttpMethod.GET, "self"); return(result); }