public virtual void testInsertDeleteInsertTheSameVariable() { BpmnModelInstance bpmnModel = Bpmn.createExecutableProcess("serviceTaskProcess").startEvent().userTask("userTask").serviceTask("service").camundaClass(typeof(InsertDeleteInsertVariableDelegate)).userTask("userTask1").endEvent().done(); ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(bpmnModel); VariableMap variables = Variables.createVariables().putValue("listVar", Arrays.asList(new int[] { 1, 2, 3 })); ProcessInstance instance = engineRule.RuntimeService.startProcessInstanceById(processDefinition.Id, variables); Task task = engineRule.TaskService.createTaskQuery().singleResult(); engineRule.TaskService.complete(task.Id); VariableInstance variable = engineRule.RuntimeService.createVariableInstanceQuery().processInstanceIdIn(instance.Id).variableName("foo").singleResult(); assertNotNull(variable); assertEquals("bar", variable.Value); IList <HistoricVariableInstance> historyVariables = engineRule.HistoryService.createHistoricVariableInstanceQuery().list(); foreach (HistoricVariableInstance historicVariable in historyVariables) { if (variable.Name.Equals(historicVariable.Name)) { assertEquals(org.camunda.bpm.engine.history.HistoricVariableInstance_Fields.STATE_CREATED, historicVariable.State); break; } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldContinueParentProcessWithMultiInstanceEmbeddedSubProcess() public virtual void shouldContinueParentProcessWithMultiInstanceEmbeddedSubProcess() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance parentProcessInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess("parentProcess").startEvent().subProcess().embeddedSubProcess().startEvent().callActivity("callActivity").calledElement("subprocess").endEvent().subProcessDone().multiInstance().cardinality("3").multiInstanceDone().userTask().endEvent().done(); BpmnModelInstance parentProcessInstance = Bpmn.createExecutableProcess("parentProcess").startEvent().subProcess().embeddedSubProcess().startEvent().callActivity("callActivity").calledElement("subprocess").endEvent().subProcessDone().multiInstance().cardinality("3").multiInstanceDone().userTask().endEvent().done(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance subprocessInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess("subprocess").startEvent().userTask("userTask").endEvent("subEnd").done(); BpmnModelInstance subprocessInstance = Bpmn.createExecutableProcess("subprocess").startEvent().userTask("userTask").endEvent("subEnd").done(); testHelper.deploy(parentProcessInstance, subprocessInstance); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String subprocessPrDefId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("subprocess").singleResult().getId(); string subprocessPrDefId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("subprocess").singleResult().Id; // given I start the process, which waits at user task inside multiinstance subprocess ProcessInstance parentPI = runtimeService.startProcessInstanceByKey("parentProcess"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<org.camunda.bpm.engine.runtime.ProcessInstance> subprocesses = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").list(); IList <ProcessInstance> subprocesses = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").list(); assertEquals(3, subprocesses.Count); // when I do process instance modification runtimeService.createModification(subprocessPrDefId).cancelAllForActivity("userTask").startAfterActivity("userTask").processInstanceIds(collectIds(subprocesses)).execute(); // then the parent process instance is still active assertThat(runtimeService.createProcessInstanceQuery().count(), @is(1L)); Task task = taskService.createTaskQuery().singleResult(); assertThat(task.ProcessInstanceId, @is(parentPI.Id)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testRemoveIncidentForJob() public virtual void testRemoveIncidentForJob() { // given BpmnModelInstance sourceProcess = modify(ProcessModels.ONE_TASK_PROCESS).userTaskBuilder("userTask").boundaryEvent("boundary").timerWithDate(TIMER_DATE).serviceTask("failingTask").camundaClass("org.camunda.bpm.engine.test.api.runtime.FailingDelegate").endEvent().done(); BpmnModelInstance targetProcess = modify(sourceProcess).changeElementId("userTask", "newUserTask").changeElementId("boundary", "newBoundary"); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess); ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(sourceProcessDefinition.Id); // a timer job exists Job jobBeforeMigration = rule.ManagementService.createJobQuery().singleResult(); assertNotNull(jobBeforeMigration); // if the timer job is triggered the failing delegate fails and an incident is created executeJob(jobBeforeMigration); Incident incidentBeforeMigration = rule.RuntimeService.createIncidentQuery().singleResult(); assertEquals("boundary", incidentBeforeMigration.ActivityId); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask", "newUserTask").build(); // when testHelper.migrateProcessInstance(migrationPlan, processInstance); // then the incident was removed Job jobAfterMigration = rule.ManagementService.createJobQuery().jobId(jobBeforeMigration.Id).singleResult(); assertNull(jobAfterMigration); assertEquals(0, rule.RuntimeService.createIncidentQuery().count()); }
public virtual void testJavaDelegateModelExecutionContext() { deploy(); runtimeService.startProcessInstanceByKey(PROCESS_ID); BpmnModelInstance modelInstance = ModelExecutionContextServiceTask.modelInstance; assertNotNull(modelInstance); Model model = modelInstance.Model; ICollection <ModelElementInstance> events = modelInstance.getModelElementsByType(model.getType(typeof(Event))); assertEquals(2, events.Count); ICollection <ModelElementInstance> tasks = modelInstance.getModelElementsByType(model.getType(typeof(Task))); assertEquals(1, tasks.Count); Process process = (Process)modelInstance.Definitions.RootElements.GetEnumerator().next(); assertEquals(PROCESS_ID, process.Id); assertTrue(process.Executable); ServiceTask serviceTask = ModelExecutionContextServiceTask.serviceTask; assertNotNull(serviceTask); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: assertEquals(typeof(ModelExecutionContextServiceTask).FullName, serviceTask.CamundaClass); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldContinueParentProcess() public virtual void shouldContinueParentProcess() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance parentProcessInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess("parentProcess").startEvent().callActivity("callActivity").calledElement("subprocess").userTask().endEvent().done(); BpmnModelInstance parentProcessInstance = Bpmn.createExecutableProcess("parentProcess").startEvent().callActivity("callActivity").calledElement("subprocess").userTask().endEvent().done(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance subprocessInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess("subprocess").startEvent().userTask("userTask").endEvent("subEnd").done(); BpmnModelInstance subprocessInstance = Bpmn.createExecutableProcess("subprocess").startEvent().userTask("userTask").endEvent("subEnd").done(); testHelper.deploy(parentProcessInstance, subprocessInstance); // given I start the process, which wait as user task in subprocess ProcessInstance parentPI = runtimeService.startProcessInstanceByKey("parentProcess"); assertNotNull(taskService.createTaskQuery().taskName("userTask").singleResult()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.runtime.ProcessInstance subprocess = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").singleResult(); ProcessInstance subprocess = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").singleResult(); assertNotNull(subprocess); // when I do process instance modification runtimeService.createProcessInstanceModification(subprocess.ProcessInstanceId).cancelAllForActivity("userTask").startAfterActivity("userTask").execute(); // then the parent process instance is still active assertThat(runtimeService.createProcessInstanceQuery().count(), @is(1L)); Task task = taskService.createTaskQuery().singleResult(); assertThat(task.ProcessInstanceId, @is(parentPI.Id)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeleteCascadeProcessDefinitionDisabledTenantCheck() public virtual void testDeleteCascadeProcessDefinitionDisabledTenantCheck() { //given deployment with a process definition and process instances BpmnModelInstance bpmnModel = Bpmn.createExecutableProcess("process").startEvent().userTask().endEvent().done(); testRule.deployForTenant(TENANT_ONE, bpmnModel); //tenant check disabled processEngineConfiguration.TenantCheckEnabled = false; ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); ProcessDefinition processDefinition = processDefinitionQuery.processDefinitionKey("process").singleResult(); engineRule.RuntimeService.createProcessInstanceByKey("process").executeWithVariablesInReturn(); //user with no authentication identityService.setAuthentication("user", null, null); //when the corresponding process definition is cascading deleted from the deployment repositoryService.deleteProcessDefinition(processDefinition.Id, true); //then exist no process instance and one definition, because test case deployes per default one definition identityService.clearAuthentication(); assertEquals(0, engineRule.RuntimeService.createProcessInstanceQuery().count()); if (processEngineConfiguration.HistoryLevel.Id >= org.camunda.bpm.engine.impl.history.HistoryLevel_Fields.HISTORY_LEVEL_ACTIVITY.Id) { assertEquals(0, engineRule.HistoryService.createHistoricActivityInstanceQuery().count()); } assertThat(repositoryService.createProcessDefinitionQuery().count(), @is(1L)); assertThat(repositoryService.createProcessDefinitionQuery().tenantIdIn(TENANT_ONE).count(), @is(1L)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void createBatchModification() public virtual void createBatchModification() { //given BpmnModelInstance instance = Bpmn.createExecutableProcess("process1").startEvent().userTask("user1").userTask("user2").endEvent().done(); ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(instance); IList <string> instances = new List <string>(); for (int i = 0; i < 2; i++) { ProcessInstance processInstance = engineRule.RuntimeService.startProcessInstanceByKey("process1"); instances.Add(processInstance.Id); } authRule.init(scenario).withUser("userId").bindResource("batchId", "*").start(); // when engineRule.RuntimeService.createModification(processDefinition.Id).startAfterActivity("user1").processInstanceIds(instances).executeAsync(); // then if (authRule.assertScenario(scenario)) { Batch batch = engineRule.ManagementService.createBatchQuery().singleResult(); assertEquals("userId", batch.CreateUserId); } }
protected internal virtual Deployment deploy(BpmnModelInstance modelInstance) { DeploymentBuilder deploymentbuilder = processEngineConfiguration.RepositoryService.createDeployment(); deploymentbuilder.addModelInstance("process0.bpmn", modelInstance); return(testRule.deploy(deploymentbuilder)); }
protected internal virtual void performDeployments(Type clazz) { foreach (System.Reflection.MethodInfo method in clazz.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)) { Deployment deploymentAnnotation = method.getAnnotation(typeof(Deployment)); if (deploymentAnnotation != null) { object deploymentResource = null; try { deploymentResource = method.invoke(null, new object[0]); } catch (Exception e) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new Exception("Could not invoke method " + clazz.FullName + "#" + method.Name + " specifying a deployment", e); } if (method.ReturnType.IsAssignableFrom(typeof(string))) { string deploymentResourcePath = (string)deploymentResource; engine.RepositoryService.createDeployment().name(clazz.Name + "." + method.Name).addClasspathResource(deploymentResourcePath).deploy(); } else if (method.ReturnType.IsAssignableFrom(typeof(BpmnModelInstance))) { if (deploymentResource != null) { BpmnModelInstance instance = (BpmnModelInstance)deploymentResource; engine.RepositoryService.createDeployment().addModelInstance(clazz.Name + "." + method.Name + ".bpmn20.xml", instance).deploy(); } } } } }
protected internal virtual void addAllIn(BpmnModelInstance modelInstance, CallActivityBuilder callActivityBuilder) { CamundaIn camundaIn = modelInstance.newInstance(typeof(CamundaIn)); camundaIn.CamundaVariables = ALL; callActivityBuilder.addExtensionElement(camundaIn); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeleteProcessInstancesAsyncWithoutSkipSubprocesses() public virtual void testDeleteProcessInstancesAsyncWithoutSkipSubprocesses() { // given BpmnModelInstance callingInstance = ProcessModels.newModel(ONE_TASK_PROCESS).startEvent().callActivity().calledElement("called").endEvent().done(); BpmnModelInstance calledInstance = ProcessModels.newModel("called").startEvent().userTask().endEvent().done(); testRule.deploy(callingInstance, calledInstance); IList <string> processIds = startTestProcesses(1); // when Batch batch = runtimeService.deleteProcessInstancesAsync(processIds, null, TESTING_INSTANCE_DELETE, false, false); executeSeedJob(batch); executeBatchJobs(batch); // then ProcessInstance superInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processIds[0]).singleResult(); assertNull(superInstance); ProcessInstance subInstance = runtimeService.createProcessInstanceQuery().processDefinitionKey("called").singleResult(); assertNull(subInstance); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testMultiInstanceWithAllInOutMapping() public virtual void testMultiInstanceWithAllInOutMapping() { BpmnModelInstance modelInstance = BpmnModelInstance; CallActivityBuilder callActivityBuilder = ((CallActivity)modelInstance.getModelElementById(CALL_ACTIVITY)).builder(); addAllIn(modelInstance, callActivityBuilder); addAllOut(modelInstance, callActivityBuilder); BpmnModelInstance testProcess = BpmnSubProcessModelInstance; deployAndStartProcess(modelInstance, testProcess); assertThat(engineRule.RuntimeService.createExecutionQuery().processDefinitionKey(SUB_PROCESS_ID).list().size(), @is(2)); IList <Task> tasks = engineRule.TaskService.createTaskQuery().active().list(); foreach (Task task in tasks) { engineRule.TaskService.setVariable(task.Id, NUMBER_OF_INSTANCES, "3"); engineRule.TaskService.complete(task.Id); } assertThat(engineRule.RuntimeService.createExecutionQuery().processDefinitionKey(SUB_PROCESS_ID).list().size(), @is(0)); assertThat(engineRule.RuntimeService.createExecutionQuery().activityId(CALL_ACTIVITY).list().size(), @is(0)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void getHistoricVariableByteArrayUpdates() public virtual void getHistoricVariableByteArrayUpdates() { // given BpmnModelInstance simpleDefinition = Bpmn.createExecutableProcess("process").startEvent().endEvent().done(); testHelper.deploy(simpleDefinition); IList <string> serializable = new List <string>(); serializable.Add("one"); serializable.Add("two"); serializable.Add("three"); IDictionary <string, object> variables = new Dictionary <string, object>(); variables["var"] = serializable; runtimeService.startProcessInstanceByKey("process", variables); runtimeService.startProcessInstanceByKey("process", variables); runtimeService.startProcessInstanceByKey("process", variables); runtimeService.startProcessInstanceByKey("process", variables); // when IList <HistoricVariableUpdate> historicVariableUpdates = optimizeService.getHistoricVariableUpdates(new DateTime(1L), null, 10); // then assertThat(historicVariableUpdates.Count, @is(4)); foreach (HistoricVariableUpdate variableUpdate in historicVariableUpdates) { ObjectValue typedValue = (ObjectValue)variableUpdate.TypedValue; assertThat(typedValue.Deserialized, @is(false)); assertThat(typedValue.ValueSerialized, notNullValue()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void occurredAfterAndOccurredAtParameterWorks() public virtual void occurredAfterAndOccurredAtParameterWorks() { // given BpmnModelInstance simpleDefinition = Bpmn.createExecutableProcess("process").startEvent().endEvent().done(); testHelper.deploy(simpleDefinition); DateTime now = DateTime.Now; ClockUtil.CurrentTime = now; IDictionary <string, object> variables = new Dictionary <string, object>(); variables["stringVar"] = "value1"; runtimeService.startProcessInstanceByKey("process", variables); DateTime nowPlus2Seconds = new DateTime(now.Ticks + 2000L); ClockUtil.CurrentTime = nowPlus2Seconds; variables["stringVar"] = "value2"; runtimeService.startProcessInstanceByKey("process", variables); // when IList <HistoricVariableUpdate> variableUpdates = optimizeService.getHistoricVariableUpdates(now, now, 10); // then assertThat(variableUpdates.Count, @is(0)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testMigrateBoundaryEventOnConcurrentScopeUserTaskAndTriggerEvent() public virtual void testMigrateBoundaryEventOnConcurrentScopeUserTaskAndTriggerEvent() { // given BpmnModelInstance sourceProcess = ProcessModels.PARALLEL_SCOPE_TASKS.clone(); MigratingBpmnEventTrigger eventTrigger = eventFactory.addBoundaryEvent(rule.ProcessEngine, sourceProcess, USER_TASK_1_ID, BOUNDARY_ID); ModifiableBpmnModelInstance.wrap(sourceProcess).flowNodeBuilder(BOUNDARY_ID).userTask(AFTER_BOUNDARY_TASK).endEvent().done(); BpmnModelInstance targetProcess = modify(sourceProcess).changeElementId("boundary", "newBoundary"); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities(USER_TASK_1_ID, USER_TASK_1_ID).mapActivities(USER_TASK_2_ID, USER_TASK_2_ID).mapActivities(BOUNDARY_ID, NEW_BOUNDARY_ID).updateEventTrigger().build(); // when ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan); // then it is possible to trigger the event and successfully complete the migrated instance eventTrigger.inContextOf(NEW_BOUNDARY_ID).trigger(processInstance.Id); testHelper.completeTask(AFTER_BOUNDARY_TASK); testHelper.completeTask(USER_TASK_2_ID); testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.ProcessInstanceId); }
public virtual void testFailingAfterDeleteDeployment() { //given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance model = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess().startEvent().userTask().endEvent().done(); BpmnModelInstance model = Bpmn.createExecutableProcess().startEvent().userTask().endEvent().done(); deploymentId = processEngine.RepositoryService.createDeployment().addModelInstance("model.bpmn", model).deploy().Id; //when // 1. delete deployment // 2. it fails in post command interceptor (see FailDeleteDeploymentsPlugin) // 3. transaction is rolling back // 4. DeleteDeploymentFailListener is called try { processEngine.RepositoryService.deleteDeployment(deploymentId); } catch (Exception) { //expected exception } //then // DeleteDeploymentFailListener succeeded to registered deployments back assertEquals(1, processEngineConfiguration.RegisteredDeployments.Count); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testMigrateBoundaryEventToParallelSubProcess() public virtual void testMigrateBoundaryEventToParallelSubProcess() { // given BpmnModelInstance sourceProcess = ProcessModels.PARALLEL_SUBPROCESS_PROCESS.clone(); MigratingBpmnEventTrigger eventTrigger = eventFactory.addBoundaryEvent(rule.ProcessEngine, sourceProcess, "subProcess1", BOUNDARY_ID); ModifiableBpmnModelInstance.wrap(sourceProcess).flowNodeBuilder(BOUNDARY_ID).userTask(AFTER_BOUNDARY_TASK).endEvent().done(); BpmnModelInstance targetProcess = modify(sourceProcess).changeElementId(BOUNDARY_ID, NEW_BOUNDARY_ID); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("subProcess1", "subProcess1").mapActivities(USER_TASK_1_ID, USER_TASK_1_ID).mapActivities("subProcess2", "subProcess2").mapActivities(USER_TASK_2_ID, USER_TASK_2_ID).mapActivities(BOUNDARY_ID, NEW_BOUNDARY_ID).updateEventTrigger().build(); // when testHelper.createProcessInstanceAndMigrate(migrationPlan); // then eventTrigger.assertEventTriggerMigrated(testHelper, NEW_BOUNDARY_ID); // and it is possible to successfully complete the migrated instance testHelper.completeTask(USER_TASK_1_ID); testHelper.completeTask(USER_TASK_2_ID); testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.ProcessInstanceId); }
// when deployChangeOnly=true, new deployment should be created only for the changed resources //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testDeployChangeOnly() throws Exception public virtual void testDeployChangeOnly() { // given BpmnModelInstance model1 = Bpmn.createExecutableProcess("model1").startEvent("oldId").endEvent().done(); BpmnModelInstance model2 = Bpmn.createExecutableProcess("model1").startEvent("newId").endEvent().done(); BpmnModelInstance model3 = Bpmn.createExecutableProcess("model2").startEvent().endEvent().done(); DynamicResourceProducer.addResource("a.bpmn", model1); DynamicResourceProducer.addResource("b.bpmn", model3); createAppContext(CTX_DEPLOY_CHANGE_ONLY_PATH); // assume assertEquals(1, repositoryService.createDeploymentQuery().count()); // when ((AbstractXmlApplicationContext)applicationContext).destroy(); DynamicResourceProducer.clearResources(); DynamicResourceProducer.addResource("a.bpmn", model2); DynamicResourceProducer.addResource("b.bpmn", model3); applicationContext = new ClassPathXmlApplicationContext(CTX_DEPLOY_CHANGE_ONLY_PATH); repositoryService = (RepositoryService)applicationContext.getBean("repositoryService"); // then assertEquals(2, repositoryService.createDeploymentQuery().count()); assertEquals(3, repositoryService.createProcessDefinitionQuery().count()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeleteProcessDefinitionCascade() public virtual void testDeleteProcessDefinitionCascade() { // given process definition and a process instance BpmnModelInstance bpmnModel = Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().userTask().endEvent().done(); testHelper.deploy(bpmnModel); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult(); runtimeService.createProcessInstanceByKey(PROCESS_DEFINITION_KEY).executeWithVariablesInReturn(); authRule.init(scenario).withUser("userId").start(); //when the corresponding process definition is cascading deleted from the deployment repositoryService.deleteProcessDefinition(processDefinition.Id, true); //then exist no process instance and no definition if (authRule.assertScenario(scenario)) { assertEquals(0, runtimeService.createProcessInstanceQuery().count()); assertEquals(0, repositoryService.createProcessDefinitionQuery().count()); if (processEngineConfiguration.HistoryLevel.Id >= org.camunda.bpm.engine.impl.history.HistoryLevel_Fields.HISTORY_LEVEL_ACTIVITY.Id) { assertEquals(0, engineRule.HistoryService.createHistoricActivityInstanceQuery().count()); } } }
// Updating the bpmn20 file should lead to a new deployment when restarting the Spring container //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testResourceRedeploymentAfterProcessDefinitionChange() throws Exception public virtual void testResourceRedeploymentAfterProcessDefinitionChange() { // given BpmnModelInstance model1 = Bpmn.createExecutableProcess("model1").startEvent("oldId").endEvent().done(); BpmnModelInstance model2 = Bpmn.createExecutableProcess("model1").startEvent("newId").endEvent().done(); BpmnModelInstance model3 = Bpmn.createExecutableProcess("model2").startEvent().endEvent().done(); DynamicResourceProducer.addResource("a.bpmn", model1); DynamicResourceProducer.addResource("b.bpmn", model3); createAppContext(CTX_DYNAMIC_DEPLOY_PATH); assertEquals(1, repositoryService.createDeploymentQuery().count()); ((AbstractXmlApplicationContext)applicationContext).destroy(); // when DynamicResourceProducer.clearResources(); DynamicResourceProducer.addResource("a.bpmn", model2); DynamicResourceProducer.addResource("b.bpmn", model3); applicationContext = new ClassPathXmlApplicationContext(CTX_DYNAMIC_DEPLOY_PATH); repositoryService = (RepositoryService)applicationContext.getBean("repositoryService"); // then // Assertions come AFTER the file write! Otherwise the process file is messed up if the assertions fail. assertEquals(2, repositoryService.createDeploymentQuery().count()); assertEquals(4, repositoryService.createProcessDefinitionQuery().count()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void resultIsSortedByStartTime() public virtual void resultIsSortedByStartTime() { // given BpmnModelInstance simpleDefinition = Bpmn.createExecutableProcess("process").startEvent().userTask().endEvent().done(); testHelper.deploy(simpleDefinition); DateTime now = DateTime.Now; DateTime nowPlus1Second = new DateTime(now.Ticks + 1000L); ClockUtil.CurrentTime = nowPlus1Second; ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("process"); DateTime nowPlus2Seconds = new DateTime(now.Ticks + 2000L); ClockUtil.CurrentTime = nowPlus2Seconds; ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("process"); DateTime nowPlus4Seconds = new DateTime(nowPlus2Seconds.Ticks + 2000L); ClockUtil.CurrentTime = nowPlus4Seconds; ProcessInstance processInstance3 = runtimeService.startProcessInstanceByKey("process"); // when IList <HistoricProcessInstance> runningHistoricProcessInstances = optimizeService.getRunningHistoricProcessInstances(new DateTime(now.Ticks), null, 10); // then assertThat(runningHistoricProcessInstances.Count, @is(3)); assertThat(runningHistoricProcessInstances[0].Id, @is(processInstance1.Id)); assertThat(runningHistoricProcessInstances[1].Id, @is(processInstance2.Id)); assertThat(runningHistoricProcessInstances[2].Id, @is(processInstance3.Id)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testMigrateNonInterruptingEventSubprocessMessageTrigger() public virtual void testMigrateNonInterruptingEventSubprocessMessageTrigger() { BpmnModelInstance nonInterruptingModel = modify(EventSubProcessModels.MESSAGE_EVENT_SUBPROCESS_PROCESS).startEventBuilder(EVENT_SUB_PROCESS_START_ID).interrupting(false).done(); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(nonInterruptingModel); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(nonInterruptingModel); ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(sourceProcessDefinition.Id); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities(USER_TASK_ID, USER_TASK_ID).mapActivities(EVENT_SUB_PROCESS_START_ID, EVENT_SUB_PROCESS_START_ID).build(); // when testHelper.migrateProcessInstance(migrationPlan, processInstance); // then testHelper.assertEventSubscriptionMigrated(EVENT_SUB_PROCESS_START_ID, EVENT_SUB_PROCESS_START_ID, EventSubProcessModels.MESSAGE_NAME); // and it is possible to trigger the event subprocess rule.RuntimeService.correlateMessage(EventSubProcessModels.MESSAGE_NAME); Assert.assertEquals(2, rule.TaskService.createTaskQuery().count()); // and complete the process instance testHelper.completeTask(EVENT_SUB_PROCESS_TASK_ID); testHelper.completeTask(USER_TASK_ID); testHelper.assertProcessEnded(processInstance.Id); }
private void deploy() { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().serviceTask().camundaClass(typeof(ModelExecutionContextServiceTask).FullName).endEvent().done(); deploymentId = repositoryService.createDeployment().addModelInstance("process.bpmn", modelInstance).deploy().Id; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUpdateEventTimer() public virtual void testUpdateEventTimer() { // given ClockTestUtil.setClockToDateWithoutMilliseconds(); BpmnModelInstance sourceProcess = EventSubProcessModels.TIMER_EVENT_SUBPROCESS_PROCESS; BpmnModelInstance targetProcess = modify(EventSubProcessModels.TIMER_EVENT_SUBPROCESS_PROCESS).removeChildren(EVENT_SUB_PROCESS_START_ID).startEventBuilder(EVENT_SUB_PROCESS_START_ID).timerWithDuration("PT50M").done(); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities(USER_TASK_ID, USER_TASK_ID).mapActivities(EVENT_SUB_PROCESS_START_ID, EVENT_SUB_PROCESS_START_ID).updateEventTrigger().build(); // when testHelper.createProcessInstanceAndMigrate(migrationPlan); // then DateTime newDueDate = (new DateTime(ClockUtil.CurrentTime)).plusMinutes(50).toDate(); testHelper.assertJobMigrated(testHelper.snapshotBeforeMigration.Jobs[0], EVENT_SUB_PROCESS_START_ID, newDueDate); // and it is possible to successfully complete the migrated instance Job jobAfterMigration = testHelper.snapshotAfterMigration.Jobs[0]; rule.ManagementService.executeJob(jobAfterMigration.Id); testHelper.completeTask(EVENT_SUB_PROCESS_TASK_ID); testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.ProcessInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCompleteParentProcessWithParallelGateway() public virtual void shouldCompleteParentProcessWithParallelGateway() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance modelInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess("parentProcess").startEvent().parallelGateway().serviceTask("doNothingServiceTask").camundaExpression("${true}").moveToLastGateway().callActivity("callActivity").calledElement("subprocess").parallelGateway("mergingParallelGateway").endEvent().done(); BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("parentProcess").startEvent().parallelGateway().serviceTask("doNothingServiceTask").camundaExpression("${true}").moveToLastGateway().callActivity("callActivity").calledElement("subprocess").parallelGateway("mergingParallelGateway").endEvent().done(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance parentProcessInstance = modify(modelInstance).flowNodeBuilder("doNothingServiceTask").connectTo("mergingParallelGateway").done(); BpmnModelInstance parentProcessInstance = modify(modelInstance).flowNodeBuilder("doNothingServiceTask").connectTo("mergingParallelGateway").done(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance subprocessInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess("subprocess").startEvent().userTask("userTask").endEvent("subEnd").done(); BpmnModelInstance subprocessInstance = Bpmn.createExecutableProcess("subprocess").startEvent().userTask("userTask").endEvent("subEnd").done(); testHelper.deploy(parentProcessInstance, subprocessInstance); // given I start the process, which waits at user task in subprocess runtimeService.startProcessInstanceByKey("parentProcess"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.runtime.ProcessInstance subprocess = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").singleResult(); ProcessInstance subprocess = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").singleResult(); assertNotNull(subprocess); assertNotNull(taskService.createTaskQuery().taskName("userTask").singleResult()); // when I do process instance modification runtimeService.createProcessInstanceModification(subprocess.ProcessInstanceId).cancelAllForActivity("userTask").startAfterActivity("userTask").execute(); // then the process should be finished assertThat(runtimeService.createProcessInstanceQuery().count(), @is(0L)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUpdateEventSignalWithExpression() public virtual void testUpdateEventSignalWithExpression() { // given string newSignalNameWithExpression = "new" + EventSubProcessModels.MESSAGE_NAME + "-${var}"; BpmnModelInstance sourceProcess = EventSubProcessModels.SIGNAL_EVENT_SUBPROCESS_PROCESS; BpmnModelInstance targetProcess = modify(EventSubProcessModels.SIGNAL_EVENT_SUBPROCESS_PROCESS).renameSignal(EventSubProcessModels.SIGNAL_NAME, newSignalNameWithExpression); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities(USER_TASK_ID, USER_TASK_ID).mapActivities(EVENT_SUB_PROCESS_START_ID, EVENT_SUB_PROCESS_START_ID).updateEventTrigger().build(); Dictionary <string, object> variables = new Dictionary <string, object>(); variables["var"] = "foo"; // when testHelper.createProcessInstanceAndMigrate(migrationPlan, variables); // then string resolvedsignalName = "new" + EventSubProcessModels.MESSAGE_NAME + "-foo"; testHelper.assertEventSubscriptionMigrated(EVENT_SUB_PROCESS_START_ID, EventSubProcessModels.SIGNAL_NAME, EVENT_SUB_PROCESS_START_ID, resolvedsignalName); // and it is possible to successfully complete the migrated instance rule.RuntimeService.signalEventReceived(resolvedsignalName); testHelper.completeTask(EVENT_SUB_PROCESS_TASK_ID); testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.ProcessInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCancelConcurrentExecutionInCallingProcess() public virtual void shouldCancelConcurrentExecutionInCallingProcess() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance parentProcessInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess("parentProcess").startEvent().parallelGateway("split").callActivity("callActivity").calledElement("subprocess").endEvent().moveToLastGateway().userTask("parentUserTask").endEvent().done(); BpmnModelInstance parentProcessInstance = Bpmn.createExecutableProcess("parentProcess").startEvent().parallelGateway("split").callActivity("callActivity").calledElement("subprocess").endEvent().moveToLastGateway().userTask("parentUserTask").endEvent().done(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance subprocessInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess("subprocess").startEvent().userTask("childUserTask").endEvent("subEnd").done(); BpmnModelInstance subprocessInstance = Bpmn.createExecutableProcess("subprocess").startEvent().userTask("childUserTask").endEvent("subEnd").done(); testHelper.deploy(parentProcessInstance, subprocessInstance); ProcessInstance callingInstance = runtimeService.startProcessInstanceByKey("parentProcess"); ProcessInstance calledInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(callingInstance.Id).singleResult(); // when runtimeService.createProcessInstanceModification(calledInstance.Id).cancelAllForActivity("childUserTask").execute(); // then ProcessInstance calledInstanceAfterModification = runtimeService.createProcessInstanceQuery().processInstanceId(calledInstance.Id).singleResult(); Assert.assertNull(calledInstanceAfterModification); ExecutionTree executionTree = ExecutionTree.forExecution(callingInstance.Id, rule.ProcessEngine); assertThat(executionTree).matches(describeExecutionTree("parentUserTask").scope().done()); }
public static BpmnModelInstance prepareSignalEventProcess() { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().intermediateThrowEvent(FAILING_EVENT).camundaAsyncBefore(true).camundaFailedJobRetryTimeCycle(SCHEDULE).signal(MESSAGE).serviceTask().camundaClass(typeof(FailingDelegate).FullName).endEvent().done(); return(modelInstance); }
public virtual void testCommandContextNestedFailingCommandsNotExceptions() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance modelInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess("processThrowingThrowable").startEvent().serviceTask().camundaClass(ThrowErrorJavaDelegate.class).endEvent().done(); BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("processThrowingThrowable").startEvent().serviceTask().camundaClass(typeof(ThrowErrorJavaDelegate)).endEvent().done(); deployment(modelInstance); bool errorThrown = false; try { processEngineConfiguration.CommandExecutorTxRequired.execute(new CommandAnonymousInnerClass4(this)); fail("Exception expected"); } catch (StackOverflowError) { //OK errorThrown = true; } assertTrue(ThrowErrorJavaDelegate.executed); assertTrue(errorThrown); // Check data base consistency assertEquals(0, historyService.createHistoricProcessInstanceQuery().count()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void resultIsSortedByTimestamp() public virtual void resultIsSortedByTimestamp() { // given BpmnModelInstance simpleDefinition = Bpmn.createExecutableProcess("process").startEvent().userTask("userTask").endEvent().done(); testHelper.deploy(simpleDefinition); runtimeService.startProcessInstanceByKey("process"); string taskId = taskService.createTaskQuery().singleResult().Id; DateTime now = DateTime.Now; ClockUtil.CurrentTime = now; taskService.addCandidateUser(taskId, userId); DateTime nowPlus2Seconds = new DateTime(now.Ticks + 2000L); ClockUtil.CurrentTime = nowPlus2Seconds; taskService.deleteCandidateUser(taskId, userId); DateTime nowPlus4Seconds = new DateTime(now.Ticks + 4000L); ClockUtil.CurrentTime = nowPlus4Seconds; taskService.addCandidateUser(taskId, userId); // when IList <OptimizeHistoricIdentityLinkLogEntity> identityLinkLogs = optimizeService.getHistoricIdentityLinkLogs(pastDate(), null, 4); // then assertThat(identityLinkLogs.Count, @is(3)); assertThat(identityLinkLogs[0].OperationType, @is(IDENTITY_LINK_ADD)); assertThat(identityLinkLogs[1].OperationType, @is(IDENTITY_LINK_DELETE)); assertThat(identityLinkLogs[2].OperationType, @is(IDENTITY_LINK_ADD)); }