Search in sources :

Example 1 with MappedVariable

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());
    }
}
Also used : VariableEntity(org.drools.persistence.jpa.marshaller.VariableEntity) HashMap(java.util.HashMap) LazyInitializationException(org.hibernate.LazyInitializationException) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) MappedVariable(org.drools.persistence.jpa.marshaller.MappedVariable) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 MappedVariable (org.drools.persistence.jpa.marshaller.MappedVariable)1 VariableEntity (org.drools.persistence.jpa.marshaller.VariableEntity)1 LazyInitializationException (org.hibernate.LazyInitializationException)1 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)1 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)1 Test (org.junit.Test)1 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)1