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();
}
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);
}
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);
}
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");
}
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);
}
Aggregations