Search in sources :

Example 51 with SystemOutWorkItemHandler

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

the class AsyncAuditLogProducerTest method createSession.

public KieSession createSession(KieBase kbase, Environment env) {
    KieSession session = createKieSession(kbase, env);
    session.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    return session;
}
Also used : SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) KieSession(org.kie.api.runtime.KieSession) AbstractAuditLogServiceTest.createKieSession(org.jbpm.process.audit.AbstractAuditLogServiceTest.createKieSession)

Example 52 with SystemOutWorkItemHandler

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

the class AbstractAuditLogServiceTest method runTestLogger5.

public static void runTestLogger5(KieSession session, AuditLogService auditLogService) throws Exception {
    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.ruleflow").getId();
    logger.debug("Checking process instances for process 'com.sample.ruleflow'");
    processInstances = auditLogService.findProcessInstances("com.sample.ruleflow");
    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();
    Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId);
    Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow");
    Assertions.assertThat(processInstance.getStatus().intValue()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    List<NodeInstanceLog> nodeInstances = auditLogService.findNodeInstances(processInstanceId);
    Assertions.assertThat(nodeInstances.size()).isEqualTo(6);
    for (NodeInstanceLog nodeInstance : nodeInstances) {
        logger.debug(nodeInstance.toString());
        Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId);
        Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow");
        Assertions.assertThat(nodeInstance.getDate()).isNotNull();
    }
    auditLogService.clear();
    processInstances = auditLogService.findProcessInstances("com.sample.ruleflow");
    Assertions.assertThat(processInstances).isEmpty();
}
Also used : SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler)

Example 53 with SystemOutWorkItemHandler

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

the class AbstractAuditLogServiceTest method runTestLogger1.

public static void runTestLogger1(KieSession session, AuditLogService auditLogService) throws Exception {
    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.ruleflow").getId();
    logger.debug("Checking process instances for process 'com.sample.ruleflow'");
    processInstances = auditLogService.findProcessInstances("com.sample.ruleflow");
    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.ruleflow");
    List<NodeInstanceLog> nodeInstances = auditLogService.findNodeInstances(processInstanceId);
    Assertions.assertThat(nodeInstances.size()).isEqualTo(6);
    for (NodeInstanceLog nodeInstance : nodeInstances) {
        logger.debug(nodeInstance.toString());
        Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId);
        Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow");
        Assertions.assertThat(nodeInstance.getDate()).isNotNull();
    }
    auditLogService.clear();
    processInstances = auditLogService.findProcessInstances("com.sample.ruleflow");
    Assertions.assertThat(processInstances).isEmpty();
}
Also used : SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler)

Example 54 with SystemOutWorkItemHandler

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

the class WorkingMemoryDbLoggerWithSeparateLoggingEmfTest method startProcess.

@Override
public ProcessInstance startProcess(String processName) {
    if (ksession == null) {
        KieBase kbase = createKnowledgeBase();
        Environment env = createEnvironment(context);
        ksession = createKieSession(kbase, env);
        ksession.addEventListener(new JPAWorkingMemoryDbLogger(emf));
        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 55 with SystemOutWorkItemHandler

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

the class IntermediateEventTest method testIntermediateCatchEventSignalWithRef.

@Test
public void testIntermediateCatchEventSignalWithRef() throws Exception {
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-IntermediateCatchEventSignalWithRef.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
    assertProcessInstanceActive(processInstance);
    ksession = restoreSession(ksession, true);
    // now signal process instance
    ksession.signalEvent("Signal1", "SomeValue", processInstance.getId());
    assertProcessInstanceFinished(processInstance, ksession);
    assertNodeTriggered(processInstance.getId(), "StartProcess", "UserTask", "EndProcess", "event");
}
Also used : KieBase(org.kie.api.KieBase) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

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