public static ExecutionAssert That(ExecutionTree tree) { ExecutionAssert Assertion = new ExecutionAssert(); Assertion.Tree = tree; return(Assertion); }
public static ExecutionTree ForExecution(string executionId, IProcessEngine processEngine) { ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl)processEngine.ProcessEngineConfiguration; ICommandExecutor commandExecutor = configuration.CommandExecutorTxRequired; ExecutionTree executionTree = commandExecutor.Execute(new CommandAnonymousInnerClass(executionId)); return(executionTree); }
protected internal static ExecutionTree ForExecution(ExecutionEntity execution) { IList <ExecutionTree> children = new List <ExecutionTree>(); foreach (ExecutionEntity child in execution.Executions) { children.Add(ExecutionTree.ForExecution(child)); } return(new ExecutionTree(execution, children)); }
public virtual void AssertExecution(ExecutionTree tree) { bool matches = Matches(tree); if (!matches) { StringBuilder errorBuilder = new StringBuilder(); errorBuilder.Append("Expected tree: \n"); Describe(this, "", errorBuilder); errorBuilder.Append("Actual tree: \n"); errorBuilder.Append(tree); Assert.Fail(errorBuilder.ToString()); } }
/// <summary> /// returns umatched executions in the tree /// </summary> protected internal virtual IList <IExecution> Matches(ExecutionTree tree) { ExecutionEntity executionEntity = (ExecutionEntity)tree.Execution; IList <IExecution> unmatchedExecutions = new List <IExecution>(); if (!ExpectedProcessDefinitionId.Equals(executionEntity.ProcessDefinitionId)) { unmatchedExecutions.Add(tree.Execution); } foreach (ExecutionTree child in tree.Executions) { ((List <IExecution>)unmatchedExecutions).AddRange(Matches(child)); } return(unmatchedExecutions); }
public virtual void AssertExecution(ExecutionTree tree) { IList <IExecution> nonMatchingExecutions = Matches(tree); if (nonMatchingExecutions.Count > 0) { StringBuilder sb = new StringBuilder(); sb.Append("Expected all executions to have process definition id " + ExpectedProcessDefinitionId + "\n"); sb.Append("Actual Tree: \n"); sb.Append(tree); sb.Append("\nExecutions with unexpected process definition id:\n"); sb.Append("[\n"); foreach (IExecution execution in nonMatchingExecutions) { sb.Append(execution); sb.Append("\n"); } sb.Append("]\n"); Assert.Fail(sb.ToString()); } }
protected internal static string ExecutionTreeToString(ExecutionTree executionTree) { StringBuilder sb = new StringBuilder(); sb.Append(executionTree.Execution); sb.Append("[activityId="); sb.Append(executionTree.ActivityId); sb.Append(", isScope="); sb.Append(executionTree.Scope); sb.Append(", isConcurrent="); sb.Append(executionTree.Concurrent); sb.Append(", isEventScope="); sb.Append(executionTree.EventScope); sb.Append("]"); return(sb.ToString()); }
/// <summary> /// This assumes that all children have been fetched /// </summary> protected internal virtual bool Matches(ExecutionTree tree) { // match activity id string actualActivityId = tree.ActivityId; if (string.ReferenceEquals(expectedActivityId, null) && !string.ReferenceEquals(actualActivityId, null)) { return(false); } else if (!string.ReferenceEquals(expectedActivityId, null) && !expectedActivityId.Equals(tree.ActivityId)) { return(false); } if (!string.ReferenceEquals(expectedId, null) && !expectedId.Equals(tree.Id)) { return(false); } // match is scope if (expectedIsScope != null && !expectedIsScope.Equals(tree.Scope)) { return(false); } if (expectedIsConcurrent != null && !expectedIsConcurrent.Equals(tree.Concurrent)) { return(false); } if (expectedIsEventScope != null && !expectedIsEventScope.Equals(tree.EventScope)) { return(false); } // match children if (tree.Executions.Count != ChildAssertions.Count) { return(false); } IList <ExecutionTreeStructureAssertion> unmatchedChildAssertions = new List <ExecutionTreeStructureAssertion>(ChildAssertions); foreach (ExecutionTree child in tree.Executions) { foreach (ExecutionTreeStructureAssertion childAssertion in unmatchedChildAssertions) { if (childAssertion.Matches(child)) { unmatchedChildAssertions.Remove(childAssertion); break; } } } if (unmatchedChildAssertions.Count > 0) { return(false); } return(true); }