Ejemplo n.º 1
0
        protected virtual void OnSaveDefinitionWithTheSameMd5ShouldFail(IProcessDefinitionPersisnenceService service)
        {
            var processDefinition = BuildProcessdefinition();

            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1);
            processDefinition.Id = Guid.NewGuid();
            Assert.Throws <ArgumentException>(() =>
            {
                service.Create(processDefinition, ProcessDefStatusEnum.Active, 1);
            });
        }
        public void TestCreateProcessDefinitionWithScriptAndRetrieve()
        {
            ProcessDefinition pd      = BuildProcessdefinition("id.123", "test_definition", "description");
            Md5CalcVisitor    visitor = new Md5CalcVisitor();

            pd.Accept(visitor);
            string md5 = visitor.CalculateMd5();
            IProcessDefinitionPersisnenceService service = InstService();

            service.Create(pd, ProcessDefStatusEnum.Active, 1);
            IReadOnlyList <ProcessDefinitionDigest> flows = service.LisAlltWorkflows();

            Assert.IsNotNull(flows);
            Assert.AreEqual(1, flows.Count);
            ProcessDefStatusEnum stat;
            ProcessDefinition    savedPd;

            AccountData[] accounts;
            Assert.IsTrue(service.TryFind(flows[0].Id, flows[0].Version, out savedPd, out stat, out accounts));

            Assert.IsNotNull(savedPd);
            visitor.Reset();
            savedPd.Accept(visitor);
            string savedMd5 = visitor.CalculateMd5();

            Assert.AreEqual(md5, savedMd5);
        }
Ejemplo n.º 3
0
        protected virtual void OnTestLoadSimpleRuntimeProcess()
        {
            IProcessDefinitionPersisnenceService service = GetProcessDefinitionPersistenceService();
            var processDefinition = BuildProcessdefinition();

            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1);
            Md5CalcVisitor visitor = new Md5CalcVisitor();

            processDefinition.Accept(visitor);
            string md5 = visitor.CalculateMd5();
            IProcessRuntimeService pservice   = GetProcessRuntime();
            PropertySetCollection  collection = new PropertySetCollection(new PropertySchemaSet(new PropertySchemaFactory()));
            IProcessRuntime        runtime    = pservice.Create(processDefinition, collection);

            IProcessRuntime        ufRuntime;
            StepRuntime            nextStep;
            IPropertySetCollection ufCollection;
            bool val = pservice.TryUnfreeze(runtime.Id, out ufRuntime, out nextStep, out ufCollection);

            Assert.IsTrue(val);
            Assert.IsNotNull(ufRuntime);
            Assert.IsNotNull(ufCollection);
            Assert.AreEqual(ProcessStateEnum.NotStarted, ufRuntime.State);
            Assert.AreEqual(runtime.Id, ufRuntime.Id);
            string policyNumber = collection.Get <string>("PolicyNumber");

            Assert.IsTrue(string.IsNullOrEmpty(policyNumber));
        }
Ejemplo n.º 4
0
        protected virtual void OnCreateProcessUsingExistingAccounts(IProcessDefinitionPersisnenceService service)
        {
            var processDefinition = BuildProcessdefinition();

            Assert.IsNotNull(processDefinition);
            AccountData[] accounts = new[]
            {
                new AccountData
                {
                    AccountType  = 1,
                    Id           = Guid.NewGuid(),
                    Name         = "Underwriters",
                    SourceSystem = "ActiveDirectory"
                },
                new AccountData
                {
                    AccountType  = 1,
                    Id           = Guid.NewGuid(),
                    Name         = "Modeler",
                    SourceSystem = "ActiveDirectory"
                },
            };
            service.CreateAccounts(accounts);
            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1, accounts);
            ProcessDefStatusEnum status;

            AccountData[] pdAccounts;
            Assert.IsTrue(service.TryFind(processDefinition.Id, 1, out processDefinition, out status, out pdAccounts));
            Assert.IsNotNull(pdAccounts);
            Assert.AreEqual(2, pdAccounts.Length);
            Assert.IsNotNull(pdAccounts.FirstOrDefault(d => d.Id == accounts[0].Id));
            Assert.IsNotNull(pdAccounts.FirstOrDefault(d => d.Id == accounts[1].Id));
        }
