use of org.kie.api.runtime.manager.audit.AuditService in project jbpm by kiegroup.
the class SingletonRuntimeManagerTest method testBusinessRuleTaskWithRuleAwareListener.
@Test
public void testBusinessRuleTaskWithRuleAwareListener() {
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().addAsset(ResourceFactory.newClassPathResource("BPMN2-BusinessRuleTask.bpmn2"), ResourceType.BPMN2).addAsset(ResourceFactory.newClassPathResource("BPMN2-BusinessRuleTask.drl"), ResourceType.DRL).get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
long sessionId = ksession.getIdentifier();
assertTrue(sessionId == 1);
runtime = manager.getRuntimeEngine(EmptyContext.get());
ksession = runtime.getKieSession();
assertEquals(sessionId, ksession.getIdentifier());
// start process
ksession.addEventListener(new RuleAwareProcessEventLister());
ProcessInstance pi = ksession.startProcess("BPMN2-BusinessRuleTask");
assertNull(ksession.getProcessInstance(pi.getId()));
AuditService logService = runtime.getAuditService();
List<? extends ProcessInstanceLog> logs = logService.findActiveProcessInstances("BPMN2-BusinessRuleTask");
assertNotNull(logs);
assertEquals(0, logs.size());
logs = logService.findProcessInstances("BPMN2-BusinessRuleTask");
assertNotNull(logs);
assertEquals(1, logs.size());
// dispose session that should not have affect on the session at all
manager.disposeRuntimeEngine(runtime);
// close manager which will close session maintained by the manager
manager.close();
}
use of org.kie.api.runtime.manager.audit.AuditService in project jbpm by kiegroup.
the class TimerInitFailureRuntimeManagerTest method testPerCaseRuntimeManager.
@Test(timeout = 10000)
@BMScript(value = "byteman-scripts/failOnRuntimeManagerInitRules.btm")
public void testPerCaseRuntimeManager() throws Exception {
final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Intermediate Catch Event 1", 1);
RuntimeEnvironment environment = createEnvironment(countDownListener);
manager = RuntimeManagerFactory.Factory.get().newPerCaseRuntimeManager(environment, "first");
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(CaseContext.get("CASE-001"));
KieSession ksession = runtime.getKieSession();
// start a new process instance
Map<String, Object> params = new HashMap<>();
ProcessInstance pi = ksession.startProcess("TimerInitFailure", params);
assertEquals(ProcessInstance.STATE_ACTIVE, pi.getState());
manager.disposeRuntimeEngine(runtime);
countDownListener.waitTillCompleted();
// User access
runtime = manager.getRuntimeEngine(CaseContext.get("CASE-001"));
runtime.getKieSession();
TaskService taskService = runtime.getTaskService();
List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
assertEquals(1, list.size());
long taskId = list.get(0).getId();
taskService.start(taskId, "john");
taskService.complete(taskId, "john", null);
manager.disposeRuntimeEngine(runtime);
runtime = manager.getRuntimeEngine(CaseContext.get("CASE-001"));
AuditService auditService = runtime.getAuditService();
ProcessInstanceLog log = auditService.findProcessInstance(pi.getId());
assertEquals(ProcessInstance.STATE_COMPLETED, log.getStatus().intValue());
auditService.dispose();
manager.disposeRuntimeEngine(runtime);
}
use of org.kie.api.runtime.manager.audit.AuditService in project jbpm by kiegroup.
the class AdminAPIsWithListenerTest method automaticCleanUpForSubProcessWithPerProcessInstanceStrategy.
@Test
public void automaticCleanUpForSubProcessWithPerProcessInstanceStrategy() throws Exception {
TaskCleanUpProcessEventListener taskCleanUpProcessEventListener = new TaskCleanUpProcessEventListener(null);
this.addProcessEventListener(taskCleanUpProcessEventListener);
RuntimeManager manager = createRuntimeManager(Strategy.PROCESS_INSTANCE, "com.mycompany.sample", "org/jbpm/test/functional/task/ht-main.bpmn", "org/jbpm/test/functional/task/ht-sub.bpmn");
RuntimeEngine runtime = getRuntimeEngine(ProcessInstanceIdContext.get());
taskCleanUpProcessEventListener.setTaskService((InternalTaskService) runtime.getTaskService());
KieSession ksession = runtime.getKieSession();
// start a new process instance
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance pi = ksession.startProcess("com.mycompany.sample", params);
// obtain the task service
TaskService taskService = runtime.getTaskService();
List<TaskSummary> tasks1 = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
assertFalse(tasks1.isEmpty());
TaskSummary task1 = tasks1.get(0);
System.out.println("Sales-rep executing task " + task1.getName() + "(" + task1.getId() + ": " + task1.getDescription() + ")");
taskService.start(task1.getId(), "john");
Map<String, Object> results = new HashMap<String, Object>();
results.put("comment", "Agreed, existing laptop needs replacing");
results.put("outcome", "Accept");
// complete the human task of the main process
taskService.complete(task1.getId(), "john", results);
// abort the process instance
ksession.abortProcessInstance(pi.getId());
// main process instance shall be aborted
assertProcessInstanceAborted(pi.getId());
AuditService logService = runtime.getAuditService();
List<? extends ProcessInstanceLog> logs = logService.findProcessInstances("com.mycompany.sample");
assertNotNull(logs);
assertEquals(1, logs.size());
assertEquals(ProcessInstance.STATE_ABORTED, logs.get(0).getStatus().intValue());
logs = logService.findProcessInstances("com.mycompany.sample.subprocess");
assertNotNull(logs);
assertEquals(1, logs.size());
assertEquals(ProcessInstance.STATE_ABORTED, logs.get(0).getStatus().intValue());
manager.close();
final EntityManager em = emfTasks.createEntityManager();
assertEquals(0, em.createQuery("select t from TaskImpl t").getResultList().size());
assertEquals(0, em.createQuery("select i from I18NTextImpl i").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_BAs").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_ExclOwners").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_PotOwners").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_Recipients").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_Stakeholders").getResultList().size());
assertEquals(0, em.createQuery("select c from ContentImpl c").getResultList().size());
em.close();
}
use of org.kie.api.runtime.manager.audit.AuditService in project jbpm by kiegroup.
the class BPMN2DataServicesReferencesTest method testCallActivity.
@Test
public void testCallActivity() throws IOException {
Assume.assumeTrue("Skip call activity tests", loadCallActivityProcesses);
String processId = PROC_ID_CALL_ACTIVITY;
ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentId, processId);
assertNotNull(procDef);
// run process (to verify that it works)
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "oldValue");
Long procId = startProcess(deploymentId, processId, params);
ProcessInstance procInst = processService.getProcessInstance(procId);
assertNull(procInst);
AuditService auditService = deploymentService.getRuntimeManager(deploymentId).getRuntimeEngine(null).getAuditService();
List<? extends VariableInstanceLog> logs = auditService.findVariableInstances(procId);
boolean foundY = false;
for (VariableInstanceLog log : logs) {
if (log.getVariableId().equals("y") && log.getValue().equals("new value")) {
foundY = true;
}
}
assertTrue("Parent process did not call sub process", foundY);
// check information about process
Collection<String> refProcesses = bpmn2Service.getReusableSubProcesses(deploymentId, processId);
assertNotNull("Null set of referenced processes", refProcesses);
assertFalse("Empty set of referenced processes", refProcesses.isEmpty());
assertEquals("Number referenced processes", 1, refProcesses.size());
assertEquals("Imported class in processes", PROC_ID_ACTIVITY_CALLED, refProcesses.iterator().next());
}
use of org.kie.api.runtime.manager.audit.AuditService in project jbpm by kiegroup.
the class BPMN2DataServicesReferencesTest method testCallActivityByName.
@Test
public void testCallActivityByName() throws IOException {
Assume.assumeTrue("Skip call activity tests", loadCallActivityProcesses);
String processId = PROC_ID_CALL_ACTIVITY_BY_NAME;
ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentId, processId);
assertNotNull(procDef);
// run process (to verify that it works)
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "oldValue");
Long procId = startProcess(deploymentId, processId, params);
ProcessInstance procInst = processService.getProcessInstance(procId);
assertNull(procInst);
AuditService auditService = deploymentService.getRuntimeManager(deploymentId).getRuntimeEngine(null).getAuditService();
List<? extends VariableInstanceLog> logs = auditService.findVariableInstances(procId);
boolean foundY = false;
for (VariableInstanceLog log : logs) {
if (log.getVariableId().equals("y") && log.getValue().equals("new value")) {
foundY = true;
}
}
assertTrue("Parent process did not call sub process", foundY);
// check information about process
Collection<String> refProcesses = bpmn2Service.getReusableSubProcesses(deploymentId, processId);
assertNotNull("Null set of referenced processes", refProcesses);
assertFalse("Empty set of referenced processes", refProcesses.isEmpty());
assertEquals("Number referenced processes", 1, refProcesses.size());
assertEquals("Imported class in processes", PROC_ID_ACTIVITY_CALLED, refProcesses.iterator().next());
}
Aggregations