Ejemplo n.º 1
0
        public static ExecutionAssert assertThat(ExecutionTree tree)
        {
            ExecutionAssert assertion = new ExecutionAssert();

            assertion.tree = tree;
            return(assertion);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public static ExecutionTree forExecution(final String executionId, org.camunda.bpm.engine.ProcessEngine processEngine)
        public static ExecutionTree forExecution(string executionId, ProcessEngine processEngine)
        {
            ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl)processEngine.ProcessEngineConfiguration;

            CommandExecutor commandExecutor = configuration.CommandExecutorTxRequired;

            ExecutionTree executionTree = commandExecutor.execute(new CommandAnonymousInnerClass(executionId));

            return(executionTree);
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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());
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// returns umatched executions in the tree
        /// </summary>
        protected internal virtual IList <Execution> matches(ExecutionTree tree)
        {
            ExecutionEntity   executionEntity     = (ExecutionEntity)tree.Execution;
            IList <Execution> unmatchedExecutions = new List <Execution>();

            if (!expectedProcessDefinitionId.Equals(executionEntity.ProcessDefinitionId))
            {
                unmatchedExecutions.Add(tree.Execution);
            }
            foreach (ExecutionTree child in tree.Executions)
            {
                ((IList <Execution>)unmatchedExecutions).AddRange(matches(child));
            }

            return(unmatchedExecutions);
        }
Ejemplo n.º 6
0
        public virtual void assertExecution(ExecutionTree tree)
        {
            IList <Execution> 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 (Execution execution in nonMatchingExecutions)
                {
                    sb.Append(execution);
                    sb.Append("\n");
                }
                sb.Append("]\n");
                Assert.fail(sb.ToString());
            }
        }
Ejemplo n.º 7
0
        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());
        }
Ejemplo n.º 8
0
        /// <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);
        }