Ejemplo n.º 5
0
        protected virtual ProcessDefinition OnCreateProcessDefinition(IProcessDefinitionPersisnenceService service)
        {
            var processDefinition = BuildProcessdefinition();

            Assert.IsNotNull(processDefinition);
            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1);
            return(processDefinition);
        }
Ejemplo n.º 6
0
        protected virtual void OnTestExecuteWorkflowFromSuspendedStep()
        {
            var processDefinition = BuildProcessWithTasks();
            IProcessDefinitionPersisnenceService service = GetProcessDefinitionPersistenceService();

            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1);

            IProcessRuntimeService            pservice   = GetProcessRuntime();
            PropertySetCollection             collection = new PropertySetCollection(new PropertySchemaSet(new PropertySchemaFactory()));
            Mock <IProcessRuntimeEnvironment> mEnv       = new Mock <IProcessRuntimeEnvironment>();

            mEnv.SetupGet(m => m.PropertySet).Returns(collection).Verifiable();
            mEnv.Setup(m => m.TaskServiceAsync())
            .Returns(() =>
                     Task.FromResult(new ExecutionResult(StepExecutionStatusEnum.Suspend)))
            .Verifiable();

            IProcessRuntime runtime = pservice.Create(processDefinition, collection);

            string[] error;
            Assert.IsTrue(runtime.TryCompile(out error));
            var startStep = runtime.StartSteps.First();

            Assert.IsNotNull(startStep);
            var result = runtime.Execute(startStep, mEnv.Object);

            Assert.IsNotNull(result);
            Assert.AreEqual(StepExecutionStatusEnum.Ready, result.Item1.Status);
            Assert.AreEqual("task_1", result.Item2.StepId);
            // freeze the workflow
            pservice.Freeze(runtime, collection);
            // execute Task step
            result = runtime.Execute(result.Item2, mEnv.Object);
            Assert.IsNotNull(result);
            Assert.AreEqual(StepExecutionStatusEnum.Suspend, result.Item1.Status);
            Assert.AreEqual("task_1", result.Item2.StepId);
            mEnv.Verify(m => m.TaskServiceAsync(), Times.Once);
            Assert.IsNotNull(runtime.SuspendedInStep);
            Assert.AreEqual("task_1", runtime.SuspendedInStep.StepId);
            // freeze the process
            pservice.Freeze(runtime, collection);
            // unfreeze the process

            IProcessRuntime        unfrozenProcess;
            StepRuntime            nextStep;
            IPropertySetCollection unfrozenCollection;

            Assert.IsTrue(pservice.TryUnfreeze(runtime.Id, out unfrozenProcess, out nextStep, out unfrozenCollection));
            Assert.IsNotNull(unfrozenProcess);
            Assert.IsNotNull(unfrozenCollection);
            Assert.AreEqual(1, unfrozenCollection.Get <int?>("Count"));
            Assert.AreEqual("P12345", unfrozenCollection.Get <string>("PolicyNumber"));
            Assert.AreEqual(ProcessStateEnum.Suspended, unfrozenProcess.State);
            Assert.IsNotNull(unfrozenProcess.SuspendedInStep);
            Assert.AreEqual("task_1", unfrozenProcess.SuspendedInStep.StepId);
        }
        public void TestContinueAfterSuspending()
        {
            var factory = new ProcessBuilderFactory();
            var builder = factory.CreateProcess(id: "com.klaudwerk.workflow.renewal",
                                                name: "Renewal", description: "Policy Renewal");
            IReadOnlyList <ProcessValidationResult> result;

            builder.Start("s_1").Handler().HumanTask().Done().SetName("Start").Done()
            .Step("s_2").Handler().HumanTask().Done().Done()
            .Step("s_3").Handler().HumanTask().Done().Done()
            .End("e_1").SetName("End Process").Done()
            .Link().From("s_1").To("s_2").Name("s_1_s_2").Done()
            .Link().From("s_2").To("s_3").Name("s_2_s_3").Done()
            .Link().From("s_3").To("e_1").Name("end").Done()
            .TryValidate(out result);

            ProcessDefinition processDefinition          = builder.Build();
            IProcessDefinitionPersisnenceService service = GetProcessDefinitionPersistenceService();

            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1);

            IProcessRuntimeService            pservice   = GetProcessRuntime();
            PropertySetCollection             collection = new PropertySetCollection(new PropertySchemaSet(new PropertySchemaFactory()));
            Mock <IProcessRuntimeEnvironment> mEnv       = new Mock <IProcessRuntimeEnvironment>();

            mEnv.SetupGet(m => m.PropertySet).Returns(collection).Verifiable();
            mEnv.Setup(m => m.TaskServiceAsync())
            .Returns(() =>
                     Task.FromResult(new ExecutionResult(StepExecutionStatusEnum.Suspend)))
            .Verifiable();

            IProcessRuntime runtime = pservice.Create(processDefinition, collection);

            string[] errors;
            runtime.TryCompile(out errors);

            IProcessRuntime        ufRuntime;
            StepRuntime            ufStep;
            IPropertySetCollection ufCollection;
            Tuple <ExecutionResult, StepRuntime> execute = runtime.Execute(runtime.StartSteps[0], mEnv.Object);

            Assert.IsNotNull(execute);
            Assert.AreEqual(StepExecutionStatusEnum.Suspend, execute.Item1.Status, "The Workflow should be in Suspended state");
            Assert.AreEqual(execute.Item2.StepId, "s_1");
            execute = runtime.Continue(mEnv.Object);
            Assert.IsNotNull(execute);
            Assert.AreEqual(StepExecutionStatusEnum.Ready, execute.Item1.Status, "The Workflow should be in Suspended state");
            Assert.AreEqual(execute.Item2.StepId, "s_2");

            pservice.TryUnfreeze(runtime.Id, out ufRuntime, out ufStep, out ufCollection);
            Assert.IsNotNull(ufRuntime);
            Assert.IsNotNull(ufStep);
            Assert.AreEqual("s_2", ufStep.StepId);
        }
