Пример #1
0
        public virtual void testPartialChangesDeployAll()
        {
            BpmnModelInstance model1 = Bpmn.createExecutableProcess("process1").done();
            BpmnModelInstance model2 = Bpmn.createExecutableProcess("process2").done();

            org.camunda.bpm.engine.repository.Deployment deployment1 = repositoryService.createDeployment().enableDuplicateFiltering().addModelInstance("process1.bpmn20.xml", model1).addModelInstance("process2.bpmn20.xml", model2).name("twice").deploy();

            IList <string> deploymentResources = repositoryService.getDeploymentResourceNames(deployment1.Id);

            assertEquals(2, deploymentResources.Count);

            BpmnModelInstance changedModel2 = Bpmn.createExecutableProcess("process2").startEvent().done();

            org.camunda.bpm.engine.repository.Deployment         deployment2    = repositoryService.createDeployment().enableDuplicateFiltering().addModelInstance("process1.bpmn20.xml", model1).addModelInstance("process2.bpmn20.xml", changedModel2).name("twice").deploy();
            IList <org.camunda.bpm.engine.repository.Deployment> deploymentList = repositoryService.createDeploymentQuery().list();

            assertEquals(2, deploymentList.Count);

            // there should be new versions of both processes
            assertEquals(2, repositoryService.createProcessDefinitionQuery().processDefinitionKey("process1").count());
            assertEquals(2, repositoryService.createProcessDefinitionQuery().processDefinitionKey("process2").count());

            repositoryService.deleteDeployment(deployment1.Id);
            repositoryService.deleteDeployment(deployment2.Id);
        }
Пример #2
0
        protected internal virtual void deployProcess(string scriptFormat, string scriptText)
        {
            BpmnModelInstance process    = createProcess(scriptFormat, scriptText);
            Deployment        deployment = repositoryService.createDeployment().addModelInstance("testProcess.bpmn", process).deploy();

            deploymentId = deployment.Id;
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testStartInstanceAfterDeleteLatestProcessVersion()
        public virtual void testStartInstanceAfterDeleteLatestProcessVersion()
        {
            // given a deployed process
            testRule.deploy(SINGLE_MESSAGE_START_EVENT_XML);
            // deploy second version of the process
            string deploymentId = testRule.deploy(SINGLE_MESSAGE_START_EVENT_XML).Id;

            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();

            // delete it
            repositoryService.deleteDeployment(deployment.Id, true);

            // when
            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("singleMessageStartEvent");

            assertFalse(processInstance.Ended);

            Task task = taskService.createTaskQuery().singleResult();

            assertNotNull(task);

            taskService.complete(task.Id);

            ProcessInstance completedInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.Id).singleResult();

            if (completedInstance != null)
            {
                throw new AssertionFailedError("Expected finished process instance '" + completedInstance + "' but it was still in the db");
            }
        }
Пример #4
0
        public virtual void testSetProcessDefinitionVersionSubExecutions()
        {
            // start process instance
            ProcessInstance pi = runtimeService.startProcessInstanceByKey("forkJoin");

            // check that the user tasks have been reached
            assertEquals(2, taskService.createTaskQuery().count());

            // deploy new version of the process definition
            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_WITH_PARALLEL_GATEWAY).deploy();
            assertEquals(2, repositoryService.createProcessDefinitionQuery().count());

            // migrate process instance to new process definition version
            CommandExecutor commandExecutor = processEngineConfiguration.CommandExecutorTxRequired;

            commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.Id, 2));

            // check that all executions of the instance now use the new process definition version
            ProcessDefinition newProcessDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(2).singleResult();
            IList <Execution> executions           = runtimeService.createExecutionQuery().processInstanceId(pi.Id).list();

            foreach (Execution execution in executions)
            {
                assertEquals(newProcessDefinition.Id, ((ExecutionEntity)execution).ProcessDefinitionId);
            }

            // undeploy "manually" deployed process definition
            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #5
