Search in sources :

Example 46 with SystemOutWorkItemHandler

use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.

the class AbstractAuditLogServiceTest method runTestLogger3.

public static void runTestLogger3(KieSession session, AuditLogService auditLogService) {
    session.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    // record the initial count to compare to later
    List<ProcessInstanceLog> processInstances = auditLogService.findProcessInstances("com.sample.ruleflow");
    int initialProcessInstanceSize = processInstances.size();
    // start process instance
    long processInstanceId = session.startProcess("com.sample.ruleflow2").getId();
    logger.debug("Checking process instances for process 'com.sample.ruleflow2'");
    processInstances = auditLogService.findProcessInstances("com.sample.ruleflow2");
    Assertions.assertThat(processInstances.size()).isEqualTo(initialProcessInstanceSize + 1);
    ProcessInstanceLog processInstance = processInstances.get(initialProcessInstanceSize);
    logger.debug("{} -> {} - {}", processInstance.toString(), processInstance.getStart(), processInstance.getEnd());
    Assertions.assertThat(processInstance.getStart()).isNotNull();
    Assertions.assertThat(processInstance.getEnd()).isNotNull().withFailMessage("ProcessInstanceLog does not contain end date.");
    Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId);
    Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow2");
    List<NodeInstanceLog> nodeInstances = auditLogService.findNodeInstances(processInstanceId);
    for (NodeInstanceLog nodeInstance : nodeInstances) {
        logger.debug("{} -> {}", nodeInstance.toString(), nodeInstance.getDate());
        Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId);
        Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow2");
        Assertions.assertThat(nodeInstance.getDate()).isNotNull();
    }
    Assertions.assertThat(nodeInstances.size()).isEqualTo(14);
    auditLogService.clear();
}
Also used : SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler)

Example 47 with SystemOutWorkItemHandler

use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.

the class StandaloneAuditLogServiceTest method setUp.

@Before
public void setUp() throws Exception {
    // persistence
    context = setupWithPoolingDataSource(JBPM_PERSISTENCE_UNIT_NAME);
    // create a new session
    Environment env = createEnvironment(context);
    KieBase kbase = createKnowledgeBase();
    ksession = createKieSession(kbase, env);
    new JPAWorkingMemoryDbLogger(ksession);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    // log service
    auditLogService = new JPAAuditLogService(env);
}
Also used : KieBase(org.kie.api.KieBase) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) PersistenceUtil.createEnvironment(org.jbpm.persistence.util.PersistenceUtil.createEnvironment) Environment(org.kie.api.runtime.Environment) Before(org.junit.Before)

Example 48 with SystemOutWorkItemHandler

use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.

the class WorkingMemoryDbLoggerWithPersistentSessionTest method startProcess.

@Override
public ProcessInstance startProcess(String processName) {
    if (ksession == null) {
        KieBase kbase = createKnowledgeBase();
        Environment env = createEnvironment(context);
        ksession = createKieSession(kbase, env);
        new JPAWorkingMemoryDbLogger(ksession);
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    }
    return ksession.startProcess(processName);
}
Also used : KieBase(org.kie.api.KieBase) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) PersistenceUtil.createEnvironment(org.jbpm.persistence.util.PersistenceUtil.createEnvironment) Environment(org.kie.api.runtime.Environment)

Example 49 with SystemOutWorkItemHandler

use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.

the class EmbeddedSubprocessTest method testTaskCompensation.

@Test
@BZ("1191768")
public void testTaskCompensation() throws Exception {
    KieSession kieSession = createKSession(TASK_COMPENSATION);
    kieSession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("compensation", "True");
    ProcessInstance processInstance = kieSession.startProcess(TASK_COMPENSATION_ID, params);
    long pid = processInstance.getId();
    assertProcessInstanceCompleted(pid);
    List<? extends VariableInstanceLog> log = getLogService().findVariableInstances(processInstance.getId(), "compensation");
    Assertions.assertThat(log.get(log.size() - 1).getValue()).isEqualTo("compensation");
}
Also used : HashMap(java.util.HashMap) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 50 with SystemOutWorkItemHandler

use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.

the class WorkingMemoryDbLoggerWithSeparateLoggingLocalEmfTest method startProcess.

@Override
public ProcessInstance startProcess(String processName) {
    if (ksession == null) {
        KieBase kbase = createKnowledgeBase();
        Properties properties = new Properties();
        properties.put("drools.processInstanceManagerFactory", "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");
        properties.put("drools.processSignalManagerFactory", "org.jbpm.persistence.processinstance.JPASignalManagerFactory");
        KieSessionConfiguration conf = SessionConfiguration.newInstance(properties);
        Environment env = createEnvironment(context);
        env.set("IS_JTA_TRANSACTION", false);
        ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, conf, env);
        ksession.addEventListener(new JPAWorkingMemoryDbLogger(emf, env));
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    }
    return ksession.startProcess(processName);
}
Also used : KieBase(org.kie.api.KieBase) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) PersistenceUtil.createEnvironment(org.jbpm.persistence.util.PersistenceUtil.createEnvironment) Environment(org.kie.api.runtime.Environment) Properties(java.util.Properties) KieSessionConfiguration(org.kie.api.runtime.KieSessionConfiguration)

Aggregations

SystemOutWorkItemHandler (org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler)87 Test (org.junit.Test)77 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)75 KieBase (org.kie.api.KieBase)59 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)45 HashMap (java.util.HashMap)39 KieSession (org.kie.api.runtime.KieSession)38 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)16 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)15 DefaultRegisterableItemsFactory (org.jbpm.runtime.manager.impl.DefaultRegisterableItemsFactory)14 AbstractExecutorBaseTest (org.jbpm.test.util.AbstractExecutorBaseTest)14 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)14 WorkItemHandler (org.kie.api.runtime.process.WorkItemHandler)14 NodeTriggeredCountDownProcessEventListener (org.jbpm.test.listener.NodeTriggeredCountDownProcessEventListener)13 ProcessEventListener (org.kie.api.event.process.ProcessEventListener)13 ArrayList (java.util.ArrayList)10 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)6 Document (org.w3c.dom.Document)5 Map (java.util.Map)4 PersistenceUtil.createEnvironment (org.jbpm.persistence.util.PersistenceUtil.createEnvironment)4