Ejemplo n.º 8
0
        protected virtual void OnCreateFlowWithAssociatedSecutityAccounts(IProcessDefinitionPersisnenceService service, AccountData[] accounts)
        {
            var processDefinition = BuildProcessdefinition();

            Assert.IsNotNull(processDefinition);
            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1, accounts);
            ProcessDefStatusEnum status;

            AccountData[] pdAccounts;
            Assert.IsTrue(service.TryFind(processDefinition.Id, 1, out processDefinition, out status, out pdAccounts));
            Assert.IsNotNull(pdAccounts);
            Assert.AreEqual(2, pdAccounts.Length);
            Assert.IsNotNull(pdAccounts.FirstOrDefault(d => d.Id == accounts[0].Id));
            Assert.IsNotNull(pdAccounts.FirstOrDefault(d => d.Id == accounts[1].Id));
        }
Ejemplo n.º 9
0
        protected virtual void OnPossibleToUpdateNameAndDescription(IProcessDefinitionPersisnenceService service)
        {
            var processDefinition = BuildProcessdefinition();

            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1);
            ProcessDefinition    definition;
            ProcessDefStatusEnum stat;

            AccountData[] pdAccounts;
            Assert.IsTrue(service.TryFind(processDefinition.Id, 1, out definition, out stat, out pdAccounts));
            service.Update(processDefinition.Id, 1, pd => { pd.Name = "New Name"; });
            var flows = service.ActivetWorkflows();

            Assert.IsNotNull(flows);
            Assert.AreEqual("New Name", flows[0].Name);
        }
