Ejemplo n.º 1
0
 private void LoadProcessModel(string org, string app)
 {
     using (Stream definitions = processService.GetProcessDefinition(org, app))
     {
         ProcessModel = BpmnReader.Create(definitions);
     }
 }
Ejemplo n.º 2
0
        public void Create_InputBpmnDescriptionAsString_ReturnsInitializedBpmnReader()
        {
            // Arrange
            string definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.multiple_events.bpmn");

            // Act
            BpmnReader actual = BpmnReader.Create(definitions);

            // Assert
            Assert.NotNull(actual);
        }
Ejemplo n.º 3
0
        public void ParseTest()
        {
            FlowResult result = new BpmnReader().Parse(Content);

            CollectionAssert.AreEqual(new List <LogicComponent> {
                new LogicComponent("OPERATION BOOKED QUANTITIES", "lib/qi-operation-booked-quantities")
            }, result.LogicComponents);
            Assert.AreEqual(new Project("system.forcam.ff-rd-07.oee-manual-sequence", "erp-process", "?"), result.Project);
            CollectionAssert.AreEqual(new List <Dependency> {
                new Dependency("system.forcam.ff-rd-07.oee-manual-sequence", "core-process", "1.0")
            }, result.Project.Dependencies);
        }
Ejemplo n.º 4
0
        public void EndEvents_DefinitionHasTwoEndEvent_AskForEndEvent_ReturnsEndEvents()
        {
            // Arrange
            string     definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.multiple_events.bpmn");
            BpmnReader target      = BpmnReader.Create(definitions);

            // Act
            List <string> actual = target.EndEvents();

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(2, actual.Count);
        }
Ejemplo n.º 5
0
        public void Tasks_DefinitionHasTwoTasks_AskForTask_ReturnsAllTasks()
        {
            // Arrange
            string     definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.default_process.bpmn");
            BpmnReader target      = BpmnReader.Create(definitions);

            // Act
            List <string> actual = target.Tasks();

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(2, actual.Count);
        }
Ejemplo n.º 6
0
        public void NextElements_DefinitionHasTwoEndEvents_AskForNextStepFromLastTask_ReturnsIdOfBothEndEvents()
        {
            // Arrange
            string     definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.multiple_events.bpmn");
            BpmnReader target      = BpmnReader.Create(definitions);

            // Act
            List <string> actual = target.NextElements("Task_08wkkve");

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(2, actual.Count);
        }
Ejemplo n.º 7
0
        public void GetStartElementId_ProcessWithOneStartEvent_IdentifyInitialTask()
        {
            // Arrange
            string     definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.default_process.bpmn");
            BpmnReader target      = BpmnReader.Create(definitions);

            // Act
            string actual = target.GetStartElementId();

            // Assert
            Assert.NotNull(actual);
            Assert.Equal("FormFilling_1", actual);
        }
Ejemplo n.º 8
0
        public void StartEvents_DefinitionHasOneStartEvent_AskForStartEvents_ReturnsSingleStartEvent()
        {
            // Arrange
            string     definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.default_process.bpmn");
            BpmnReader target      = BpmnReader.Create(definitions);

            // Act
            List <string> actual = target.StartEvents();

            // Assert
            Assert.NotNull(actual);
            Assert.Single(actual);
        }
Ejemplo n.º 9
0
        public void NextElements_AskForNextStepFromStartEvent_ReturnsNextTaskId()
        {
            // Arrange
            string     definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.multiple_events.bpmn");
            BpmnReader target      = BpmnReader.Create(definitions);

            // Act
            List <string> actual = target.NextElements("StartEvent_0mau26i");

            // Assert
            Assert.NotNull(actual);
            Assert.Single(actual);
            Assert.Equal("Task_14svrga", actual[0]);
        }
Ejemplo n.º 10
0
        public void NextElements_DefinitionsHaveTwoTasks_AskForNextStepAfterFirst_ReturnsNextElementId(string currentId, string nextId)
        {
            // Arrange
            string     definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.default_process.bpmn");
            BpmnReader target      = BpmnReader.Create(definitions);

            // Act
            List <string> actual = target.NextElements(currentId);

            // Assert
            Assert.NotNull(actual);
            Assert.Single(actual);
            Assert.Equal(nextId, actual[0]);
        }
Ejemplo n.º 11
0
 public ProcessOperations(
     PomReader pomReader,
     BpmnReader bpmnReader,
     FfdReader ffdReader,
     ProcessFlowJsonReader processFlowJsonReader,
     ProcessJsonReader processJsonReader,
     StatusTableReader statusTableReader)
 {
     PomReader             = pomReader;
     BpmnReader            = bpmnReader;
     FfdReader             = ffdReader;
     ProcessFlowJsonReader = processFlowJsonReader;
     ProcessJsonReader     = processJsonReader;
     StatusTableReader     = statusTableReader;
 }
