//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void createModel() public virtual void createModel() { testBpmnModelInstance = Bpmn.createEmptyModel(); Definitions definitions = testBpmnModelInstance.newInstance(typeof(Definitions)); testBpmnModelInstance.Definitions = definitions; message = testBpmnModelInstance.newInstance(typeof(Message)); message.Id = "message-id"; definitions.RootElements.Add(message); Process process = testBpmnModelInstance.newInstance(typeof(Process)); process.Id = "process-id"; definitions.RootElements.Add(process); startEvent = testBpmnModelInstance.newInstance(typeof(StartEvent)); startEvent.Id = "start-event-id"; process.FlowElements.Add(startEvent); messageEventDefinition = testBpmnModelInstance.newInstance(typeof(MessageEventDefinition)); messageEventDefinition.Id = "msg-def-id"; messageEventDefinition.Message = message; startEvent.EventDefinitions.Add(messageEventDefinition); startEvent.EventDefinitionRefs.Add(messageEventDefinition); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testShouldUpdateReferenceIfReferencingElementIsReplaced() public virtual void testShouldUpdateReferenceIfReferencingElementIsReplaced() { assertThat(messageEventDefinition.Message).isEqualTo(message); Message newMessage = testBpmnModelInstance.newInstance(typeof(Message)); newMessage.Id = "new-message-id"; message.replaceWithElement(newMessage); assertThat(messageEventDefinition.Message).isEqualTo(newMessage); }
private void addMessageEventDefinition(CatchEvent catchEvent) { BpmnModelInstance modelInstance = (BpmnModelInstance)catchEvent.ModelInstance; Message message = modelInstance.newInstance(typeof(Message)); message.Id = MESSAGE_ID; message.Name = MESSAGE_NAME; modelInstance.Definitions.addChildElement(message); MessageEventDefinition messageEventDefinition = modelInstance.newInstance(typeof(MessageEventDefinition)); messageEventDefinition.Message = message; catchEvent.EventDefinitions.add(messageEventDefinition); }
protected internal override Task createModelAccessTask(BpmnModelInstance modelInstance, Type delegateClass) { ManualTask task = modelInstance.newInstance(typeof(ManualTask)); task.Id = "manualTask"; CamundaExecutionListener executionListener = modelInstance.newInstance(typeof(CamundaExecutionListener)); executionListener.CamundaEvent = [email protected]_Fields.EVENTNAME_START; //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: executionListener.CamundaClass = delegateClass.FullName; task.builder().addExtensionElement(executionListener); return(task); }
public static void initEndEvent(BpmnModelInstance modelInstance, string endEventId) { EndEvent endEvent = modelInstance.getModelElementById(endEventId); TerminateEventDefinition terminateDefinition = modelInstance.newInstance(typeof(TerminateEventDefinition)); endEvent.addChildElement(terminateDefinition); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void createEmptyModel() public virtual void createEmptyModel() { modelInstance = Bpmn.createEmptyModel(); definitions = modelInstance.newInstance(typeof(Definitions)); definitions.TargetNamespace = "http://camunda.org/examples"; modelInstance.Definitions = definitions; }
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 shouldAddChildElementsInCorrectOrder() public virtual void shouldAddChildElementsInCorrectOrder() { // create an empty model BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel(); // add definitions Definitions definitions = bpmnModelInstance.newInstance(typeof(Definitions)); definitions.TargetNamespace = "Examples"; bpmnModelInstance.Definitions = definitions; // create a Process element and add it to the definitions Process process = bpmnModelInstance.newInstance(typeof(Process)); process.Id = "some-process-id"; definitions.RootElements.Add(process); // create an Import element and add it to the definitions Import importElement = bpmnModelInstance.newInstance(typeof(Import)); importElement.Namespace = "Imports"; importElement.Location = "here"; importElement.ImportType = "example"; definitions.Imports.Add(importElement); // create another Process element and add it to the definitions process = bpmnModelInstance.newInstance(typeof(Process)); process.Id = "another-process-id"; definitions.RootElements.Add(process); // create another Import element and add it to the definitions importElement = bpmnModelInstance.newInstance(typeof(Import)); importElement.Namespace = "Imports"; importElement.Location = "there"; importElement.ImportType = "example"; definitions.Imports.Add(importElement); // validate model try { Bpmn.validateModel(bpmnModelInstance); } catch (ModelValidationException) { Assert.fail(); } }
protected internal virtual T createElement <T>(BpmnModelElementInstance parentElement, string id, Type elementClass) where T : BpmnModelElementInstance { elementClass = typeof(T); T element = modelInstance.newInstance(elementClass); element.setAttributeValue("id", id, true); parentElement.addChildElement(element); return(element); }
protected internal override Task createModelAccessTask(BpmnModelInstance modelInstance, Type delegateClass) { ServiceTask serviceTask = modelInstance.newInstance(typeof(ServiceTask)); serviceTask.Id = "serviceTask"; //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: serviceTask.CamundaClass = delegateClass.FullName; return(serviceTask); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGenerateIdsOnCreate() public virtual void shouldGenerateIdsOnCreate() { BpmnModelInstance modelInstance = Bpmn.createEmptyModel(); Definitions definitions = modelInstance.newInstance(typeof(Definitions)); assertThat(definitions.Id).NotNull; Process process = modelInstance.newInstance(typeof(Process)); assertThat(process.Id).NotNull; StartEvent startEvent = modelInstance.newInstance(typeof(StartEvent)); assertThat(startEvent.Id).NotNull; UserTask userTask = modelInstance.newInstance(typeof(UserTask)); assertThat(userTask.Id).NotNull; }
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); }
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); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAddParentChildElementInCorrectOrder() public virtual void shouldAddParentChildElementInCorrectOrder() { // create empty model BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel(); // add definitions to model Definitions definitions = bpmnModelInstance.newInstance(typeof(Definitions)); definitions.TargetNamespace = "Examples"; bpmnModelInstance.Definitions = definitions; // add process Process process = bpmnModelInstance.newInstance(typeof(Process)); process.Id = "messageEventDefinition"; definitions.RootElements.Add(process); // add start event StartEvent startEvent = bpmnModelInstance.newInstance(typeof(StartEvent)); startEvent.Id = "theStart"; process.FlowElements.Add(startEvent); // create and add message Message message = bpmnModelInstance.newInstance(typeof(Message)); message.Id = "start-message-id"; definitions.RootElements.Add(message); // add message event definition to start event MessageEventDefinition startEventMessageEventDefinition = bpmnModelInstance.newInstance(typeof(MessageEventDefinition)); startEventMessageEventDefinition.Message = message; startEvent.EventDefinitions.Add(startEventMessageEventDefinition); // add property after message event definition Property property = bpmnModelInstance.newInstance(typeof(Property)); startEvent.Properties.Add(property); // finally add an extensions element ExtensionElements extensionElements = bpmnModelInstance.newInstance(typeof(ExtensionElements)); process.ExtensionElements = extensionElements; // validate model try { Bpmn.validateModel(bpmnModelInstance); } catch (ModelValidationException) { Assert.fail(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCreateEmptyModel() public virtual void testCreateEmptyModel() { BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel(); Definitions definitions = bpmnModelInstance.Definitions; assertThat(definitions).Null; definitions = bpmnModelInstance.newInstance(typeof(Definitions)); bpmnModelInstance.Definitions = definitions; definitions = bpmnModelInstance.Definitions; assertThat(definitions).NotNull; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testClone() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testClone() { BpmnModelInstance modelInstance = Bpmn.createEmptyModel(); Definitions definitions = modelInstance.newInstance(typeof(Definitions)); definitions.Id = "TestId"; modelInstance.Definitions = definitions; BpmnModelInstance cloneInstance = modelInstance.clone(); cloneInstance.Definitions.Id = "TestId2"; assertThat(modelInstance.Definitions.Id, @is(equalTo("TestId"))); assertThat(cloneInstance.Definitions.Id, @is(equalTo("TestId2"))); }
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; }
//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); }
//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"); }
//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); }
public virtual T newInstance <T>(Type type) where T : org.camunda.bpm.model.xml.instance.ModelElementInstance { type = typeof(T); return(modelInstance.newInstance(type)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAddMessageAndMessageEventDefinition() public virtual void shouldAddMessageAndMessageEventDefinition() { // create empty model BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel(); // add definitions to model Definitions definitions = bpmnModelInstance.newInstance(typeof(Definitions)); definitions.TargetNamespace = "Examples"; bpmnModelInstance.Definitions = definitions; // create and add message Message message = bpmnModelInstance.newInstance(typeof(Message)); message.Id = "start-message-id"; definitions.RootElements.Add(message); // create and add message event definition MessageEventDefinition messageEventDefinition = bpmnModelInstance.newInstance(typeof(MessageEventDefinition)); messageEventDefinition.Id = "message-event-def-id"; messageEventDefinition.Message = message; definitions.RootElements.Add(messageEventDefinition); // test if message was set correctly Message setMessage = messageEventDefinition.Message; assertThat(setMessage).isEqualTo(message); // add process Process process = bpmnModelInstance.newInstance(typeof(Process)); process.Id = "messageEventDefinition"; definitions.RootElements.Add(process); // add start event StartEvent startEvent = bpmnModelInstance.newInstance(typeof(StartEvent)); startEvent.Id = "theStart"; process.FlowElements.Add(startEvent); // create and add message event definition to start event MessageEventDefinition startEventMessageEventDefinition = bpmnModelInstance.newInstance(typeof(MessageEventDefinition)); startEventMessageEventDefinition.Message = message; startEvent.EventDefinitions.Add(startEventMessageEventDefinition); // create another message but do not add it Message anotherMessage = bpmnModelInstance.newInstance(typeof(Message)); anotherMessage.Id = "another-message-id"; // create a message event definition and try to add last create message MessageEventDefinition anotherMessageEventDefinition = bpmnModelInstance.newInstance(typeof(MessageEventDefinition)); try { anotherMessageEventDefinition.Message = anotherMessage; Assert.fail("Message should not be added to message event definition, cause it is not part of the model"); } catch (Exception e) { assertThat(e).isInstanceOf(typeof(ModelReferenceException)); } // first add message to model than to event definition definitions.RootElements.Add(anotherMessage); anotherMessageEventDefinition.Message = anotherMessage; startEvent.EventDefinitions.Add(anotherMessageEventDefinition); // message event definition and add message by id to it anotherMessageEventDefinition = bpmnModelInstance.newInstance(typeof(MessageEventDefinition)); startEvent.EventDefinitions.Add(anotherMessageEventDefinition); // validate model try { Bpmn.validateModel(bpmnModelInstance); } catch (ModelValidationException) { Assert.fail(); } }