Ejemplo n.º 10
0
        protected virtual IProcessRuntime OnTestCreateSimplePersistentRuntime()
        {
            IProcessDefinitionPersisnenceService service = GetProcessDefinitionPersistenceService();
            var processDefinition = BuildProcessdefinition();

            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1);
            Md5CalcVisitor visitor = new Md5CalcVisitor();

            processDefinition.Accept(visitor);
            string md5 = visitor.CalculateMd5();
            IProcessRuntimeService pservice   = GetProcessRuntime();
            PropertySetCollection  collection = new PropertySetCollection(new PropertySchemaSet(new PropertySchemaFactory()));
            IProcessRuntime        runtime    = pservice.Create(processDefinition, collection);

            Assert.IsNotNull(runtime);
            return(runtime);
        }
Ejemplo n.º 11
0
        public void DeployWorkflow(Guid guid)
        {
            List <ProcessDefinition> defs = new List <ProcessDefinition>();

            _registries.ForEach(r =>
            {
                ProcessDefinition pd;
                if (r.TryGet(guid, out pd))
                {
                    defs.Add(pd);
                }
            });
            if (defs.Count == 0)
            {
                throw new ArgumentException($"No Process Definition with ID={guid} was found.");
            }
            if (defs.Count > 1)
            {
                throw new ArgumentException($"{defs.Count} Process Definitions with ID={guid} was found.");
            }
            Md5CalcVisitor visitor = new Md5CalcVisitor();

            defs[0].Accept(visitor);
            string md5 = visitor.CalculateMd5();
            IReadOnlyList <ProcessDefinitionDigest> processes = _persistence.LisAlltWorkflows();
            var processDefinitionDigests = processes.Where(p => p.Id == guid).ToArray();
            int nextVersion = processDefinitionDigests.Length > 0?processDefinitionDigests.Max(p => p.Version) + 1:1;

            foreach (ProcessDefinitionDigest p in processDefinitionDigests)
            {
                if (p.Md5 == md5)
                {
                    throw new ArgumentException($"Process ID={defs[0].Id} MD5={md5} already deployed. Cannot deploy the same process with the same MD5.");
                }
            }
            foreach (ProcessDefinitionDigest p in processes)
            {
                _persistence.SetStatus(p.Id, p.Version, ProcessDefStatusEnum.NotActive);
            }
            _persistence.Create(defs[0], ProcessDefStatusEnum.Active, nextVersion);
        }
Ejemplo n.º 12
0
        protected virtual void OnChangeProcessDefinitionStatus(IProcessDefinitionPersisnenceService service)
        {
            var processDefinition = BuildProcessdefinition();

            Assert.IsNotNull(processDefinition);
            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1);
            IReadOnlyList <ProcessDefinitionDigest> flows = service.LisAlltWorkflows();

            Assert.IsNotNull(flows);
            Assert.AreEqual(1, flows.Count);
            flows = service.ActivetWorkflows();
            Assert.IsNotNull(flows);
            Assert.AreEqual(1, flows.Count);
            Guid id = flows[0].Id;

            Assert.IsTrue(service.SetStatus(id, 1, ProcessDefStatusEnum.NotActive));
            flows = service.ActivetWorkflows();
            Assert.IsNotNull(flows);
            Assert.AreEqual(0, flows.Count);
            flows = service.LisAlltWorkflows();
            Assert.IsNotNull(flows);
            Assert.AreEqual(1, flows.Count);
        }
