use of org.jbpm.process.audit.AuditLogService in project jbpm by kiegroup.
the class AsyncAuditLogProducerTest method testAsyncAuditLoggerCompleteWithVariables.
@Test
public void testAsyncAuditLoggerCompleteWithVariables() throws Exception {
Environment env = createEnvironment(context);
// load the process
KieBase kbase = createKnowledgeBase();
// create a new session
KieSession session = createSession(kbase, env);
Map<String, Object> jmsProps = new HashMap<String, Object>();
jmsProps.put("jbpm.audit.jms.transacted", false);
jmsProps.put("jbpm.audit.jms.connection.factory", factory);
jmsProps.put("jbpm.audit.jms.queue", queue);
AbstractAuditLogger logger = AuditLoggerFactory.newInstance(Type.JMS, session, jmsProps);
Assertions.assertThat(logger).isNotNull();
Assertions.assertThat((logger instanceof AsyncAuditLogProducer)).isTrue();
Map<String, Object> params = new HashMap<String, Object>();
params.put("s", "test value");
// start process instance
ProcessInstance processInstance = session.startProcess("com.sample.ruleflow3", params);
MessageReceiver receiver = new MessageReceiver();
receiver.receiveAndProcess(queue, ((EntityManagerFactory) env.get(EnvironmentName.ENTITY_MANAGER_FACTORY)), 3000, 13);
// validate if everything is stored in db
AuditLogService logService = new JPAAuditLogService(env);
List<ProcessInstanceLog> processInstances = logService.findProcessInstances("com.sample.ruleflow3");
Assertions.assertThat(processInstances.size()).isEqualTo(1);
List<NodeInstanceLog> nodeInstances = logService.findNodeInstances(processInstance.getId());
Assertions.assertThat(nodeInstances.size()).isEqualTo(6);
for (NodeInstanceLog nodeInstance : nodeInstances) {
Assertions.assertThat(nodeInstance.getProcessInstanceId().longValue()).isEqualTo(processInstance.getId());
Assertions.assertThat(nodeInstance.getProcessId()).isEqualTo("com.sample.ruleflow3");
Assertions.assertThat(nodeInstance.getDate()).isNotNull();
}
// verify variables
List<VariableInstanceLog> variables = logService.findVariableInstances(processInstance.getId());
Assertions.assertThat(variables).isNotNull();
Assertions.assertThat(variables).hasSize(2);
VariableInstanceLog var = variables.get(0);
// initial value from rule flow definition
Assertions.assertThat(var.getValue()).isEqualTo("InitialValue");
Assertions.assertThat(var.getOldValue()).isIn("", " ", null);
Assertions.assertThat(var.getProcessInstanceId().longValue()).isEqualTo(processInstance.getId());
Assertions.assertThat(var.getProcessId()).isEqualTo(processInstance.getProcessId());
Assertions.assertThat(var.getVariableId()).isEqualTo("s");
Assertions.assertThat(var.getVariableInstanceId()).isEqualTo("s");
// value given at process start
var = variables.get(1);
// initial value from rule flow definition
Assertions.assertThat(var.getValue()).isEqualTo("test value");
Assertions.assertThat(var.getOldValue()).isEqualTo("InitialValue");
Assertions.assertThat(var.getProcessInstanceId().longValue()).isEqualTo(processInstance.getId());
Assertions.assertThat(var.getProcessId()).isEqualTo(processInstance.getProcessId());
Assertions.assertThat(var.getVariableId()).isEqualTo("s");
Assertions.assertThat(var.getVariableInstanceId()).isEqualTo("s");
logService.clear();
processInstances = logService.findProcessInstances("com.sample.ruleflow3");
logService.dispose();
Assertions.assertThat(processInstances).isNullOrEmpty();
}
use of org.jbpm.process.audit.AuditLogService in project jbpm by kiegroup.
the class JbpmBpmn2TestCase method getCompletedNodes.
protected List<String> getCompletedNodes(long processInstanceId) {
List<String> names = new ArrayList<String>();
if (sessionPersistence) {
AuditLogService auditLogService = new JPAAuditLogService(emf);
List<NodeInstanceLog> logs = auditLogService.findNodeInstances(processInstanceId);
if (logs != null) {
for (NodeInstanceLog l : logs) {
names.add(l.getNodeId());
}
}
} else {
for (LogEvent event : logger.getLogEvents()) {
if (event instanceof RuleFlowNodeLogEvent) {
if (event.getType() == 27) {
names.add(((RuleFlowNodeLogEvent) event).getNodeId());
}
}
}
}
return names;
}
use of org.jbpm.process.audit.AuditLogService in project jbpm by kiegroup.
the class HumanTaskResolver method testConcurrentInvocationsIncludingUserTasks.
@Test(timeout = 10000)
public void testConcurrentInvocationsIncludingUserTasks() throws Exception {
CountDownLatch latch = new CountDownLatch(THREADS);
for (int i = 0; i < THREADS; i++) {
ProcessRunner pr = new ProcessRunner(i, getEmf(), latch);
Thread t = new Thread(pr, i + "-process-runner");
t.start();
}
latch.await();
AuditLogService logService = new JPAAuditLogService(getEmf());
List<? extends ProcessInstanceLog> logs = logService.findProcessInstances("com.sample.humantask.concurrent");
assertEquals(2, logs.size());
for (ProcessInstanceLog log : logs) {
assertEquals(ProcessInstance.STATE_COMPLETED, log.getStatus().intValue());
}
logService.dispose();
}
Aggregations