0
        protected internal virtual void initializeCallableElement(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context)
        {
            Deployment deployment   = context.Deployment;
            string     deploymentId = null;

            if (deployment != null)
            {
                deploymentId = deployment.Id;
            }

            BaseCallableElement callableElement = createCallableElement();

            callableElement.DeploymentId = deploymentId;

            // set callableElement on behavior
            CallingTaskActivityBehavior behavior = (CallingTaskActivityBehavior)activity.ActivityBehavior;

            behavior.CallableElement = callableElement;

            // definition key
            initializeDefinitionKey(element, activity, context, callableElement);

            // binding
            initializeBinding(element, activity, context, callableElement);

            // version
            initializeVersion(element, activity, context, callableElement);

            // tenant-id
            initializeTenantId(element, activity, context, callableElement);
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @OperateOnDeployment("clientDeployment") public void shouldSwitchContextWhenUsingDecisionServiceAfterRedeployment()
        public virtual void shouldSwitchContextWhenUsingDecisionServiceAfterRedeployment()
        {
            // given
            IList <org.camunda.bpm.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery().list();

            // find dmn deployment
            org.camunda.bpm.engine.repository.Deployment dmnDeployment = null;
            foreach (org.camunda.bpm.engine.repository.Deployment deployment in deployments)
            {
                IList <string> resourceNames = repositoryService.getDeploymentResourceNames(deployment.Id);
                if (resourceNames.Contains(DMN_RESOURCE_NAME))
                {
                    dmnDeployment = deployment;
                }
            }

            if (dmnDeployment == null)
            {
                Assert.fail("Expected to find DMN deployment");
            }

            org.camunda.bpm.engine.repository.Deployment deployment2 = repositoryService.createDeployment().nameFromDeployment(dmnDeployment.Id).addDeploymentResources(dmnDeployment.Id).deploy();

            try
            {
                // when then
                DmnDecisionTableResult decisionResult = decisionService.evaluateDecisionTableByKey("decision", Variables.createVariables());
                assertEquals("ok", decisionResult.FirstResult.FirstEntry);
            }
            finally
            {
                repositoryService.deleteDeployment(deployment2.Id, true);
            }
        }
Пример #7
0
//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()
        {
            Assert.assertNotNull(processEngine);
            RepositoryService repositoryService = processEngine.RepositoryService;

            IList <ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().processDefinitionKey("testDeployProcessArchive").list();

            Assert.assertEquals(1, processDefinitions.Count);
            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(processDefinitions[0].DeploymentId).singleResult();

            ISet <string> registeredProcessApplications = BpmPlatform.ProcessApplicationService.ProcessApplicationNames;

            bool containsProcessApplication = false;

            // the process application name is used as name for the db deployment
            foreach (string appName in registeredProcessApplications)
            {
                if (appName.Equals(deployment.Name))
                {
                    containsProcessApplication = true;
                }
            }
            assertTrue(containsProcessApplication);


            // manually delete process definition here (to clean up)
            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #8
0
        public virtual void testQueryByProcessDefinitionId()
        {
            // given
            org.camunda.bpm.engine.repository.Deployment secondDeployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml").deploy();

            IList <ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list();

            startInstancesById(processDefinitions[0].Id, 3);
            startInstancesById(processDefinitions[1].Id, 2);

            // when
            IList <ExternalTask> definition1Tasks = externalTaskService.createExternalTaskQuery().processDefinitionId(processDefinitions[0].Id).list();
            IList <ExternalTask> definition2Tasks = externalTaskService.createExternalTaskQuery().processDefinitionId(processDefinitions[1].Id).list();

            // then
            assertEquals(3, definition1Tasks.Count);
            foreach (ExternalTask task in definition1Tasks)
            {
                assertEquals(processDefinitions[0].Id, task.ProcessDefinitionId);
            }

            assertEquals(2, definition2Tasks.Count);
            foreach (ExternalTask task in definition2Tasks)
            {
                assertEquals(processDefinitions[1].Id, task.ProcessDefinitionId);
            }

            // cleanup
            repositoryService.deleteDeployment(secondDeployment.Id, true);
        }
Пример #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDeploymentStatisticsQuery()
        public virtual void testDeploymentStatisticsQuery()
        {
            string deploymentName = "my deployment";

            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testMultiInstanceStatisticsQuery.bpmn20.xml").addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testParallelGatewayStatisticsQuery.bpmn20.xml").name(deploymentName).deploy();
            runtimeService.startProcessInstanceByKey("MIExampleProcess");
            runtimeService.startProcessInstanceByKey("ParGatewayExampleProcess");

            IList <DeploymentStatistics> statistics = managementService.createDeploymentStatisticsQuery().includeFailedJobs().list();

            Assert.assertEquals(1, statistics.Count);

            DeploymentStatistics result = statistics[0];

            Assert.assertEquals(2, result.Instances);
            Assert.assertEquals(0, result.FailedJobs);

            Assert.assertEquals(deployment.Id, result.Id);
            Assert.assertEquals(deploymentName, result.Name);

            // only compare time on second level (i.e. drop milliseconds)
            DateTime cal1 = new DateTime();

            cal1 = new DateTime(deployment.DeploymentTime);
            cal1.set(DateTime.MILLISECOND, 0);

            DateTime cal2 = new DateTime();

            cal2 = new DateTime(result.DeploymentTime);
            cal2.set(DateTime.MILLISECOND, 0);

            Assert.assertTrue(cal1.Equals(cal2));

            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #10
0
        public virtual void testProcessDefinitionStatisticsQueryForMultipleVersionsWithIncidentType()
        {
            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml").deploy();

            IList <ProcessDefinition> definitions = repositoryService.createProcessDefinitionQuery().processDefinitionKey("ExampleProcess").list();

            foreach (ProcessDefinition definition in definitions)
            {
                runtimeService.startProcessInstanceById(definition.Id);
            }

            executeAvailableJobs();

            IList <ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeFailedJobs().includeIncidentsForType("failedJob").list();

            Assert.assertEquals(2, statistics.Count);

            ProcessDefinitionStatistics definitionResult = statistics[0];

            Assert.assertEquals(1, definitionResult.Instances);
            Assert.assertEquals(0, definitionResult.FailedJobs);

            assertTrue(definitionResult.IncidentStatistics.Count == 0);

            definitionResult = statistics[1];
            Assert.assertEquals(1, definitionResult.Instances);
            Assert.assertEquals(0, definitionResult.FailedJobs);

            assertTrue(definitionResult.IncidentStatistics.Count == 0);

            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #11
0
        public virtual void testPreserveTimestampOnUpdatedIncident()
        {
            // given
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneJobProcess", Variables.createVariables().putValue("shouldFail", true));

            executeAvailableJobs();

            Incident incident = runtimeService.createIncidentQuery().singleResult();

            assertNotNull(incident);

            DateTime timestamp = incident.IncidentTimestamp;

            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_ONE_JOB).deploy();

            ProcessDefinition newDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.Id).singleResult();

            assertNotNull(newDefinition);

            // when
            CommandExecutor commandExecutor = processEngineConfiguration.CommandExecutorTxRequired;

            commandExecutor.execute(new SetProcessDefinitionVersionCmd(instance.Id, 2));

            Incident migratedIncident = runtimeService.createIncidentQuery().singleResult();

            // then
            assertEquals(timestamp, migratedIncident.IncidentTimestamp);

            // cleanup
            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #12
0
        public virtual void testConcurrencyInSubProcess()
        {
            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/subprocess/SubProcessTest.fixSystemFailureProcess.bpmn20.xml").deploy();

            // After staring the process, both tasks in the subprocess should be active
            ProcessInstance pi    = runtimeService.startProcessInstanceByKey("fixSystemFailure");
            IList <Task>    tasks = taskService.createTaskQuery().processInstanceId(pi.Id).orderByTaskName().asc().list();

            // Tasks are ordered by name (see query)
            assertEquals(2, tasks.Count);
            Task investigateHardwareTask = tasks[0];
            Task investigateSoftwareTask = tasks[1];

            assertEquals("Investigate hardware", investigateHardwareTask.Name);
            assertEquals("Investigate software", investigateSoftwareTask.Name);

            // Completing both the tasks finishes the subprocess and enables the task after the subprocess
            taskService.complete(investigateHardwareTask.Id);
            taskService.complete(investigateSoftwareTask.Id);

            Task writeReportTask = taskService.createTaskQuery().processInstanceId(pi.Id).singleResult();

            assertEquals("Write report", writeReportTask.Name);

            // Clean up
            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #13
0
        public virtual void testDeployAndRemoveAsyncActivity()
        {
            ISet <string> deployments = new HashSet <string>();

            try
            {
                // given a deployment that contains a process called "process" with an async task "task"
                org.camunda.bpm.engine.repository.Deployment deployment1 = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/async/AsyncTaskTest.testDeployAndRemoveAsyncActivity.v1.bpmn20.xml").deploy();
                deployments.Add(deployment1.Id);

                // when redeploying the process where that task is not contained anymore
                org.camunda.bpm.engine.repository.Deployment deployment2 = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/async/AsyncTaskTest.testDeployAndRemoveAsyncActivity.v2.bpmn20.xml").deploy();
                deployments.Add(deployment2.Id);

                // and clearing the deployment cache (note that the equivalent of this in a real-world
                // scenario would be making the deployment with a different engine
                processEngineConfiguration.DeploymentCache.discardProcessDefinitionCache();

                // then it should be possible to load the latest process definition
                ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
                assertNotNull(processInstance);
            }
            finally
            {
                foreach (string deploymentId in deployments)
                {
                    repositoryService.deleteDeployment(deploymentId, true);
                }
            }
        }
Пример #14
0
        public virtual void testSetProcessDefinitionVersionWithCallActivity()
        {
            // start process instance
            ProcessInstance pi = runtimeService.startProcessInstanceByKey("parentProcess");

            // check that receive task has been reached
            Execution execution = runtimeService.createExecutionQuery().activityId("waitState1").processDefinitionKey("childProcess").singleResult();

            assertNotNull(execution);

            // deploy new version of the process definition
            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_CALL_ACTIVITY).deploy();
            assertEquals(2, repositoryService.createProcessDefinitionQuery().processDefinitionKey("parentProcess").count());

            // migrate process instance to new process definition version
            CommandExecutor commandExecutor = processEngineConfiguration.CommandExecutorTxRequired;

            commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.Id, 2));

            // signal process instance
            runtimeService.signal(execution.Id);

            // should be finished now
            assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(pi.Id).count());

            // undeploy "manually" deployed process definition
            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #15
