Ejemplo n.º 1
0
        private void deployAndStartTestProcess(string elementId, string eventName)
        {
            BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID).startEvent(START_ID).sequenceFlowId(SEQUENCE_FLOW_ID).intermediateCatchEvent(CATCH_EVENT_ID).parallelGateway(GATEWAY_ID).userTask(USER_TASK_ID).endEvent(END_ID).done();

            addMessageEventDefinition((CatchEvent)modelInstance.getModelElementById(CATCH_EVENT_ID));
            addExecutionListener((BaseElement)modelInstance.getModelElementById(elementId), eventName);
            deployAndStartProcess(modelInstance);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeClass public static void createModelInstance()
        public static void createModelInstance()
        {
            modelInstance = Bpmn.createProcess().startEvent().id("start").userTask().id("user").parallelGateway().id("gateway1").serviceTask().endEvent().moveToLastGateway().parallelGateway().id("gateway2").userTask().endEvent().moveToLastGateway().serviceTask().endEvent().moveToLastGateway().scriptTask().endEvent().done();

            startSucceeding    = ((FlowNode)modelInstance.getModelElementById("start")).SucceedingNodes;
            gateway1Succeeding = ((FlowNode)modelInstance.getModelElementById("gateway1")).SucceedingNodes;
            gateway2Succeeding = ((FlowNode)modelInstance.getModelElementById("gateway2")).SucceedingNodes;
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testGetDataStore()
        public virtual void testGetDataStore()
        {
            DataStore dataStore = modelInstance.getModelElementById("myDataStore");

            assertThat(dataStore).NotNull;
            assertThat(dataStore.Name).isEqualTo("My Data Store");
            assertThat(dataStore.Capacity).isEqualTo(23);
            assertThat(dataStore.Unlimited).False;
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void parseModel()
        public virtual void parseModel()
        {
            modelInstance        = Bpmn.readModelFromStream(this.GetType().getResourceAsStream(this.GetType().Name + ".xml"));
            flow1                = modelInstance.getModelElementById("flow1");
            flow2                = modelInstance.getModelElementById("flow2");
            flow3                = modelInstance.getModelElementById("flow3");
            conditionExpression1 = flow1.ConditionExpression;
            conditionExpression2 = flow2.ConditionExpression;
            conditionExpression3 = flow3.ConditionExpression;
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testGetTextAnnotationById()
        public virtual void testGetTextAnnotationById()
        {
            TextAnnotation textAnnotation = modelInstance.getModelElementById("textAnnotation2");

            assertThat(textAnnotation).NotNull;
            assertThat(textAnnotation.TextFormat).isEqualTo("text/plain");
            Text text = textAnnotation.Text;

            assertThat(text.TextContent).isEqualTo("Attached text annotation");
        }
Ejemplo n.º 6
0
//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));
        }
Ejemplo n.º 7
0
        public static void initEndEvent(BpmnModelInstance modelInstance, string endEventId)
        {
            EndEvent endEvent = modelInstance.getModelElementById(endEventId);
            TerminateEventDefinition terminateDefinition = modelInstance.newInstance(typeof(TerminateEventDefinition));

            endEvent.addChildElement(terminateDefinition);
        }
Ejemplo n.º 8
0
        public virtual void testRetryOnServiceTaskLikeMessageThrowEvent()
        {
            // given
            BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess("process").startEvent().intermediateThrowEvent().camundaAsyncBefore().camundaFailedJobRetryTimeCycle("R10/PT5S").messageEventDefinition("messageDefinition").message("message").messageEventDefinitionDone().endEvent().done();

            MessageEventDefinition messageDefinition = bpmnModelInstance.getModelElementById("messageDefinition");

//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            messageDefinition.CamundaClass = typeof(FailingDelegate).FullName;

            deployment(bpmnModelInstance);

            runtimeService.startProcessInstanceByKey("process");

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

            // when job fails
            try
            {
                managementService.executeJob(job.Id);
            }
            catch (Exception)
            {
                // ignore
            }

            // then
            job = managementService.createJobQuery().singleResult();
            Assert.assertEquals(9, job.Retries);
        }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testGetDataObject()
        public virtual void testGetDataObject()
        {
            DataObject     dataObject     = modelInstance.getModelElementById("_21");
            ItemDefinition itemDefinition = modelInstance.getModelElementById("_100");

            assertThat(dataObject).NotNull;
            assertThat(dataObject.Name).isEqualTo("DataObject _21");
            assertThat(dataObject.Collection).False;
            assertThat(dataObject.ItemSubject).isEqualTo(itemDefinition);
        }
Ejemplo n.º 10
0
        // Helper methods //////////////////////////////////////////////

        private void createAndDeployModelForClass(Type delegateClass)
        {
            BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_DEF_KEY).startEvent().manualTask("templateTask").endEvent().done();

            // replace the template task with the actual task provided by the subtask
            modelInstance.getModelElementById("templateTask").replaceWithElement(createModelAccessTask(modelInstance, delegateClass));

            deployModel(modelInstance);
        }
Ejemplo n.º 11
0
        protected internal static void addTaskListener(BpmnModelInstance targetModel, string activityId, string @event, string className)
        {
            CamundaTaskListener taskListener = targetModel.newInstance(typeof(CamundaTaskListener));

            taskListener.CamundaClass = className;
            taskListener.CamundaEvent = @event;

            UserTask task = targetModel.getModelElementById(activityId);

            task.builder().addExtensionElement(taskListener);
        }
Ejemplo n.º 12
0
        private void deployProcess(string eventName)
        {
            BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().userTask(USER_TASK_ID).endEvent().done();

            ExtensionElements    extensionElements = modelInstance.newInstance(typeof(ExtensionElements));
            ModelElementInstance taskListener      = extensionElements.addExtensionElement(CAMUNDA_NS, "taskListener");

//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            taskListener.setAttributeValueNs(CAMUNDA_NS, "class", typeof(ModelExecutionContextTaskListener).FullName);
            taskListener.setAttributeValueNs(CAMUNDA_NS, "event", eventName);

            UserTask userTask = modelInstance.getModelElementById(USER_TASK_ID);

            userTask.ExtensionElements = extensionElements;

            deploymentId = repositoryService.createDeployment().addModelInstance("process.bpmn", modelInstance).deploy().Id;
        }
Ejemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void modifyingElementWithActivitiNsKeepsIt()
        public virtual void modifyingElementWithActivitiNsKeepsIt()
        {
            BpmnModelInstance modelInstance     = Bpmn.readModelFromStream(typeof(CamundaExtensionsTest).getResourceAsStream("CamundaExtensionsCompatabilityTest.xml"));
            ProcessImpl       process           = modelInstance.getModelElementById(PROCESS_ID);
            ExtensionElements extensionElements = process.ExtensionElements;
            ICollection <CamundaExecutionListener> listeners = extensionElements.getChildElementsByType(typeof(CamundaExecutionListener));
            string listenerClass = "org.foo.Bar";

            foreach (CamundaExecutionListener listener in listeners)
            {
                listener.CamundaClass = listenerClass;
            }
            foreach (CamundaExecutionListener listener in listeners)
            {
                assertThat(listener.getAttributeValueNs(BpmnModelConstants.ACTIVITI_NS, "class"), @is(listenerClass));
            }
        }
Ejemplo n.º 14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGeneratePlaneForProcess()
        public virtual void shouldGeneratePlaneForProcess()
        {
            // when
            instance = Bpmn.createExecutableProcess("process").done();

            // then
            ICollection <BpmnDiagram> bpmnDiagrams = instance.getModelElementsByType(typeof(BpmnDiagram));

            assertEquals(1, bpmnDiagrams.Count);

            BpmnDiagram diagram = bpmnDiagrams.GetEnumerator().next();

            assertNotNull(diagram.Id);

            assertNotNull(diagram.BpmnPlane);
            assertEquals(diagram.BpmnPlane.BpmnElement, instance.getModelElementById("process"));
        }
Ejemplo n.º 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void modifyingAttributeWithActivitiNsKeepsIt()
        public virtual void modifyingAttributeWithActivitiNsKeepsIt()
        {
            BpmnModelInstance modelInstance = Bpmn.readModelFromStream(typeof(CamundaExtensionsTest).getResourceAsStream("CamundaExtensionsCompatabilityTest.xml"));
            ProcessImpl       process       = modelInstance.getModelElementById(PROCESS_ID);
            string            priority      = "9000";

            process.CamundaJobPriority  = priority;
            process.CamundaTaskPriority = priority;
            int?historyTimeToLive = 10;

            process.CamundaHistoryTimeToLive     = historyTimeToLive;
            process.CamundaIsStartableInTasklist = false;
            process.CamundaVersionTag            = "v1.0.0";
            assertThat(process.getAttributeValueNs(BpmnModelConstants.ACTIVITI_NS, "jobPriority"), @is(priority));
            assertThat(process.getAttributeValueNs(BpmnModelConstants.ACTIVITI_NS, "taskPriority"), @is(priority));
            assertThat(process.getAttributeValueNs(BpmnModelConstants.ACTIVITI_NS, "historyTimeToLive"), @is(historyTimeToLive.ToString()));
            assertThat(process.CamundaStartableInTasklist, @is(false));
            assertThat(process.CamundaVersionTag, @is("v1.0.0"));
        }
Ejemplo n.º 16
0
        public virtual void testRepositoryService()
        {
            string processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_KEY).singleResult().Id;

            BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);

            assertNotNull(modelInstance);

            ICollection <ModelElementInstance> events = modelInstance.getModelElementsByType(modelInstance.Model.getType(typeof(Event)));

            assertEquals(2, events.Count);

            ICollection <ModelElementInstance> sequenceFlows = modelInstance.getModelElementsByType(modelInstance.Model.getType(typeof(SequenceFlow)));

            assertEquals(1, sequenceFlows.Count);

            StartEvent startEvent = modelInstance.getModelElementById("start");

            assertNotNull(startEvent);
        }
