use of org.jbpm.persistence.processinstance.objects.NonSerializableClass in project jbpm by kiegroup.
the class ProcessInstanceResolverStrategyTest method testWithDatabaseAndStartProcess.
@Test
public void testWithDatabaseAndStartProcess() throws Exception {
// Create variable
Map<String, Object> params = new HashMap<String, Object>();
NonSerializableClass processVar = new NonSerializableClass();
processVar.setString("1234567890");
params.put(VAR_NAME, processVar);
// Persist variable
UserTransaction ut = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
ut.begin();
EntityManagerFactory emf = (EntityManagerFactory) context.get(ENTITY_MANAGER_FACTORY);
EntityManager em = emf.createEntityManager();
em.setFlushMode(FlushModeType.COMMIT);
em.joinTransaction();
em.persist(processVar);
em.close();
ut.commit();
// Generate, insert, and start process
ProcessInstance processInstance = ksession.startProcess(PROCESS_ID, params);
// Test resuls
Assert.assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
processVar = (NonSerializableClass) ((WorkflowProcessInstance) processInstance).getVariable(VAR_NAME);
Assert.assertNotNull(processVar);
}
use of org.jbpm.persistence.processinstance.objects.NonSerializableClass in project jbpm by kiegroup.
the class ProcessInstanceResolverStrategyTest method testWithDatabaseAndStartProcessInstance.
@Test
public void testWithDatabaseAndStartProcessInstance() throws Exception {
// Create variable
Map<String, Object> params = new HashMap<String, Object>();
NonSerializableClass processVar = new NonSerializableClass();
processVar.setString("1234567890");
params.put(VAR_NAME, processVar);
// Persist variable
UserTransaction ut = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
ut.begin();
EntityManagerFactory emf = (EntityManagerFactory) context.get(ENTITY_MANAGER_FACTORY);
EntityManager em = emf.createEntityManager();
em.setFlushMode(FlushModeType.COMMIT);
em.joinTransaction();
em.persist(processVar);
em.close();
ut.commit();
// Create process,
ProcessInstance processInstance = ksession.createProcessInstance(PROCESS_ID, params);
long processInstanceId = processInstance.getId();
Assert.assertTrue(processInstanceId > 0);
Assert.assertEquals(ProcessInstance.STATE_PENDING, processInstance.getState());
// insert process,
ksession.insert(processInstance);
// and start process
ksession.startProcessInstance(processInstanceId);
ksession.fireAllRules();
// Test results
processInstance = ksession.getProcessInstance(processInstanceId);
Assert.assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
processVar = (NonSerializableClass) ((WorkflowProcessInstance) processInstance).getVariable(VAR_NAME);
Assert.assertNotNull(processVar);
}
Aggregations