0
        public virtual void testSetProcessDefinitionVersionActivityMissing()
        {
            // start process instance
            ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");

            // check that receive task has been reached
            Execution execution = runtimeService.createExecutionQuery().activityId("waitState1").singleResult();

            assertNotNull(execution);

            // deploy new version of the process definition
            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_ACTIVITY_MISSING).deploy();
            assertEquals(2, repositoryService.createProcessDefinitionQuery().count());

            // migrate process instance to new process definition version
            CommandExecutor commandExecutor = processEngineConfiguration.CommandExecutorTxRequired;
            SetProcessDefinitionVersionCmd setProcessDefinitionVersionCmd = new SetProcessDefinitionVersionCmd(pi.Id, 2);

            try
            {
                commandExecutor.execute(setProcessDefinitionVersionCmd);
                fail("ProcessEngineException expected");
            }
            catch (ProcessEngineException ae)
            {
                assertTextPresent("The new process definition (key = 'receiveTask') does not contain the current activity (id = 'waitState1') of the process instance (id = '", ae.Message);
            }

            // undeploy "manually" deployed process definition
            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #16
0
        public virtual void testNoRegistrationCheckIfNoProcessApplicationIsDeployed()
        {
            // create two deployments; both contain a process with the same key
            Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(BPMN_RESOURCE, createProcessWithServiceTask(PROCESS_KEY)).deploy();

            Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResources(deployment1.Id).deploy();

            // assume an empty deployment cache (e.g. on a different engine)
            processEngineConfiguration.DeploymentCache.discardProcessDefinitionCache();

            // then starting a process instance for the latest version
            //
            // The context switch mechanism for process definitions in redeployments
            // is to look up the process application registration from a previous version
            // of the same process. This can trigger fetching these process definitions
            // from the database.
            //
            // In case where there are no process application registrations anyway (e.g. embedded engine),
            // this logic should not be executed.
            runtimeService.startProcessInstanceByKey(PROCESS_KEY);

            ProcessDefinition version1 = repositoryService.createProcessDefinitionQuery().deploymentId(deployment1.Id).singleResult();
            ProcessDefinition version2 = repositoryService.createProcessDefinitionQuery().deploymentId(deployment2.Id).singleResult();

            // accordingly the process definition cache should only contain the latest version now
            Cache cache = processEngineConfiguration.DeploymentCache.ProcessDefinitionCache;

            assertNotNull(cache.get(version2.Id));
            assertNull(cache.get(version1.Id));

            deleteDeployments(deployment1, deployment2);
        }
