예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void validateModel() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void validateModel()
        {
            if (instance != null)
            {
                Bpmn.validateModel(instance);
            }
        }
예제 #2
0
//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();
            }
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @BpmnModelResource public void shouldNotAffectComments() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void shouldNotAffectComments()
        {
            Definitions definitions = bpmnModelInstance.Definitions;

            assertThat(definitions).NotNull;

            // create another Process element and add it to the definitions
            Process process = bpmnModelInstance.newInstance(typeof(Process));

            process.Id = "another-process-id";
            definitions.RootElements.Add(process);

            // create another Import element and add it to the definitions
            Import 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();
            }

            // convert the model to the XML string representation
            Stream outputStream = new MemoryStream();

            Bpmn.writeModelToStream(outputStream, bpmnModelInstance);
            Stream inputStream = IoUtil.convertOutputStreamToInputStream(outputStream);
            string modelString = IoUtil.getStringFromInputStream(inputStream);

            IoUtil.closeSilently(outputStream);
            IoUtil.closeSilently(inputStream);

            // read test process from file as string
            inputStream = this.GetType().getResourceAsStream("DefinitionsTest.shouldNotAffectCommentsResult.bpmn");
            string fileString = IoUtil.getStringFromInputStream(inputStream);

            IoUtil.closeSilently(inputStream);

            // compare strings
            assertThat(modelString).EndsWith(fileString);
        }
예제 #4
0
//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();
            }
        }
예제 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void validateModel()
        public virtual void validateModel()
        {
            Bpmn.validateModel(modelInstance);
        }
예제 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @AfterClass public static void validateModelInstance()
        public static void validateModelInstance()
        {
            Bpmn.validateModel(modelInstance);
        }
예제 #7
0
//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();
            }
        }