Search in sources :

Example 11 with VariableDesc

use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.

the class EObjectVariableTest method testFloatArrayProcessVariable.

@Test
public void testFloatArrayProcessVariable() {
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("myobject", new Float[] { 10.3f, 5.6f });
    long pid = ejb.startProcess(ProcessDefinitions.OBJECT_VARIABLE, parameters);
    List<VariableDesc> typeVarHistory = ejb.getVariableHistory(pid, "type");
    Assertions.assertThat(typeVarHistory).isNotNull();
    Assertions.assertThat(typeVarHistory.size()).isEqualTo(1);
    VariableDesc typeVarLog = typeVarHistory.get(0);
    Assertions.assertThat(typeVarLog.getNewValue()).isEqualTo(Float[].class.getName());
    List<VariableDesc> contentVarHistory = ejb.getVariableHistory(pid, "myobject");
    Assertions.assertThat(contentVarHistory).isNotNull();
    Assertions.assertThat(contentVarHistory.size()).isEqualTo(1);
    VariableDesc contentVarLog = contentVarHistory.get(0);
    Assertions.assertThat(contentVarLog.getNewValue()).startsWith("[Ljava.lang.Float;@");
}
Also used : HashMap(java.util.HashMap) VariableDesc(org.jbpm.services.api.model.VariableDesc) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 12 with VariableDesc

use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.

the class ProcessServiceWithServiceRegistryTest method testRunScriptProcessWithServiceRegistryInScriptTask.

@Test
public void testRunScriptProcessWithServiceRegistryInScriptTask() {
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), PROCESS_ID_SCRIPT_TASK);
    assertNotNull(processInstanceId);
    try {
        ProcessInstance pi = processService.getProcessInstance(processInstanceId);
        if (pi != null) {
            fail("Process should be already completed");
        }
    } catch (ProcessInstanceNotFoundException e) {
    // expected
    }
    Collection<VariableDesc> variables = runtimeDataService.getVariableHistory(processInstanceId, "correlationKey", new QueryContext());
    assertNotNull(variables);
    assertEquals(1, variables.size());
    VariableDesc ckVar = variables.iterator().next();
    assertNotNull(ckVar);
    assertEquals("1", ckVar.getNewValue());
}
Also used : VariableDesc(org.jbpm.services.api.model.VariableDesc) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) QueryContext(org.kie.api.runtime.query.QueryContext) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 13 with VariableDesc

use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.

the class RuntimeDataServiceImplTest method testGetVariableLogs.

@Test
public void testGetVariableLogs() {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("approval_document", "initial content");
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
    assertNotNull(processInstanceId);
    Collection<VariableDesc> variableLogs = runtimeDataService.getVariableHistory(processInstanceId, "approval_document", new QueryContext());
    assertNotNull(variableLogs);
    assertEquals(1, variableLogs.size());
    processService.setProcessVariable(processInstanceId, "approval_document", "updated content");
    variableLogs = runtimeDataService.getVariableHistory(processInstanceId, "approval_document", new QueryContext());
    assertNotNull(variableLogs);
    assertEquals(2, variableLogs.size());
    processService.setProcessVariable(processInstanceId, "approval_reviewComment", "under review - content");
    variableLogs = runtimeDataService.getVariablesCurrentState(processInstanceId);
    assertNotNull(variableLogs);
    assertEquals(2, variableLogs.size());
    for (VariableDesc vDesc : variableLogs) {
        if (vDesc.getVariableId().equals("approval_document")) {
            assertEquals("updated content", vDesc.getNewValue());
        } else if (vDesc.getVariableId().equals("approval_reviewComment")) {
            assertEquals("under review - content", vDesc.getNewValue());
        }
    }
}
Also used : HashMap(java.util.HashMap) VariableDesc(org.jbpm.services.api.model.VariableDesc) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Aggregations

VariableDesc (org.jbpm.services.api.model.VariableDesc)13 Test (org.junit.Test)12 HashMap (java.util.HashMap)11 RemoteEjbTest (org.jbpm.remote.ejb.test.RemoteEjbTest)4 QueryContext (org.kie.api.runtime.query.QueryContext)4 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)2 AbstractRuntimeEJBServicesTest (org.jbpm.test.container.AbstractRuntimeEJBServicesTest)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Date (java.util.Date)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 UUID (java.util.UUID)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Assertions (org.assertj.core.api.Assertions)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1