Пример #17
0
//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);
        }
Пример #18
0
        public virtual void testSetProcessDefinitionVersionMigrateIncident()
        {
            // given a process instance
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneJobProcess", Variables.createVariables().putValue("shouldFail", true));

            // with a failed job
            executeAvailableJobs();

            // and an incident
            Incident incident = runtimeService.createIncidentQuery().singleResult();

            assertNotNull(incident);

            // and a second deployment of the process
            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_ONE_JOB).deploy();

            ProcessDefinition newDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.Id).singleResult();

            assertNotNull(newDefinition);

            // when the process instance is migrated
            CommandExecutor commandExecutor = processEngineConfiguration.CommandExecutorTxRequired;

            commandExecutor.execute(new SetProcessDefinitionVersionCmd(instance.Id, 2));

            // then the the incident should also be migrated
            Incident migratedIncident = runtimeService.createIncidentQuery().singleResult();

            assertNotNull(migratedIncident);
            assertEquals(newDefinition.Id, migratedIncident.ProcessDefinitionId);
            assertEquals(instance.Id, migratedIncident.ProcessInstanceId);
            assertEquals(instance.Id, migratedIncident.ExecutionId);

            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #19
0
        private void deployModelInstance(BpmnModelInstance modelInstance)
        {
            DeploymentBuilder deploymentbuilder = repositoryService.createDeployment();

            deploymentbuilder.addModelInstance("process0.bpmn", modelInstance);
            Deployment deployment = deploymentbuilder.deploy();

            rule.manageDeployment(deployment);
        }
