use of org.jbpm.process.audit.JPAAuditLogService in project jbpm by kiegroup.
the class MultiInstanceCallActivityRuntimeManagerTest method testMultiInstanceCallactivityCompleteAtTheSameTime.
public void testMultiInstanceCallactivityCompleteAtTheSameTime(Context<?> startContext) {
// start first process instance with first manager
RuntimeEngine runtime1 = manager.getRuntimeEngine(startContext);
KieSession ksession1 = runtime1.getKieSession();
assertNotNull(ksession1);
List<String> items = new ArrayList<String>();
for (int i = 0; i < numberOfChildProcesses; i++) {
items.add(i + "");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("items", items);
ProcessInstance processInstance = ksession1.startProcess("test.Parent", params);
manager.disposeRuntimeEngine(runtime1);
countDownListener.waitTillCompleted();
JPAAuditLogService auditService = new JPAAuditLogService(emf);
// process instance 1 should be completed by signal
ProcessInstanceLog pi1Log = auditService.findProcessInstance(processInstance.getId());
assertNotNull(pi1Log);
assertEquals(ProcessInstance.STATE_COMPLETED, pi1Log.getStatus().intValue());
auditService.dispose();
// close manager which will close session maintained by the manager
manager.close();
}
use of org.jbpm.process.audit.JPAAuditLogService in project jbpm by kiegroup.
the class AsyncTaskCallbackTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
auditLogService = new JPAAuditLogService(getEmf());
auditLogService.clear();
}
use of org.jbpm.process.audit.JPAAuditLogService in project jbpm by kiegroup.
the class MigrationManagerTest method testMigrateUserTaskProcessInstanceDifferentRuntimeManagers.
@Test
public void testMigrateUserTaskProcessInstanceDifferentRuntimeManagers() {
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().entityManagerFactory(emf).userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("migration/v1/BPMN2-UserTask-v1.bpmn2"), ResourceType.BPMN2).get();
managerV1 = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment, DEPLOYMENT_ID_V1);
RuntimeEnvironment environment2 = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().entityManagerFactory(emf).userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("migration/v2/BPMN2-UserTask-v2.bpmn2"), ResourceType.BPMN2).get();
managerV2 = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment2, DEPLOYMENT_ID_V2);
assertNotNull(managerV1);
assertNotNull(managerV2);
RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
ProcessInstance pi1 = ksession.startProcess(PROCESS_ID_V1);
assertNotNull(pi1);
assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState());
JPAAuditLogService auditService = new JPAAuditLogService(emf);
ProcessInstanceLog log = auditService.findProcessInstance(pi1.getId());
assertNotNull(log);
assertEquals(PROCESS_ID_V1, log.getProcessId());
assertEquals(PROCESS_NAME_V1, log.getProcessName());
assertEquals(DEPLOYMENT_ID_V1, log.getExternalId());
TaskService taskService = runtime.getTaskService();
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK");
assertNotNull(tasks);
assertEquals(1, tasks.size());
TaskSummary task = tasks.get(0);
assertNotNull(task);
assertEquals(PROCESS_ID_V1, task.getProcessId());
assertEquals(DEPLOYMENT_ID_V1, task.getDeploymentId());
assertEquals(TASK_NAME_V1, task.getName());
managerV1.disposeRuntimeEngine(runtime);
MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, PROCESS_ID_V2);
MigrationManager migrationManager = new MigrationManager(migrationSpec);
try {
migrationManager.migrate();
} catch (MigrationException e) {
assertEquals("Source (org.jbpm.runtime.manager.impl.SingletonRuntimeManager) and target (org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager) deployments are of different type (they represent different runtime strategies)", e.getMessage());
}
runtime = managerV1.getRuntimeEngine(EmptyContext.get());
ksession = runtime.getKieSession();
assertNotNull(ksession);
auditService = new JPAAuditLogService(emf);
log = auditService.findProcessInstance(pi1.getId());
assertNotNull(log);
assertEquals(PROCESS_ID_V1, log.getProcessId());
assertEquals(PROCESS_NAME_V1, log.getProcessName());
assertEquals(DEPLOYMENT_ID_V1, log.getExternalId());
taskService = runtime.getTaskService();
tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK");
assertNotNull(tasks);
assertEquals(1, tasks.size());
task = tasks.get(0);
assertNotNull(task);
assertEquals(PROCESS_ID_V1, task.getProcessId());
assertEquals(DEPLOYMENT_ID_V1, task.getDeploymentId());
assertEquals(TASK_NAME_V1, task.getName());
managerV1.disposeRuntimeEngine(runtime);
}
use of org.jbpm.process.audit.JPAAuditLogService in project jbpm by kiegroup.
the class MigrationManagerTest method testMigrateUserTaskProcessInstanceWithRollback.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testMigrateUserTaskProcessInstanceWithRollback() {
createRuntimeManagers("migration/v1/BPMN2-UserTask-v1.bpmn2", "migration/v2/BPMN2-UserTask-v2.bpmn2");
assertNotNull(managerV1);
assertNotNull(managerV2);
RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
ProcessInstance pi1 = ksession.startProcess(PROCESS_ID_V1);
assertNotNull(pi1);
assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState());
managerV1.disposeRuntimeEngine(runtime);
MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, PROCESS_ID_V2);
MigrationManager migrationManager = new MigrationManager(migrationSpec);
MigrationReport report = null;
try {
// explicitly without generic to cause error (class cast) in migration process to test rollback
Map erronousMapping = Collections.singletonMap("_2", 2);
migrationManager.migrate(erronousMapping);
} catch (MigrationException e) {
report = e.getReport();
}
assertNotNull(report);
assertFalse(report.isSuccessful());
JPAAuditLogService auditService = new JPAAuditLogService(emf);
ProcessInstanceLog log = auditService.findProcessInstance(pi1.getId());
assertNotNull(log);
assertEquals(PROCESS_ID_V1, log.getProcessId());
assertEquals(DEPLOYMENT_ID_V1, log.getExternalId());
auditService.dispose();
}
use of org.jbpm.process.audit.JPAAuditLogService in project jbpm by kiegroup.
the class MigrationManagerTest method setup.
@Before
public void setup() {
TestUtil.cleanupSingletonSessionId();
pds = TestUtil.setupPoolingDataSource();
emf = EntityManagerFactoryManager.get().getOrCreate("org.jbpm.persistence.jpa");
Properties properties = new Properties();
properties.setProperty("mary", "HR");
properties.setProperty("john", "HR");
userGroupCallback = new JBossUserGroupCallbackImpl(properties);
auditService = new JPAAuditLogService(emf);
}
Aggregations