Package org.drools.runtime

Examples of org.drools.runtime.StatefulKnowledgeSession.startProcess()


        KnowledgeBase kbase = kbuilder.newKnowledgeBase();
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
        List<String> list = new ArrayList<String>();
        ksession.setGlobal("list", list);
        ProcessInstance processInstance =
            ksession.startProcess("org.drools.actions1");
        assertEquals(1, list.size());
        assertEquals("Action1", list.get(0));
        list.clear();
        processInstance =
          ksession.startProcess("org.drools.actions2");
View Full Code Here


            ksession.startProcess("org.drools.actions1");
        assertEquals(1, list.size());
        assertEquals("Action1", list.get(0));
        list.clear();
        processInstance =
          ksession.startProcess("org.drools.actions2");
        assertEquals(1, list.size());
        assertEquals("Action2", list.get(0));
        assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
    }
 
View Full Code Here

        );
       
        ((AbstractRuleBase) ((InternalKnowledgeBase) kbase).getRuleBase()).addProcess(process);
       
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
        ksession.startProcess("org.drools.process.process");
        assertTrue(executed);
        assertEquals(0, ksession.getProcessInstances().size());
    }

    public void testAsynchronousSubProcess() {
View Full Code Here

        SubProcessTest.this.workItem = workItem;
      }
      public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
      }
        });
        ksession.startProcess("org.drools.process.process");
        assertNotNull(workItem);
        assertEquals(2, ksession.getProcessInstances().size());
       
        ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
        assertEquals(0, ksession.getProcessInstances().size());
View Full Code Here

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        ((AbstractRuleBase) ((InternalKnowledgeBase) kbase).getRuleBase()).addProcess(process);
       
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
        try{
            ksession.startProcess("org.drools.process.process");
            fail("should throw exception");
        } catch (RuntimeException re){
            assertTrue(re.getMessage().contains( nonExistentSubProcessName ));
        }
    }
View Full Code Here

        parameters.put( "Person",
                        new Person( "John Doe" ) );

        ProcessInstance processInstance = null;
        try {
            processInstance = ksession.startProcess( "org.drools.actions",
                                                                 parameters );
            Assert.fail( "should fail if WorkItemHandler for" + workName + "is not registered" );
        } catch ( Throwable e ) {

        }
View Full Code Here

        parameters.put( "UserName",
                        "John Doe" );
        parameters.put( "Person",
                        new Person( "John Doe" ) );

        ProcessInstance processInstance = ksession.startProcess( "org.drools.actions",
                                                                  parameters );
        long processInstanceId = processInstance.getId();
        Assert.assertEquals( ProcessInstance.STATE_ACTIVE,
                           processInstance.getState() );
        ksession.getWorkItemManager().registerWorkItemHandler( workName,
View Full Code Here

        };
        session.addEventListener( processEventListener );

        // execute the process
        session.startProcess("org.drools.process.event");
        assertEquals( 16, processEventList.size() );
        assertEquals( "org.drools.process.event", ((ProcessStartedEvent) processEventList.get(0)).getProcessInstance().getProcessId());
        assertEquals( "Start", ((ProcessNodeTriggeredEvent) processEventList.get(1)).getNodeInstance().getNodeName());
        assertEquals( "Start", ((ProcessNodeLeftEvent) processEventList.get(2)).getNodeInstance().getNodeName());
        assertEquals( "Print", ((ProcessNodeTriggeredEvent) processEventList.get(3)).getNodeInstance().getNodeName());
View Full Code Here

      ksession.getWorkItemManager().registerWorkItemHandler("Email", emailWorkItemHandler);
      TransformWorkItemHandler transformWorkItemHandler = new TransformWorkItemHandler();
      transformWorkItemHandler.registerTransformer(FileTransformer.class);
      ksession.getWorkItemManager().registerWorkItemHandler("Transform", transformWorkItemHandler);
      KnowledgeRuntimeLogger log = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
      ksession.startProcess("com.sample.ruleflow");
      log.close();
     
    } catch (Throwable t) {
      t.printStackTrace();
    }
View Full Code Here

        List<Person> persons = new ArrayList<Person>();
        persons.add(new Person("John Doe"));
        persons.add(new Person("Jane Doe"));
        persons.add(new Person("Jack"));
        parameters.put("persons", persons);
        ksession.startProcess("org.drools.process.foreach", parameters);
        assertEquals(3, myList.size());
    }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.