Package org.drools.runtime

Examples of org.drools.runtime.StatefulKnowledgeSession


      }
      throw new IllegalArgumentException("Errors while parsing knowledge base");
    }
    KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("x", "oldValue");
    ProcessInstance processInstance = ksession.startProcess("ParentProcess", params);
    assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);
    assertEquals("new value", ((WorkflowProcessInstance) processInstance).getVariable("y"));
  }
View Full Code Here


    assertEquals("new value", ((WorkflowProcessInstance) processInstance).getVariable("y"));
  }

  public void testSubProcess() throws Exception {
    KnowledgeBase kbase = createKnowledgeBase("BPMN2-SubProcess.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    ProcessInstance processInstance = ksession.startProcess("SubProcess");
    assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);
  }
View Full Code Here

    assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);
  }

  public void testMultiInstanceLoopCharacteristicsProcess() throws Exception {
    KnowledgeBase kbase = createKnowledgeBase("BPMN2-MultiInstanceLoopCharacteristicsProcess.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    Map<String, Object> params = new HashMap<String, Object>();
    List<String> myList = new ArrayList<String>();
    myList.add("First Item");
    myList.add("Second Item");
    params.put("list", myList);
    ProcessInstance processInstance = ksession.startProcess("MultiInstanceLoopCharacteristicsProcess", params);
    assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);
  }
View Full Code Here

    assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);
  }

    public void testEscalationBoundaryEvent() throws Exception {
        KnowledgeBase kbase = createKnowledgeBase("BPMN2-EscalationBoundaryEvent.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
        ProcessInstance processInstance = ksession.startProcess("EscalationBoundaryEvent");
        assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);
    }
View Full Code Here

        assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);
    }

    public void testEscalationBoundaryEventInterrupting() throws Exception {
        KnowledgeBase kbase = createKnowledgeBase("BPMN2-EscalationBoundaryEventInterrupting.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
        ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
        ProcessInstance processInstance = ksession.startProcess("EscalationBoundaryEvent");
        assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);
        // TODO: check for cancellation of task
    }
View Full Code Here

        // TODO: check for cancellation of task
    }

    public void testErrorBoundaryEvent() throws Exception {
        KnowledgeBase kbase = createKnowledgeBase("BPMN2-ErrorBoundaryEventInterrupting.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
        ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
        ProcessInstance processInstance = ksession.startProcess("ErrorBoundaryEvent");
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
    }
View Full Code Here

//    assertProcessInstanceCompleted(processInstance.getId(), ksession);
//    }
   
    public void testIntermediateCatchEventSignal() throws Exception {
    KnowledgeBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventSignal.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
    assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
    ksession = restoreSession(ksession, true);
        // now signal process instance
    ksession.signalEvent("MyMessage", "SomeValue", processInstance.getId());
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
  }
View Full Code Here

    assertProcessInstanceCompleted(processInstance.getId(), ksession);
  }

    public void testIntermediateCatchEventMessage() throws Exception {
        KnowledgeBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventMessage.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
        ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
        assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
        ksession = restoreSession(ksession, true);
        // now signal process instance
        ksession.signalEvent("Message-HelloMessage", "SomeValue", processInstance.getId());
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
    }
View Full Code Here

    assertProcessInstanceCompleted(processInstance.getId(), ksession);
    }

    public void testIntermediateCatchEventTimer() throws Exception {
        KnowledgeBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDuration.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
        ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
        assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
        // now wait for 1 second for timer to trigger
        Thread.sleep(1000);
        ksession = restoreSession(ksession, true);
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
    }
View Full Code Here

//    assertProcessInstanceCompleted(processInstance.getId(), ksession);
//    }

    public void testErrorEndEventProcess() throws Exception {
        KnowledgeBase kbase = createKnowledgeBase("BPMN2-ErrorEndEvent.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
        ProcessInstance processInstance = ksession.startProcess("ErrorEndEvent");
    assertProcessInstanceAborted(processInstance.getId(), ksession);
    }
View Full Code Here

TOP

Related Classes of org.drools.runtime.StatefulKnowledgeSession

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.