Пример #20
0
        public virtual void testParsePriorityOnNonAsyncActivity()
        {
            // deploying a process definition where the activity
            // has a priority but defines no jobs succeeds
            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/job/JobPrioritizationBpmnTest.testParsePriorityOnNonAsyncActivity.bpmn20.xml").deploy();

            // cleanup
            repositoryService.deleteDeployment(deployment.Id);
        }
Пример #21
0
        public virtual void testDeployTimeConversion()
        {
            // when
            Deployment deployment = repositoryService.createDeploymentQuery().deploymentName(DEPLOYMENT_NAME).singleResult();

            // assume
            assertNotNull(deployment);

            // then
            assertThat(deployment.DeploymentTime, @is(TIMESTAMP));
        }
Пример #22
0
        public virtual Void execute(CommandContext commandContext)
        {
            Deployment deployment = commandContext.DeploymentManager.findDeploymentById(deploymentId);

            ensureNotNull("Deployment " + deploymentId + " does not exist", "deployment", deployment);

            commandContext.AuthorizationManager.checkCamundaAdmin();

            Context.ProcessEngineConfiguration.RegisteredDeployments.Add(deploymentId);
            return(null);
        }
Пример #23
0
        public virtual void testTimerStartEventPriorityOnActivity()
        {
            // given a timer start job
            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/job/JobPrioritizationBpmnConstantValueTest.testTimerStartEventPriorityOnActivity.bpmn20.xml").deploy();

            Job job = managementService.createJobQuery().singleResult();

            // then the timer start job has the priority defined in the process definition
            assertEquals(1515, job.Priority);

            // cleanup
            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #24
0
        public virtual void testProcessDefinitionStatisticsQueryForMultipleVersionsWithFailedJobsAndIncidents()
        {
            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml").deploy();

            IList <ProcessDefinition> definitions = repositoryService.createProcessDefinitionQuery().processDefinitionKey("ExampleProcess").list();

            IDictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["fail"] = true;

            foreach (ProcessDefinition definition in definitions)
            {
                runtimeService.startProcessInstanceById(definition.Id, parameters);
            }

            executeAvailableJobs();

            IList <ProcessDefinitionStatistics> statistics = managementService.createProcessDefinitionStatisticsQuery().includeFailedJobs().includeIncidents().list();

            Assert.assertEquals(2, statistics.Count);

            ProcessDefinitionStatistics definitionResult = statistics[0];

            Assert.assertEquals(1, definitionResult.Instances);
            Assert.assertEquals(1, definitionResult.FailedJobs);

            IList <IncidentStatistics> incidentStatistics = definitionResult.IncidentStatistics;

            assertFalse(incidentStatistics.Count == 0);
            assertEquals(1, incidentStatistics.Count);

            IncidentStatistics incident = incidentStatistics[0];

            assertEquals(org.camunda.bpm.engine.runtime.Incident_Fields.FAILED_JOB_HANDLER_TYPE, incident.IncidentType);
            assertEquals(1, incident.IncidentCount);

            definitionResult = statistics[1];
            Assert.assertEquals(1, definitionResult.Instances);
            Assert.assertEquals(1, definitionResult.FailedJobs);

            incidentStatistics = definitionResult.IncidentStatistics;
            assertFalse(incidentStatistics.Count == 0);
            assertEquals(1, incidentStatistics.Count);

            incident = incidentStatistics[0];

            assertEquals(org.camunda.bpm.engine.runtime.Incident_Fields.FAILED_JOB_HANDLER_TYPE, incident.IncidentType);
            assertEquals(1, incident.IncidentCount);

            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #25
0
        public virtual void testOpLogSetProcessDefinitionVersionCmd()
        {
            // given
            try
            {
                identityService.AuthenticatedUserId = "demo";
                string resource = "org/camunda/bpm/engine/test/api/runtime/migration/SetProcessDefinitionVersionCmdTest.bpmn";

                // Deployments
                org.camunda.bpm.engine.repository.Deployment firstDeployment = repositoryService.createDeployment().addClasspathResource(resource).deploy();

                org.camunda.bpm.engine.repository.Deployment secondDeployment = repositoryService.createDeployment().addClasspathResource(resource).deploy();

                // Process definitions
                ProcessDefinition processDefinitionV1 = repositoryService.createProcessDefinitionQuery().deploymentId(firstDeployment.Id).singleResult();

                ProcessDefinition processDefinitionV2 = repositoryService.createProcessDefinitionQuery().deploymentId(secondDeployment.Id).singleResult();

                // start process instance
                ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinitionV1.Id);

                // when
                setProcessDefinitionVersion(processInstance.Id, 2);

                // then
                ProcessInstance processInstanceAfterMigration = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.Id).singleResult();
                assertEquals(processDefinitionV2.Id, processInstanceAfterMigration.ProcessDefinitionId);

                if (processEngineConfiguration.HistoryLevel.Equals(org.camunda.bpm.engine.impl.history.HistoryLevel_Fields.HISTORY_LEVEL_FULL))
                {
                    IList <UserOperationLogEntry> userOperations = historyService.createUserOperationLogQuery().processInstanceId(processInstance.Id).operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE).list();

                    assertEquals(1, userOperations.Count);

                    UserOperationLogEntry userOperationLogEntry = userOperations[0];
                    assertEquals("processDefinitionVersion", userOperationLogEntry.Property);
                    assertEquals("1", userOperationLogEntry.OrgValue);
                    assertEquals("2", userOperationLogEntry.NewValue);
                }

                // Clean up the test
                repositoryService.deleteDeployment(firstDeployment.Id, true);
                repositoryService.deleteDeployment(secondDeployment.Id, true);
            }
            finally
            {
                identityService.clearAuthentication();
            }
        }
