use of org.drools.persistence.jpa.marshaller.MappedVariable in project jbpm by kiegroup.
the class ProcessServiceWithEntitiesTest method testStartProcessAndGetVariables.
@Test
public void testStartProcessAndGetVariables() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
assertNotNull(processService);
Map<String, Object> params = new HashMap<String, Object>();
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "processvarentity", params);
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNotNull(pi);
Map<String, Object> variables = processService.getProcessInstanceVariables(processInstanceId);
assertNotNull(variables);
assertEquals(1, variables.size());
assertTrue(variables.containsKey("caseDetails"));
VariableEntity varEntity = (VariableEntity) variables.get("caseDetails");
// make sure getting mapped variables does NOT throw LazyInitializationException
Set<MappedVariable> mappedVariables = varEntity.getMappedVariables();
try {
assertEquals(1, mappedVariables.size());
MappedVariable mappedVariable = mappedVariables.iterator().next();
assertEquals("example.CaseDetail", mappedVariable.getVariableType());
} catch (LazyInitializationException e) {
fail("Unable to retrieve mapped variables : " + e.getMessage());
}
}
Aggregations