Пример #1
0
        public static void addResource(string name, BpmnModelInstance modelInstance)
        {
            MemoryStream outStream = new MemoryStream();

            Bpmn.writeModelToStream(outStream, modelInstance);

            resources.Add(new NamedByteArrayResource(outStream.toByteArray(), name));
        }
Пример #2
0
        static ConcurrentDeploymentTest()
        {
            BpmnModelInstance modelInstance = Bpmn.createExecutableProcess().startEvent().done();
            MemoryStream      outputStream  = new MemoryStream();

            Bpmn.writeModelToStream(outputStream, modelInstance);
            processResource = StringHelper.NewString(outputStream.toByteArray());
        }
Пример #3
0
        protected internal static Asset modelAsAsset(BpmnModelInstance modelInstance)
        {
            MemoryStream byteStream = new MemoryStream();

            Bpmn.writeModelToStream(byteStream, modelInstance);

            sbyte[] bytes = byteStream.toByteArray();
            return(new ByteArrayAsset(bytes));
        }
Пример #4
0
        public virtual DeploymentBuilder addModelInstance(string resourceName, BpmnModelInstance modelInstance)
        {
            ensureNotNull("modelInstance", modelInstance);

            validateResouceName(resourceName, BpmnDeployer.BPMN_RESOURCE_SUFFIXES);

            MemoryStream outputStream = new MemoryStream();

            Bpmn.writeModelToStream(outputStream, modelInstance);

            return(addBytes(resourceName, outputStream.toByteArray()));
        }
Пример #5
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);
        }
Пример #6
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");
        }