Ejemplo n.º 17
0
        private void addServiceTaskCompensationHandler(BpmnModelInstance modelInstance, string boundaryEventId, string compensationHandlerId)
        {
            BoundaryEvent boundaryEvent = modelInstance.getModelElementById(boundaryEventId);
            BaseElement   scope         = (BaseElement)boundaryEvent.ParentElement;

            ServiceTask compensationHandler = modelInstance.newInstance(typeof(ServiceTask));

            compensationHandler.Id = compensationHandlerId;
            compensationHandler.ForCompensation = true;
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            compensationHandler.CamundaClass = typeof(IncreaseCurrentTimeServiceTask).FullName;
            scope.addChildElement(compensationHandler);

            Association association = modelInstance.newInstance(typeof(Association));

            association.AssociationDirection = AssociationDirection.One;
            association.Source = boundaryEvent;
            association.Target = compensationHandler;
            scope.addChildElement(association);
        }
Ejemplo n.º 18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testUpdateIncomingOutgoingChildElements()
        public virtual void testUpdateIncomingOutgoingChildElements()
        {
            BpmnModelInstance modelInstance = Bpmn.createProcess().startEvent().userTask("test").endEvent().done();

            // save current incoming and outgoing sequence flows
            UserTask userTask = modelInstance.getModelElementById("test");
            ICollection <SequenceFlow> incoming = userTask.Incoming;
            ICollection <SequenceFlow> outgoing = userTask.Outgoing;

            // create a new service task
            ServiceTask serviceTask = modelInstance.newInstance(typeof(ServiceTask));

            serviceTask.Id = "new";

            // replace the user task with the new service task
            userTask.replaceWithElement(serviceTask);

            // assert that the new service task has the same incoming and outgoing sequence flows
            assertThat(serviceTask.Incoming).containsExactlyElementsOf(incoming);
            assertThat(serviceTask.Outgoing).containsExactlyElementsOf(outgoing);
        }
