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); }
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); }
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]); }
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]); }
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); }
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); }