Ejemplo n.º 13
0
        protected virtual void OnTryFindFlow(IProcessDefinitionPersisnenceService service)
        {
            var processDefinition = BuildProcessdefinition();

            Assert.IsNotNull(processDefinition);
            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1);
            ProcessDefinition    definition;
            ProcessDefStatusEnum stat;

            AccountData[] pdAccounts;
            Assert.IsTrue(service.TryFind(processDefinition.Id, 1, out definition, out stat, out pdAccounts));
            Assert.IsNotNull(definition);
            Md5CalcVisitor visitor = new Md5CalcVisitor();

            processDefinition.Accept(visitor);
            string md5 = visitor.CalculateMd5();

            visitor.Reset();
            definition.Accept(visitor);
            string restoredMd5 = visitor.CalculateMd5();

            Assert.AreEqual(md5, restoredMd5);
        }
        public void TestRetrieveActiveProcessDefitinionsListsForAccounts()
        {
            AccountData[] accounts = new[]
            {
                new AccountData
                {
                    AccountType  = 1,
                    Id           = Guid.NewGuid(),
                    Name         = "Underwriters",
                    SourceSystem = "ActiveDirectory"
                },
                new AccountData
                {
                    AccountType  = 1,
                    Id           = Guid.NewGuid(),
                    Name         = "Modeler",
                    SourceSystem = "ActiveDirectory"
                },
                new AccountData
                {
                    AccountType  = 1,
                    Id           = Guid.NewGuid(),
                    Name         = "Role1",
                    SourceSystem = "ActiveDirectory"
                },
                new AccountData
                {
                    AccountType  = 1,
                    Id           = Guid.NewGuid(),
                    Name         = "Role2",
                    SourceSystem = "ActiveDirectory"
                },
                new AccountData
                {
                    AccountType  = 1,
                    Id           = Guid.NewGuid(),
                    Name         = "None",
                    SourceSystem = "ActiveDirectory"
                }
            };
            var collection = _database.GetCollection <ProcessDefinitionPersistence>(MongoProcessDefinitionPersistenceService.CollectionName);
            IProcessDefinitionPersisnenceService service = InstService();
            ProcessDefinition pd1 = BuildProcessdefinition();
            ProcessDefinition pd2 = BuildProcessdefinition(id: "mongo.flow", name: "pd_1", description: "second flow");

            service.Create(pd1, ProcessDefStatusEnum.Active, 1, accounts[0], accounts[1]);
            service.Create(pd2, ProcessDefStatusEnum.Active, 1, accounts[2], accounts[3]);
            //List Underwriter should return one definition
            IReadOnlyList <ProcessDefinitionDigest> digest = service.ActivetWorkflows(accounts[0].Name);

            Assert.IsNotNull(digest);
            Assert.AreEqual(1, digest.Count);
            Assert.AreEqual(pd1.Name, digest[0].Name);

            digest = service.ActivetWorkflows(accounts[1].Name, accounts[3].Name);
            Assert.IsNotNull(digest);
            Assert.AreEqual(2, digest.Count);
            Assert.AreEqual(1, digest.Count(c => c.Name == pd1.Name));
            Assert.AreEqual(1, digest.Count(c => c.Name == pd2.Name));

            digest = service.ActivetWorkflows(accounts[4].Name);
            Assert.IsNotNull(digest);
            Assert.AreEqual(0, digest.Count);
        }