Пример #26
0
        public virtual void testMigrateJobWithMultipleDefinitionsOnActivity()
        {
            // given a process instance
            ProcessInstance asyncAfterInstance = runtimeService.startProcessInstanceByKey("twoJobsProcess");

            // with an async after job
            string jobId = managementService.createJobQuery().singleResult().Id;

            managementService.executeJob(jobId);
            Job asyncAfterJob = managementService.createJobQuery().singleResult();

            // and a process instance with an before after job
            ProcessInstance asyncBeforeInstance = runtimeService.startProcessInstanceByKey("twoJobsProcess");
            Job             asyncBeforeJob      = managementService.createJobQuery().processInstanceId(asyncBeforeInstance.Id).singleResult();

            // and a second deployment of the process
            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_TWO_JOBS).deploy();

            ProcessDefinition newDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.Id).singleResult();

            assertNotNull(newDefinition);

            JobDefinition asnycBeforeJobDefinition = managementService.createJobDefinitionQuery().jobConfiguration(MessageJobDeclaration.ASYNC_BEFORE).processDefinitionId(newDefinition.Id).singleResult();
            JobDefinition asnycAfterJobDefinition  = managementService.createJobDefinitionQuery().jobConfiguration(MessageJobDeclaration.ASYNC_AFTER).processDefinitionId(newDefinition.Id).singleResult();

            assertNotNull(asnycBeforeJobDefinition);
            assertNotNull(asnycAfterJobDefinition);

            // when the process instances are migrated
            CommandExecutor commandExecutor = processEngineConfiguration.CommandExecutorTxRequired;

            commandExecutor.execute(new SetProcessDefinitionVersionCmd(asyncBeforeInstance.Id, 2));
            commandExecutor.execute(new SetProcessDefinitionVersionCmd(asyncAfterInstance.Id, 2));

            // then the the job's definition reference should also be migrated
            Job migratedAsyncBeforeJob = managementService.createJobQuery().processInstanceId(asyncBeforeInstance.Id).singleResult();

            assertEquals(asyncBeforeJob.Id, migratedAsyncBeforeJob.Id);
            assertNotNull(migratedAsyncBeforeJob);
            assertEquals(asnycBeforeJobDefinition.Id, migratedAsyncBeforeJob.JobDefinitionId);

            Job migratedAsyncAfterJob = managementService.createJobQuery().processInstanceId(asyncAfterInstance.Id).singleResult();

            assertEquals(asyncAfterJob.Id, migratedAsyncAfterJob.Id);
            assertNotNull(migratedAsyncAfterJob);
            assertEquals(asnycAfterJobDefinition.Id, migratedAsyncAfterJob.JobDefinitionId);

            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #27
