Package org.jbpm.graph.exe

Examples of org.jbpm.graph.exe.Token


  public void testAprioriRuntimeKnowledgeScenario4() {
    scenario = 4;
   
    ProcessInstance processInstance = new ProcessInstance(processDefinition);
    Token token = processInstance.getRootToken();
    processInstance.signal();
    processInstance.signal();
   
    assertSame(t, token.getNode());
    assertEquals(3, getNbrOfTasks(token));
   
    addOneTask(token);

    assertSame(t, token.getNode());
    assertEquals(4, getNbrOfTasks(token));
   
    endOneTask(token);
    endOneTask(token);
    endOneTask(token);

    assertSame(t, token.getNode());
    assertEquals(1, getNbrOfTasks(token));
   
    endOneTask(token);

    assertSame(c, token.getNode());
    assertEquals(0, getNbrOfTasks(token));
  }
View Full Code Here


    } finally {
      jbpmContext.close();
    }

    assertEquals(1, testSchedulerService.suspendedTimerTokens.size());
    Token suspendedToken = (Token) testSchedulerService.suspendedTimerTokens.get(0);
    assertSame(processInstance.getRootToken(), suspendedToken);

    jbpmContext = jbpmConfiguration.createJbpmContext();
    testSchedulerService = (TestSchedulerService) jbpmContext.getServices().getSchedulerService();
    try {
      processInstance.resume();
      jbpmContext.save(processInstance);
    } finally {
      jbpmContext.close();
    }

    Token resumedToken = (Token) testSchedulerService.resumedTimerTokens.get(0);
    assertSame(processInstance.getRootToken(), resumedToken);
  }
View Full Code Here

    ProcessInstance processInstance =
        new ProcessInstance(processDefinition);
   
    // After construction, the process execution has one main path
    // of execution (=the root token).
    Token token = processInstance.getRootToken();
   
    // Also after construction, the main path of execution is positioned
    // in the start-state of the process definition.
    assertSame(processDefinition.getStartState(), token.getNode());
   
    // Let's start the process execution, leaving the start-state
    // over its default transition.
    token.signal();
    // The signal method will block until the process execution
    // enters a wait state.

    // The process execution will have entered the first wait state
    // in state 's'. So the main path of execution is not
    // positioned in state 's'
    assertSame(processDefinition.getNode("s"), token.getNode());

    // Let's send another signal.  This will resume execution by
    // leaving the state 's' over its default transition.
    token.signal();
    // Now the signal method returned because the process instance
    // has arrived in the end-state.
   
    assertSame(processDefinition.getNode("end"), token.getNode());
  }
View Full Code Here

      "</process-definition>"
    );
   
    ProcessInstance processInstance =
        new ProcessInstance(processDefinition);
    Token token = processInstance.getRootToken();
    assertSame(processDefinition.getStartState(), token.getNode());

    token.signal();
    assertSame(processDefinition.getNode("phase one"), token.getNode());

    token.signal();
    assertSame(processDefinition.getNode("phase two"), token.getNode());

    token.signal();
    assertSame(processDefinition.getNode("phase three"), token.getNode());

    token.signal();
    assertSame(processDefinition.getNode("end"), token.getNode());
  }
View Full Code Here

    );
   
    // Create an execution of the process definition.
    ProcessInstance processInstance =
        new ProcessInstance(processDefinition);
    Token token = processInstance.getRootToken();
   
    // Let's start the process execution, leaving the start-state
    // over its default transition.
    token.signal();
    // The signal method will block until the process execution
    // enters a wait state.   In this case, that is the task-node.
    assertSame(processDefinition.getNode("t"), token.getNode());

    // When execution arrived in the task-node, a task 'change nappy'
    // was created and the NappyAssignmentHandler was called to determine
    // to whom the task should be assigned.  The NappyAssignmentHandler
    // returned 'papa'.

    // In a real environment, the tasks would be fetched from the
    // database with the methods in the org.jbpm.db.TaskMgmtSession.
    // Since we don't want to include the persistence complexity in
    // this example, we just take the first task-instance of this
    // process instance (we know there is only one in this test
    // scenario.
    TaskInstance taskInstance = (TaskInstance
        processInstance
          .getTaskMgmtInstance()
          .getTaskInstances()
          .iterator().next();

    // Now, we check if the taskInstance was actually assigned to 'papa'.
    assertEquals("papa", taskInstance.getActorId() );
   
    // Now suppose that 'papa' has done his duties and marks the task
    // as done.
    taskInstance.end();
    // Since this was the last (only) task to do, the completion of this
    // task triggered the continuation of the process instance execution.
   
    assertSame(processDefinition.getNode("end"), token.getNode());
  }
View Full Code Here

    assertEquals("me", stalker.getActorId());
    assertEquals("me", changeNappy.getActorId());
   
    changeNappy.end();
   
    Token token = processInstance.getRootToken();
    TaskInstance beautySleep = (TaskInstance) taskMgmtInstance.getUnfinishedTasks(token).iterator().next();
    assertEquals("me", beautySleep.getActorId());
  }
View Full Code Here

    changeNappy.setActorId("johndoe");
    stalker.setPooledActors(new String[]{"footballers", "hooligans", "stewards"});
   
    changeNappy.end();

    Token token = processInstance.getRootToken();
    TaskInstance makeBottle = (TaskInstance) taskMgmtInstance.getUnfinishedTasks(token).iterator().next();
    assertEquals("johndoe", makeBottle.getActorId());
   
    Set retrievedTaskInstancePooledActorIds = new HashSet();
    Iterator iter = makeBottle.getPooledActors().iterator();
View Full Code Here

      "  </task-node>" +
      "</process-definition>"
    );

    ProcessInstance processInstance = new ProcessInstance(processDefinition);
    Token token = processInstance.getRootToken();
    processInstance.signal();
   
    TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance();
    TaskInstance throwRock = (TaskInstance) taskMgmtInstance.getUnfinishedTasks(token).iterator().next();
    assertEquals("johndoe", throwRock.getActorId());
View Full Code Here

      "  </task-node>" +
      "  <state name='b' />" +
      "</process-definition>"
    );
    ProcessInstance processInstance = new ProcessInstance(processDefinition);
    Token token = processInstance.getRootToken();
    processInstance.signal();

    TaskMgmtInstance tmi = (TaskMgmtInstance) processInstance.getInstance(TaskMgmtInstance.class);
    assertNotNull(tmi);
    assertNull(tmi.getTaskInstances());
   
    // if no tasks are created and signal is last (default) then execution continues
    assertSame(processDefinition.getNode("b"), token.getNode());
  }
View Full Code Here

      "  </task-node>" +
      "  <state name='b' />" +
      "</process-definition>"
    );
    ProcessInstance processInstance = new ProcessInstance(processDefinition);
    Token token = processInstance.getRootToken();
    processInstance.signal();
    assertSame(processDefinition.getNode("a"), token.getNode());
    processInstance.signal();
    assertSame(processDefinition.getNode("b"), token.getNode());
  }
View Full Code Here

TOP

Related Classes of org.jbpm.graph.exe.Token

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.