Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void validationFailsIfNoStartEventFound()
        public virtual void validationFailsIfNoStartEventFound()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.camunda.bpm.model.xml.validation.ModelElementValidator<?>> validators = new java.util.ArrayList<org.camunda.bpm.model.xml.validation.ModelElementValidator<?>>();
            IList <ModelElementValidator <object> > validators = new List <ModelElementValidator <object> >();

            validators.Add(new ProcessStartEventValidator());

            BpmnModelInstance bpmnModelInstance = Bpmn.createProcess().done();

            ValidationResults validationResults = bpmnModelInstance.validate(validators);

            assertThat(validationResults.hasErrors()).True;

            IDictionary <ModelElementInstance, IList <ValidationResult> > results = validationResults.Results;

            assertThat(results.Count).isEqualTo(1);

            Process process = bpmnModelInstance.Definitions.getChildElementsByType(typeof(Process)).GetEnumerator().next();

            assertThat(results.ContainsKey(process)).True;

            IList <ValidationResult> resultsForProcess = results[process];

            assertThat(resultsForProcess.Count).isEqualTo(1);

            ValidationResult validationResult = resultsForProcess[0];

            assertThat(validationResult.Element).isEqualTo(process);
            assertThat(validationResult.Code).isEqualTo(10);
            assertThat(validationResult.Message).isEqualTo("Process does not have exactly one start event. Got 0.");
            assertThat(validationResult.Type).isEqualTo(ValidationResultType.ERROR);
        }
Exemple #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;
        }
Exemple #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testDeployNonExecutableProcess() throws Exception
        public virtual void testDeployNonExecutableProcess()
        {
            // given non executable process definition
//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.createProcess("foo").startEvent().userTask().endEvent().done();
            BpmnModelInstance modelInstance = Bpmn.createProcess("foo").startEvent().userTask().endEvent().done();

            // when process model is deployed
            DeploymentWithDefinitions deployment = repositoryService.createDeployment().addModelInstance("foo.bpmn", modelInstance).deployWithResult();

            deploymentIds.Add(deployment.Id);

            // then deployment contains no deployed process definition
            assertNull(deployment.DeployedProcessDefinitions);

            // and there exist no persisted process definitions
            assertNull(repositoryService.createProcessDefinitionQuery().processDefinitionResourceName("foo.bpmn").singleResult());
        }
Exemple #4
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);
        }
Exemple #5
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");
        }
Exemple #6
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);
        }