Ejemplo n.º 12
0
        public void GetElementInfo_AskForExistingElement_ReturnsInfoAboutElement(string id, string elementType, string taskType)
        {
            // Arrange
            string     definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.default_process.bpmn");
            BpmnReader target      = BpmnReader.Create(definitions);

            // Act
            ElementInfo actual = target.GetElementInfo(id);

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(id, actual.Id);
            Assert.Equal(elementType, actual.ElementType);
            Assert.Equal(taskType, actual.AltinnTaskType);
        }
Ejemplo n.º 13
0
        public void IncrementVersionTest()
        {
            var result = new BpmnReader().IncrementVersion(Content);

            var expected = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no""?>
<definitions xmlns:g=""http://www.jboss.org/drools/flow/gpd"">
  <process id=""system.forcam.ff-rd-07.oee-manual-sequence.erp-process"" isExecutable=""true"" name=""system.forcam.ff-rd-07.oee-manual-sequence.erp-process"" processType=""Private"">
    <startEvent id=""_1"" name=""Start"" />
    <endEvent id=""_2"" name=""End"">
      <terminateEventDefinition />
    </endEvent>
    <businessRuleTask g:ruleFlowGroup=""lib/qi-operation-booked-quantities"" id=""_6"" name=""OPERATION BOOKED QUANTITIES"" />
    <callActivity calledElement=""system.forcam.ff-rd-07.oee-manual-sequence.core-process"" id=""_11"" name=""core-process&#xA;(1.1)"">
    </callActivity>
    <sequenceFlow id=""_6-_12"" sourceRef=""_6"" targetRef=""_12"" />
  </process>
</definitions>";

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 14
0
        public void NextElements_AskForNextStepWithANonexistingId_ThrowsProcessException()
        {
            // Arrange
            string     definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.multiple_events.bpmn");
            BpmnReader target      = BpmnReader.Create(definitions);

            ProcessException actual = null;

            // Act
            try
            {
                _ = target.NextElements("donotexist");
            }
            catch (ProcessException pe)
            {
                actual = pe;
            }

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <ProcessException>(actual);
        }
Ejemplo n.º 15
0
        public void GetStartElementId_ProcessWithTwoStartEvents_IdentifyInitialTask_ThrowsProcessException()
        {
            // Arrange
            string     definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.multiple_events.bpmn");
            BpmnReader target      = BpmnReader.Create(definitions);

            ProcessException actual = null;

            // Act
            try
            {
                _ = target.GetStartElementId();
            }
            catch (ProcessException pe)
            {
                actual = pe;
            }

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <ProcessException>(actual);
        }
Ejemplo n.º 16
0
        public void GetElementInfo_AskForElementInfoForElementNull_ThrowsArgumentNullException()
        {
            // Arrange
            string     definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.default_process.bpmn");
            BpmnReader target      = BpmnReader.Create(definitions);

            ArgumentNullException actual = null;

            // Act
            try
            {
                _ = target.GetElementInfo(null);
            }
            catch (ArgumentNullException ane)
            {
                actual = ane;
            }

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <ArgumentNullException>(actual);
            Assert.Equal("elementId", actual.ParamName);
        }
Ejemplo n.º 17
0
        public void VerifyFlow(VerificationResult result, DirectoryInfo projectDir, Dependency flow, Project project)
        {
            var pom             = "pom.xml";
            var flowName        = flow.ArtifactId.ToLower();
            var bpmn            = flowName + ".bpmn";
            var ffd             = flowName + ".ffd";
            var flowsJson       = flowName + ".json";
            var processJson     = flowName + "_process.json";
            var operationStatus = "operation-status.fdt";
            var workplaceStatus = "workplace-status.fdt";

            Project pomResult           = null;
            List <LogicComponent> flows = null;

            if (!File.Exists(Path.Combine(projectDir.FullName, pom)))
            {
                result.Error(flowName + " " + pom + " is missing");
            }
            else
            {
                var pomPath = Path.Combine(projectDir.FullName, pom);
                pomResult = PomReader.Parse(File.ReadAllText(pomPath));
                result.ProvideDependency(pom, pomResult);
                result.ProvideFlow(pomPath, new FlowConfiguration(pomResult.GroupId, pomResult.ArtifactId, pomResult.Version, "", ""));

                foreach (var dependency in pomResult.Dependencies)
                {
                    result.RequireDependency(pomPath, dependency);
                }
            }

            if (!File.Exists(Path.Combine(projectDir.FullName, bpmn)))
            {
                result.Error(flowName + " " + bpmn + " is missing");
            }
            else
            {
                var bpmnResult = BpmnReader.Parse(File.ReadAllText(Path.Combine(projectDir.FullName, bpmn)));
                foreach (var components in bpmnResult.LogicComponents)
                {
                    if (IgnoreComponent(components))
                    {
                        continue;
                    }

                    result.RequireLogicComponent(bpmn, components);
                }

                flows = bpmnResult.LogicComponents;

                if (pomResult != null && !bpmnResult.Project.ArtifactId.Equals(pomResult.ArtifactId))
                {
                    result.Error(bpmn + " artifact ID doesn't match pom artifact ID");
                }

                foreach (var dependency in bpmnResult.Project.Dependencies)
                {
                    result.RequireDependency(bpmn, dependency);
                }
            }

            if (!File.Exists(Path.Combine(projectDir.FullName, ffd)))
            {
                result.Error(flowName + " " + ffd + " is missing");
            }
            else
            {
                var flowResult = FfdReader.Parse(File.ReadAllText(Path.Combine(projectDir.FullName, ffd)));
                foreach (var components in flowResult.LogicComponents)
                {
                    if (IgnoreComponent(components))
                    {
                        continue;
                    }

                    result.RequireLogicComponent(ffd, components);
                }

                if (pomResult != null && !flowResult.Project.ArtifactId.Equals(pomResult.ArtifactId))
                {
                    result.Error(ffd + " artifact ID doesn't match pom artifact ID");
                }

                foreach (var dependency in flowResult.Project.Dependencies)
                {
                    result.RequireDependency(ffd, dependency);
                }
            }

            if (!File.Exists(Path.Combine(projectDir.FullName, flowsJson)))
            {
                result.Error(flowName + " " + flowsJson + " is missing");
            }
            else
            {
                var flowResult = ProcessFlowJsonReader.Parse(File.ReadAllText(Path.Combine(projectDir.FullName, flowsJson)));
                foreach (var components in flowResult.LogicComponents)
                {
                    result.RequireLogicComponent(bpmn, components);
                }

                if (flows != null)
                {
                    foreach (var missMatch in flows
                             .Where(f => !flowResult.LogicComponents.Contains(f))
                             .Where(m => !m.Name.EndsWith("status")))
                    {
                        result.Error(bpmn + " doesn't match " + missMatch);
                    }
                }

                foreach (var dependency in flowResult.Project.Dependencies)
                {
                    result.RequireDependency(flowsJson, dependency);
                }
            }

            if (!File.Exists(Path.Combine(projectDir.FullName, processJson)))
            {
                result.Error(flowName + " " + processJson + " is missing");
            }
            else
            {
                var projectResult = ProcessJsonReader.Parse(File.ReadAllText(Path.Combine(projectDir.FullName, processJson)));
                if (pomResult != null && !projectResult.ArtifactId.Equals(pomResult.ArtifactId))
                {
                    result.Error(processJson + " artifact ID doesn't match pom artifact ID");
                }

                foreach (var dependency in projectResult.Dependencies)
                {
                    result.RequireDependency(processJson, dependency);
                }
            }

            if (flowName == "core-process")
            {
                if (!File.Exists(Path.Combine(projectDir.FullName, workplaceStatus)))
                {
                    result.Error(flowName + " " + workplaceStatus + " is missing");
                }
                else
                {
                    var statusTable = StatusTableReader.Parse(File.ReadAllText(Path.Combine(projectDir.FullName, workplaceStatus)));
                    foreach (var status in statusTable)
                    {
                        result.RequireStatusDefinition(workplaceStatus, status);
                    }
                }

                if (File.Exists(Path.Combine(projectDir.FullName, operationStatus)))
                {
                    var statusTable = StatusTableReader.Parse(File.ReadAllText(Path.Combine(projectDir.FullName, operationStatus)));
                    foreach (var status in statusTable)
                    {
                        result.RequireStatusDefinition(workplaceStatus, status);
                    }
                }
            }
        }
Ejemplo n.º 18
0
 public ProcessHelper(Stream bpmnStream)
 {
     _process = BpmnReader.Create(bpmnStream);
 }
Ejemplo n.º 19
0
        public void IncrementFlowVersion(DirectoryInfo projectDir, Dependency flow, Project project)
        {
            var pom       = "pom.xml";
            var flowName  = flow.ArtifactId.ToLower();
            var bpmn      = flowName + ".bpmn";
            var flowsJson = flowName + ".json";

            if (File.Exists(Path.Combine(projectDir.FullName, pom)))
            {
                VersionIncrement.ReplaceFileContent(Path.Combine(projectDir.FullName, pom), c => PomReader.IncrementVersion(c));
            }

            if (File.Exists(Path.Combine(projectDir.FullName, bpmn)))
            {
                VersionIncrement.ReplaceFileContent(Path.Combine(projectDir.FullName, bpmn), c => BpmnReader.IncrementVersion(c));
            }

            if (File.Exists(Path.Combine(projectDir.FullName, flowsJson)))
            {
                VersionIncrement.ReplaceFileContent(Path.Combine(projectDir.FullName, flowsJson), c => ProcessFlowJsonReader.IncrementVersion(c));
            }
        }