Ejemplo n.º 15
0
        protected virtual void OnTestExecuteMultipleStepsSaveStateBetweenSteps()
        {
            var factory = new ProcessBuilderFactory();
            var builder = factory.CreateProcess(id: "com.klaudwerk.workflow.renewal",
                                                name: "Renewal", description: "Policy Renewal");
            IReadOnlyList <ProcessValidationResult> result;

            builder.Variables()
            .Name("Count")
            .Type(VariableTypeEnum.Int)
            .Done()
            .Start("s_1")
            .SetName("Start")
            .OnEntry()
            .Language(ScriptLanguage.CSharpScript)
            .Body("" +
                  " PropertySet.Set(\"Count\",(int?)1);" +
                  " return 1;")
            .Done()
            .Done()
            .Step("s_2")
            .OnEntry()
            .Language(ScriptLanguage.CSharpScript)
            .Body("" +
                  " PropertySet.Set(\"Count\",(int?)2);" +
                  " return 1;")
            .Done()
            .Done()
            .Step("s_3")
            .OnEntry()
            .Language(ScriptLanguage.CSharpScript)
            .Body("" +
                  " PropertySet.Set(\"Count\",(int?)3);" +
                  " return 1;")
            .Done()
            .Done()
            .End("e_1")
            .SetName("End Process")
            .Done()
            .Link()
            .From("s_1")
            .To("s_2")
            .Name("s_1_s_2")
            .Done()
            .Link()
            .From("s_2")
            .To("s_3")
            .Name("s_2_s_3")
            .Done()
            .Link()
            .From("s_3")
            .To("e_1")
            .Name("end")
            .Done()
            .TryValidate(out result);
            ProcessDefinition processDefinition          = builder.Build();
            IProcessDefinitionPersisnenceService service = GetProcessDefinitionPersistenceService();

            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1);

            IProcessRuntimeService            pservice   = GetProcessRuntime();
            PropertySetCollection             collection = new PropertySetCollection(new PropertySchemaSet(new PropertySchemaFactory()));
            Mock <IProcessRuntimeEnvironment> mEnv       = new Mock <IProcessRuntimeEnvironment>();

            mEnv.SetupGet(m => m.PropertySet).Returns(collection).Verifiable();
            mEnv.Setup(m => m.TaskServiceAsync())
            .Returns(() =>
                     Task.FromResult(new ExecutionResult(StepExecutionStatusEnum.Suspend)))
            .Verifiable();
            IProcessRuntime runtime = pservice.Create(processDefinition, collection);

            string[] errors;
            runtime.TryCompile(out errors);
            IProcessRuntime        ufRuntime;
            StepRuntime            ufStep;
            IPropertySetCollection ufCollection;

            pservice.TryUnfreeze(runtime.Id, out ufRuntime, out ufStep, out ufCollection);
            Assert.IsNotNull(ufRuntime);
            Assert.IsNotNull(ufCollection);
            Assert.IsNull(ufStep);
            Assert.IsNull(ufCollection.Get <int?>("Count"));
            Assert.AreEqual(ProcessStateEnum.NotStarted, ufRuntime.State);

            Tuple <ExecutionResult, StepRuntime> exResult = runtime.Execute(runtime.StartSteps[0], mEnv.Object);

            Assert.IsNotNull(exResult);
            pservice.TryUnfreeze(runtime.Id, out ufRuntime, out ufStep, out ufCollection);
            Assert.AreEqual(1, ufCollection.Get <int?>("Count"));
            Assert.AreEqual(ProcessStateEnum.Ready, ufRuntime.State);
            Assert.IsNotNull(ufStep);
            Assert.AreEqual("s_2", ufStep.StepId);

            exResult = runtime.Execute(exResult.Item2, mEnv.Object);
            Assert.IsNotNull(exResult);
            pservice.TryUnfreeze(runtime.Id, out ufRuntime, out ufStep, out ufCollection);
            Assert.AreEqual(2, ufCollection.Get <int?>("Count"));
            Assert.AreEqual(ProcessStateEnum.Ready, ufRuntime.State);
            Assert.IsNotNull(ufStep);
            Assert.AreEqual("s_3", ufStep.StepId);

            exResult = runtime.Execute(exResult.Item2, mEnv.Object);
            Assert.IsNotNull(exResult);
            pservice.TryUnfreeze(runtime.Id, out ufRuntime, out ufStep, out ufCollection);
            Assert.AreEqual(3, ufCollection.Get <int?>("Count"));
            Assert.AreEqual(ProcessStateEnum.Ready, ufRuntime.State);
            Assert.IsNotNull(ufStep);
            Assert.AreEqual("e_1", ufStep.StepId);

            exResult = runtime.Execute(exResult.Item2, mEnv.Object);
            Assert.IsNotNull(exResult);
            pservice.TryUnfreeze(runtime.Id, out ufRuntime, out ufStep, out ufCollection);
            Assert.AreEqual(3, ufCollection.Get <int?>("Count"));
            Assert.AreEqual(ProcessStateEnum.Completed, ufRuntime.State);
            Assert.IsNull(ufStep);
        }
        public void TestContinueTaskWithLinkAnVariables()
        {
            var factory = new ProcessBuilderFactory();
            var builder = factory.CreateProcess(id: "com.klaudwerk.workflow.renewal",
                                                name: "Renewal", description: "Policy Renewal");
            IReadOnlyList <ProcessValidationResult> result;

            builder
            .Variables().Name("v_1").Type(VariableTypeEnum.String).Done()
            .Variables().Name("v_2").Type(VariableTypeEnum.String).Done()
            .Start("s_1").Handler().HumanTask().Done().SetName("Start")
            .Vars().Name("v_1").Done()
            .Vars().Name("v_2").Done()
            .Done()
            .Step("s_2").Handler().HumanTask().Done()
            .Done()
            .Step("s_3").Handler().HumanTask().Done()
            .Vars().Name("v_1").OnExit().Done()
            .Vars().Name("v_2").OnExit().Done()
            .Done()
            .End("e_1").SetName("End Process").Done()
            .Link().From("s_1").To("s_2").Name("s_1_s_2").Done()
            .Link().From("s_1").To("s_3").Name("s_1_s_3").Done()
            .Link().From("s_2").To("e_1").Name("s2_end").Done()
            .Link().From("s_3").To("e_1").Name("s3_end").Done()
            .TryValidate(out result);

            ProcessDefinition processDefinition          = builder.Build();
            IProcessDefinitionPersisnenceService service = GetProcessDefinitionPersistenceService();

            service.Create(processDefinition, ProcessDefStatusEnum.Active, 1);
            // retrieve process definition
            var flows = service.ActivetWorkflows();

            Assert.IsNotNull(flows);
            Assert.AreEqual(1, flows.Count);
            ProcessDefinition    loadedPd;
            ProcessDefStatusEnum status;

            Assert.IsTrue(service.TryFind(flows[0].Id, flows[0].Version, out loadedPd, out status, out accounts));

            IProcessRuntimeService            pservice   = GetProcessRuntime();
            PropertySetCollection             collection = new PropertySetCollection(new PropertySchemaSet(new PropertySchemaFactory()));
            Mock <IProcessRuntimeEnvironment> mEnv       = new Mock <IProcessRuntimeEnvironment>();

            mEnv.SetupGet(m => m.PropertySet).Returns(collection).Verifiable();
            mEnv.Setup(m => m.TaskServiceAsync())
            .Returns(() =>
                     Task.FromResult(new ExecutionResult(StepExecutionStatusEnum.Suspend)))
            .Verifiable();
            mEnv.SetupGet(m => m.Transition).Returns("s_1_s_3");
            IProcessRuntime runtime = pservice.Create(loadedPd, collection);

            string[] errors;
            runtime.TryCompile(out errors);
            Tuple <ExecutionResult, StepRuntime> execute = runtime.Execute(runtime.StartSteps[0], mEnv.Object);

            Assert.IsNotNull(execute);
            Assert.AreEqual(StepExecutionStatusEnum.Suspend, execute.Item1.Status, "The Workflow should be in Suspended state");
            Assert.AreEqual(execute.Item2.StepId, "s_1");
            collection.Set("v_1", "v_1");
            collection.Set("v_2", "v_2");
            execute = runtime.Continue(mEnv.Object);
            Assert.IsNotNull(execute);
            Assert.AreEqual(StepExecutionStatusEnum.Ready, execute.Item1.Status, "The Workflow should be in Suspended state");
            Assert.AreEqual(execute.Item2.StepId, "s_3");
            Assert.IsNotNull(execute.Item2.StepDefinition.VariablesMap);
            Assert.AreEqual(2, execute.Item2.StepDefinition.VariablesMap.Length);
            Assert.AreEqual(VarRequiredEnum.OnExit, execute.Item2.StepDefinition.VariablesMap[0].Required);
            Assert.AreEqual(VarRequiredEnum.OnExit, execute.Item2.StepDefinition.VariablesMap[1].Required);
        }