use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.
the class EVariableHistoryTest method testVariableHistory.
@Test
public void testVariableHistory() {
Map<String, Object> parameters = new HashMap<>();
parameters.put("var1", "testVariableHistory1");
parameters.put("var2", "testVariableHistory2");
long pid = ejb.startProcess(ProcessDefinitions.SCRIPT_TASK_TWO_VARIABLES, parameters);
List<VariableDesc> vDescList = ejb.getVariableHistory(pid, "var1");
Assertions.assertThat(vDescList).isNotNull();
Assertions.assertThat(vDescList.size()).isEqualTo(1);
VariableDesc vd = vDescList.get(0);
Assertions.assertThat(vd.getProcessInstanceId()).isEqualTo(pid);
Assertions.assertThat(vd.getVariableId()).isEqualTo("var1");
Assertions.assertThat(vd.getNewValue()).isEqualTo("testVariableHistory1");
}
use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.
the class EVariableHistoryTest method testVariableHistorySimply.
@Test
public void testVariableHistorySimply() {
final String VARIABLE_NAME = "myobject";
final String VARIABLE_VALUE = "10";
Map<String, Object> parameters = new HashMap<>();
parameters.put(VARIABLE_NAME, VARIABLE_VALUE);
long pid = ejb.startProcess(ProcessDefinitions.OBJECT_VARIABLE, parameters);
List<VariableDesc> vDescList = ejb.getVariableHistory(pid, VARIABLE_NAME);
Assertions.assertThat(vDescList).isNotNull();
Assertions.assertThat(vDescList.size()).isEqualTo(1);
VariableDesc vd = vDescList.get(0);
Assertions.assertThat(vd.getProcessInstanceId()).isEqualTo(pid);
Assertions.assertThat(vd.getVariableId()).isEqualTo(VARIABLE_NAME);
Assertions.assertThat(vd.getNewValue()).isEqualTo(VARIABLE_VALUE);
}
use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.
the class RuntimeDataServiceEJBIntegrationTest 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());
}
}
}
use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.
the class CaseServiceImplTest method testStartEmptyCaseWithCaseFile.
@Test
public void testStartEmptyCaseWithCaseFile() {
Map<String, Object> data = new HashMap<>();
data.put("name", "my first case");
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), EMPTY_CASE_P_ID, data);
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), EMPTY_CASE_P_ID, caseFile);
assertNotNull(caseId);
assertEquals(FIRST_CASE_ID, caseId);
try {
CaseInstance cInstance = caseService.getCaseInstance(caseId, true, false, false, false);
assertNotNull(cInstance);
assertEquals(FIRST_CASE_ID, cInstance.getCaseId());
assertNotNull(cInstance.getCaseFile());
assertEquals("my first case", cInstance.getCaseFile().getData("name"));
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
Collection<VariableDesc> vars = runtimeDataService.getVariablesCurrentState(((CaseInstanceImpl) cInstance).getProcessInstanceId());
assertNotNull(vars);
assertEquals(3, vars.size());
Map<String, Object> mappedVars = vars.stream().collect(toMap(v -> v.getVariableId(), v -> v.getNewValue()));
assertEquals("my first case", mappedVars.get("caseFile_name"));
assertEquals(FIRST_CASE_ID, mappedVars.get("CaseId"));
assertEquals("john", mappedVars.get("initiator"));
caseService.cancelCase(caseId);
CaseInstance instance = caseService.getCaseInstance(caseId);
Assertions.assertThat(instance.getStatus()).isEqualTo(CaseStatus.CANCELLED.getId());
caseId = null;
} catch (Exception e) {
logger.error("Unexpected error {}", e.getMessage(), e);
fail("Unexpected exception " + e.getMessage());
} finally {
if (caseId != null) {
caseService.cancelCase(caseId);
}
}
}
use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.
the class EThreadInfoTest method testRESTThreadInfo.
@Test
public void testRESTThreadInfo() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("url", RestService.PING_URL);
parameters.put("method", "GET");
Long pid = startProcessInstance(THREAD_INFO_PROCESS_ID, parameters);
processService.signalProcessInstance(pid, "start", "rest");
listener.waitTillCompleted();
Assertions.assertThat(hasNodeLeft(pid, "rest")).isTrue();
Assertions.assertThat(hasNodeLeft(pid, "REST")).isTrue();
Collection<VariableDesc> result = runtimeDataService.getVariableHistory(pid, "result", new QueryContext());
Assertions.assertThat(result).hasSize(1);
Assertions.assertThat(result.iterator().next().getNewValue()).isEqualTo("pong");
Collection<VariableDesc> status = runtimeDataService.getVariableHistory(pid, "status", new QueryContext());
Assertions.assertThat(status).hasSize(1);
Assertions.assertThat(status.iterator().next().getNewValue()).isEqualTo("200");
Collection<VariableDesc> statusMsg = runtimeDataService.getVariableHistory(pid, "statusMsg", new QueryContext());
Assertions.assertThat(statusMsg).hasSize(1);
Assertions.assertThat(statusMsg.iterator().next().getNewValue()).contains("successfully completed Ok");
Collection<VariableDesc> stackTraceHistory = getStackTrace(pid);
Collection<VariableDesc> threadNameHistory = getThreadName(pid);
System.out.println("====stackTraceHistory====");
System.out.println(stackTraceHistory);
System.out.println("====stackTraceHistoryLast====");
System.out.println(stackTraceHistory.iterator().next().getNewValue());
System.out.println("====stackTraceHistorySize====");
System.out.println(stackTraceHistory.size());
System.out.println("====threadNameHistory====");
System.out.println(threadNameHistory);
System.out.println("====threadNameHistoryLast====");
System.out.println(threadNameHistory.iterator().next().getNewValue());
Assertions.assertThat(threadNameHistory.iterator().next().getNewValue()).startsWith("EE");
}
Aggregations