public virtual void testAsyncAfterExclusiveGateway() { // start process instance with variables IDictionary <string, ITypedValue> variables = new Dictionary <string, ITypedValue>(); variables["flow"] = new BooleanValueImpl(false); IProcessInstance pi = runtimeService.StartProcessInstanceByKey("testExclusiveGateway", variables); // listeners should be fired AssertListenerStartInvoked(pi); AssertListenerEndInvoked(pi); // the process should Wait *after* the gateway Assert.AreEqual(1, managementService.CreateJobQuery(c => c.SuspensionState == SuspensionStateFields.Active.StateCode).Count()); ExecuteAvailableJobs(); // if the Waiting job is executed there should be 2 IUser tasks IQueryable <ITask> taskQuery = taskService.CreateTaskQuery(); //Assert.AreEqual(1, taskQuery.Active().Count()); // finish tasks //IList<ITask> tasks = taskQuery.Active().ToList(); //foreach (ITask task in tasks) //{ // taskService.Complete(task.Id); //} AssertProcessEnded(pi.ProcessInstanceId); }
public virtual void testAsyncAfterAndBeforeExclusiveGateway() { // start process instance with variables IDictionary <string, ITypedValue> variables = new Dictionary <string, ITypedValue>(); variables["flow"] = new BooleanValueImpl(false); IProcessInstance pi = runtimeService.StartProcessInstanceByKey("testExclusiveGateway", variables); // no listeners are fired: AssertNotListenerStartInvoked(pi); AssertNotListenerEndInvoked(pi); // we should Wait *before* the gateway: IJob job = managementService.CreateJobQuery().First(); Assert.NotNull(job); // after executing the gateway: managementService.ExecuteJob(job.Id); // the listeners are fired: AssertListenerStartInvoked(pi); AssertListenerEndInvoked(pi); // and we will Wait *after* the gateway: Assert.AreEqual(1, managementService.CreateJobQuery(c => c.SuspensionState == SuspensionStateFields.Active.StateCode).Count()); }
public virtual void testAsyncExclusiveGateway() { // The test needs variables to work properly IDictionary <string, ITypedValue> variables = new Dictionary <string, ITypedValue>(); variables["flow"] = new BooleanValueImpl(false); // start PI string pid = runtimeService.StartProcessInstanceByKey("asyncExclusiveGateway", variables).ProcessInstanceId; // now there is 1 job in the database: Assert.AreEqual(1, managementService.CreateJobQuery().Count()); // the listener was not invoked now: Assert.IsNull(runtimeService.GetVariable(pid, "listener")); // there is no gateway: Assert.IsNull(taskService.CreateTaskQuery().First()); ExecuteAvailableJobs(); // the listener was now invoked: Assert.NotNull(runtimeService.GetVariable(pid, "listener")); // there isn't a job anymore Assert.AreEqual(0, managementService.CreateJobQuery().Count()); // now there is a userTask Assert.NotNull(taskService.CreateTaskQuery().First()); string taskId = taskService.CreateTaskQuery().First().Id; taskService.Complete(taskId); }