Search in sources :

Example 1 with InstanceView

use of org.jbpm.persistence.api.integration.InstanceView in project jbpm by kiegroup.

the class PersistentStatefulSessionTest method testIntegrationWithEventManager3.

@Test
public void testIntegrationWithEventManager3() {
    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add(new ClassPathResource("WorkItemsProcess.rf"), ResourceType.DRF);
    InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    kbase.addPackages(kbuilder.getKnowledgePackages());
    StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
    ksession.getWorkItemManager().registerWorkItemHandler("MyWork", new SystemOutWorkItemHandler());
    ProcessInstance processInstance = ksession.startProcess("org.drools.test.TestProcess");
    ksession.insert("TestString");
    assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
    List<InstanceView<?>> events = TestEventEmitter.getEvents();
    assertNotNull(events);
    assertEquals(1, events.size());
}
Also used : KnowledgeBuilder(org.kie.internal.builder.KnowledgeBuilder) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) ClassPathResource(org.drools.core.io.impl.ClassPathResource) InternalKnowledgeBase(org.drools.core.impl.InternalKnowledgeBase) InstanceView(org.jbpm.persistence.api.integration.InstanceView) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Aggregations

InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)1 ClassPathResource (org.drools.core.io.impl.ClassPathResource)1 InstanceView (org.jbpm.persistence.api.integration.InstanceView)1 SystemOutWorkItemHandler (org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler)1 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)1 Test (org.junit.Test)1 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)1 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)1 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)1