예제 #1
0
        public string GetValidNextElementOrError(string currentElement, out ProcessError nextElementError)
        {
            nextElementError = null;
            string nextElementId = null;

            List <string> nextElements = _process.NextElements(currentElement);

            if (nextElements.Count > 1)
            {
                nextElementError = new ProcessError
                {
                    Code = "Conflict",
                    Text = ($"There is more than one element reachable from element {currentElement}")
                };
            }
            else
            {
                nextElementId = nextElements.First();
            }

            return(nextElementId);
        }
예제 #2
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);
        }
예제 #3
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]);
        }
예제 #4
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]);
        }
예제 #5
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);
        }
예제 #6
0
        public void NextElements_DefinitionsHaveTwoTasks_AskForNextStepWithoutCurrent_ThrowsArgumentNullException()
        {
            // Arrange
            string     definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.default_process.bpmn");
            BpmnReader target      = BpmnReader.Create(definitions);

            ArgumentNullException actual = null;

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

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <ArgumentNullException>(actual);
            Assert.Equal("elementId", actual.ParamName);
        }