Ejemplo n.º 19
0
        protected internal virtual void addProcessDefinitionToCacheAndRetrieveDocumentation(IList <ProcessDefinition> list)
        {
            foreach (ProcessDefinition processDefinition in list)
            {
                BpmnModelInstance bpmnModelInstance = Context.ProcessEngineConfiguration.DeploymentCache.findBpmnModelInstanceForProcessDefinition((ProcessDefinitionEntity)processDefinition);

                ModelElementInstance processElement = bpmnModelInstance.getModelElementById(processDefinition.Key);
                if (processElement != null)
                {
                    ICollection <Documentation> documentations = processElement.getChildElementsByType(typeof(Documentation));
                    IList <string> docStrings = new List <string>();
                    foreach (Documentation documentation in documentations)
                    {
                        docStrings.Add(documentation.TextContent);
                    }

                    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity)processDefinition;
                    processDefinitionEntity.setProperty(BpmnParse.PROPERTYNAME_DOCUMENTATION, BpmnParse.parseDocumentation(docStrings));
                }
            }
        }
Ejemplo n.º 20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteTransaction() throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void shouldWriteTransaction()
        {
            // given a model
            BpmnModelInstance newModel = Bpmn.createProcess("process").done();

            Process process = newModel.getModelElementById("process");

            Transaction transaction = newModel.newInstance(typeof(Transaction));

            transaction.Id     = "transaction";
            transaction.Method = TransactionMethod.Store;
            process.addChildElement(transaction);

            // that is written to a stream
            MemoryStream outStream = new MemoryStream();

            Bpmn.writeModelToStream(outStream, newModel);

            // when reading from that stream
            MemoryStream inStream = new MemoryStream(outStream.toByteArray());

            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder        docBuilder        = docBuilderFactory.newDocumentBuilder();
            Document actualDocument = docBuilder.parse(inStream);

            // then it possible to traverse to the transaction element and assert its attributes
            NodeList transactionElements = actualDocument.getElementsByTagName("transaction");

            assertThat(transactionElements.Length).isEqualTo(1);

            Node transactionElement = transactionElements.item(0);

            assertThat(transactionElement).NotNull;
            Node methodAttribute = transactionElement.Attributes.getNamedItem("method");

            assertThat(methodAttribute.NodeValue).isEqualTo("##Store");
        }