0
        public virtual void testTxListenersInvokeAsync()
        {
            BpmnModelInstance process = Bpmn.createExecutableProcess("testProcess").startEvent().camundaAsyncBefore().camundaAsyncAfter().endEvent().done();

            Deployment deployment = repositoryService.createDeployment().addModelInstance("testProcess.bpmn", process).deploy();

            ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess");

            waitForJobExecutorToProcessAllJobs(6000);


            assertProcessEnded(pi.Id);

            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void deployTestProcesses() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void deployTestProcesses()
        {
            org.camunda.bpm.engine.repository.Deployment deployment = engineRule.RepositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml").addClasspathResource("org/camunda/bpm/engine/test/api/externaltask/externalTaskPriorityExpression.bpmn20.xml").deploy();

            engineRule.manageDeployment(deployment);

            RuntimeService runtimeService = engineRule.RuntimeService;

            processInstanceIds = new List <string>();
            for (int i = 0; i < 4; i++)
            {
                processInstanceIds.Add(runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY, i + "").Id);
            }
            processInstanceIds.Add(runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY_2).Id);
        }
Пример #29
0
        public virtual void testSetProcessDefinitionVersionWithMultipleParents()
        {
            // start process instance
            ProcessInstance pi = runtimeService.startProcessInstanceByKey("multipleJoins");

            // check that the user tasks have been reached
            assertEquals(2, taskService.createTaskQuery().count());

            //finish task1
            Task task = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();

            taskService.complete(task.Id);

            //we have reached task4
            task = taskService.createTaskQuery().taskDefinitionKey("task4").singleResult();
            assertNotNull(task);

            //The timer job has been created
            Job job = managementService.createJobQuery().executionId(task.ExecutionId).singleResult();

            assertNotNull(job);

            // check there are 2 user tasks task4 and task2
            assertEquals(2, taskService.createTaskQuery().count());

            // deploy new version of the process definition
            org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_WITH_MULTIPLE_PARENTS).deploy();
            assertEquals(2, repositoryService.createProcessDefinitionQuery().count());

            // migrate process instance to new process definition version
            CommandExecutor commandExecutor = processEngineConfiguration.CommandExecutorTxRequired;

            commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.Id, 2));

            // check that all executions of the instance now use the new process definition version
            ProcessDefinition newProcessDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(2).singleResult();
            IList <Execution> executions           = runtimeService.createExecutionQuery().processInstanceId(pi.Id).list();

            foreach (Execution execution in executions)
            {
                assertEquals(newProcessDefinition.Id, ((ExecutionEntity)execution).ProcessDefinitionId);
            }

            // undeploy "manually" deployed process definition
            repositoryService.deleteDeployment(deployment.Id, true);
        }
Пример #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void init()
        public virtual void init()
        {
            StartProcessOnAnotherEngineDelegate.engine = engine2BootstrapRule.ProcessEngine;
            NestedProcessStartDelegate.engine          = engineRule1.ProcessEngine;

            // given
            Deployment deployment1 = engineRule1.RepositoryService.createDeployment().addModelInstance("foo.bpmn", PROCESS_MODEL).deploy();

            Deployment deployment2 = engineRule1.RepositoryService.createDeployment().addModelInstance("boo.bpmn", PROCESS_MODEL_2).deploy();

            engineRule1.manageDeployment(deployment1);
            engineRule1.manageDeployment(deployment2);

            Deployment deployment3 = engineRule2.ProcessEngine.RepositoryService.createDeployment().addModelInstance("joo.bpmn", ONE_TASK_PROCESS_MODEL).deploy();

            engineRule2.manageDeployment(deployment3);
        }