Example #1
0
 protected void clearHistory() {
   if (sessionPersistence) {
     logService.clear();
   } else {
     inMemoryLogger.clear();
   }
 }
Example #2
0
 public void assertNodeTriggered(long processInstanceId, String... nodeNames) {
   List<String> names = new ArrayList<String>();
   for (String nodeName : nodeNames) {
     names.add(nodeName);
   }
   if (sessionPersistence) {
     List<NodeInstanceLog> logs = logService.findNodeInstances(processInstanceId);
     if (logs != null) {
       for (NodeInstanceLog l : logs) {
         String nodeName = l.getNodeName();
         if ((l.getType() == NodeInstanceLog.TYPE_ENTER
                 || l.getType() == NodeInstanceLog.TYPE_EXIT)
             && names.contains(nodeName)) {
           names.remove(nodeName);
         }
       }
     }
   } else {
     for (LogEvent event : inMemoryLogger.getLogEvents()) {
       if (event instanceof RuleFlowNodeLogEvent) {
         String nodeName = ((RuleFlowNodeLogEvent) event).getNodeName();
         if (names.contains(nodeName)) {
           names.remove(nodeName);
         }
       }
     }
   }
   if (!names.isEmpty()) {
     String s = names.get(0);
     for (int i = 1; i < names.size(); i++) {
       s += ", " + names.get(i);
     }
     fail("Node(s) not executed: " + s);
   }
 }
Example #3
0
 protected void clearHistory() {
   if (sessionPersistence && logService != null) {
     logService.clear();
   } else if (inMemoryLogger != null) {
     inMemoryLogger.clear();
   }
 }
  /* The purpose of the shared entity manager is to allow the application domain
   * and JBPM domain to be persisted by a single entity manager and transaction.
   */
  @Test
  public void testSpringWithJTAAndSharedEMFAndUserManagedTx() throws Exception {

    UserTransaction ut =
        (UserTransaction)
            new InitialContext().lookup(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME);
    ut.begin();

    KieSession ksession = getKieSession();
    TaskService taskService = getTaskService();
    ProcessInstance processInstance = ksession.startProcess(SAMPLE_HELLO_PROCESS_ID);

    System.out.println("Process started");

    AuditLogService logService = getLogService();
    ProcessInstanceLog log = logService.findProcessInstance(processInstance.getId());
    assertNotNull(log);

    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK");
    System.out.println("Found " + tasks.size() + " task(s) for user '" + USER_JOHN + "'");
    assertEquals(1, tasks.size());

    long taskId = tasks.get(0).getId();
    taskService.start(taskId, USER_JOHN);
    taskService.complete(taskId, USER_JOHN, null);

    tasks = taskService.getTasksAssignedAsPotentialOwner(USER_MARY, "en-UK");
    System.out.println("Found " + tasks.size() + " task(s) for user '" + USER_MARY + "'");
    assertEquals(1, tasks.size());

    taskId = tasks.get(0).getId();
    taskService.start(taskId, USER_MARY);
    taskService.complete(taskId, USER_MARY, null);

    processInstance = ksession.getProcessInstance(processInstance.getId());
    assertNull(processInstance);
    System.out.println("Process instance completed");

    ut.commit();
  }
  public void assertNodeTriggered(long processInstanceId, String... nodeNames) {
    List<String> names = new ArrayList<String>();
    for (String nodeName : nodeNames) {
      names.add(nodeName);
    }
    List<NodeInstanceLog> logs = logService.findNodeInstances(processInstanceId);
    if (logs != null) {
      for (NodeInstanceLog l : logs) {
        String nodeName = l.getNodeName();
        if ((l.getType() == NodeInstanceLog.TYPE_ENTER || l.getType() == NodeInstanceLog.TYPE_EXIT)
            && names.contains(nodeName)) {
          names.remove(nodeName);
        }
      }
    }

    if (!names.isEmpty()) {
      String s = names.get(0);
      for (int i = 1; i < names.size(); i++) {
        s += ", " + names.get(i);
      }
      fail("Node(s) not executed: " + s);
    }
  }
 protected void clearHistory() {
   if (logService != null) {
     logService.clear();
   }
 }