Ejemplo n.º 21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void parseModel()
        public virtual void parseModel()
        {
            modelInstance        = Bpmn.readModelFromStream(this.GetType().getResourceAsStream(this.GetType().Name + ".xml"));
            collaboration        = modelInstance.getModelElementById(COLLABORATION_ID);
            participant          = modelInstance.getModelElementById(PARTICIPANT_ID + 1);
            process              = modelInstance.getModelElementById(PROCESS_ID + 1);
            serviceTask          = modelInstance.getModelElementById(SERVICE_TASK_ID);
            exclusiveGateway     = modelInstance.getModelElementById(EXCLUSIVE_GATEWAY);
            startEvent           = modelInstance.getModelElementById(START_EVENT_ID + 2);
            sequenceFlow         = modelInstance.getModelElementById(SEQUENCE_FLOW_ID + 3);
            messageFlow          = modelInstance.getModelElementById(MESSAGE_FLOW_ID);
            dataInputAssociation = modelInstance.getModelElementById(DATA_INPUT_ASSOCIATION_ID);
            association          = modelInstance.getModelElementById(ASSOCIATION_ID);
            endEvent             = modelInstance.getModelElementById(END_EVENT_ID + 2);
        }
Ejemplo n.º 22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateValidBpmnDi()
        public virtual void shouldCreateValidBpmnDi()
        {
            modelInstance = Bpmn.createProcess("process").startEvent("start").sequenceFlowId("flow").endEvent("end").done();

            process      = modelInstance.getModelElementById("process");
            startEvent   = modelInstance.getModelElementById("start");
            sequenceFlow = modelInstance.getModelElementById("flow");
            endEvent     = modelInstance.getModelElementById("end");

            // create bpmn diagram
            BpmnDiagram bpmnDiagram = modelInstance.newInstance(typeof(BpmnDiagram));

            bpmnDiagram.Id            = "diagram";
            bpmnDiagram.Name          = "diagram";
            bpmnDiagram.Documentation = "bpmn diagram element";
            bpmnDiagram.Resolution    = 120.0;
            modelInstance.Definitions.addChildElement(bpmnDiagram);

            // create plane for process
            BpmnPlane processPlane = modelInstance.newInstance(typeof(BpmnPlane));

            processPlane.Id          = "plane";
            processPlane.BpmnElement = process;
            bpmnDiagram.BpmnPlane    = processPlane;

            // create shape for start event
            BpmnShape startEventShape = modelInstance.newInstance(typeof(BpmnShape));

            startEventShape.Id          = "startShape";
            startEventShape.BpmnElement = startEvent;
            processPlane.DiagramElements.Add(startEventShape);

            // create bounds for start event shape
            Bounds startEventBounds = modelInstance.newInstance(typeof(Bounds));

            startEventBounds.setHeight(36.0);
            startEventBounds.setWidth(36.0);
            startEventBounds.setX(632.0);
            startEventBounds.setY(312.0);
            startEventShape.Bounds = startEventBounds;

            // create shape for end event
            BpmnShape endEventShape = modelInstance.newInstance(typeof(BpmnShape));

            endEventShape.Id          = "endShape";
            endEventShape.BpmnElement = endEvent;
            processPlane.DiagramElements.Add(endEventShape);

            // create bounds for end event shape
            Bounds endEventBounds = modelInstance.newInstance(typeof(Bounds));

            endEventBounds.setHeight(36.0);
            endEventBounds.setWidth(36.0);
            endEventBounds.setX(718.0);
            endEventBounds.setY(312.0);
            endEventShape.Bounds = endEventBounds;

            // create edge for sequence flow
            BpmnEdge flowEdge = modelInstance.newInstance(typeof(BpmnEdge));

            flowEdge.Id            = "flowEdge";
            flowEdge.BpmnElement   = sequenceFlow;
            flowEdge.SourceElement = startEventShape;
            flowEdge.TargetElement = endEventShape;
            processPlane.DiagramElements.Add(flowEdge);

            // create waypoints for sequence flow edge
            Waypoint startWaypoint = modelInstance.newInstance(typeof(Waypoint));

            startWaypoint.X = 668.0;
            startWaypoint.Y = 330.0;
            flowEdge.Waypoints.add(startWaypoint);

            Waypoint endWaypoint = modelInstance.newInstance(typeof(Waypoint));

            endWaypoint.X = 718.0;
            endWaypoint.Y = 330.0;
            flowEdge.Waypoints.add(endWaypoint);
        }
Ejemplo n.º 23
0
 public virtual T getModelElementById <T>(string id) where T : org.camunda.bpm.model.xml.instance.ModelElementInstance
 {
     return(modelInstance.getModelElementById(id));
 }
Ejemplo n.º 24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeClass public static void parseModel()
        public static void parseModel()
        {
            modelInstance = Bpmn.readModelFromStream(typeof(CollaborationParserTest).getResourceAsStream("CollaborationParserTest.bpmn"));
            collaboration = modelInstance.getModelElementById("collaboration1");
        }