use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.
the class EThreadInfoTest method testHumanTaskThreadInfo.
@Test
public void testHumanTaskThreadInfo() throws Exception {
Long pid = startProcessInstance(THREAD_INFO_PROCESS_ID);
processService.signalProcessInstance(pid, "start", "usertask");
listener.waitTillCompleted();
List<TaskSummary> taskSummaries = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
Assertions.assertThat(taskSummaries).isNotNull().hasSize(1);
userTaskService.start(taskSummaries.get(0).getId(), "john");
userTaskService.complete(taskSummaries.get(0).getId(), "john", new HashMap<String, Object>());
Assertions.assertThat(hasNodeLeft(pid, "usertask")).isTrue();
Assertions.assertThat(hasNodeLeft(pid, "User Task")).isTrue();
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());
// in this scenario we have to check the middle value, so it is the old one in the last history entry
Assertions.assertThat(threadNameHistory.iterator().next().getOldValue()).startsWith("EE");
}
use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.
the class ERestServiceTaskTest method testRestWorkItem.
@Test
public void testRestWorkItem() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("url", RestService.PING_URL);
parameters.put("method", "GET");
Long pid = processService.startProcess(kieJar, REST_WORK_ITEM_PROCESS_ID, parameters);
Assertions.assertThat(pid).isNotNull();
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");
}
use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.
the class EObjectVariableTest method testMyTypeProcessVariableInside.
@Test
public void testMyTypeProcessVariableInside() {
Map<String, Object> parameters = new HashMap<>();
parameters.put("myobject", new MyType("Hello World!"));
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(MyType.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()).isEqualTo("MyType{text=Hello World!}");
}
use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.
the class EObjectVariableTest method testLongProcessVariable.
@Test
public void testLongProcessVariable() {
Map<String, Object> parameters = new HashMap<>();
parameters.put("myobject", 10L);
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(Long.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()).isEqualTo("10");
}
use of org.jbpm.services.api.model.VariableDesc in project jbpm by kiegroup.
the class ETaskParametersTest method startProcessAndCompleteTask.
private void startProcessAndCompleteTask(String processId, String paramName, Object paramValue, String varName) {
Map<String, Object> processParams = new HashMap<>();
processParams.put("userId", userId);
ProcessInstance pi = ejb.startAndGetProcess(processId, processParams);
Assertions.assertThat(pi).isNotNull();
Assertions.assertThat(pi.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
List<Long> ts = ejb.getTasksByProcessInstanceId(pi.getId());
Assertions.assertThat(ts).hasSize(1);
long taskId = ts.get(0);
ejb.start(taskId, userId);
Map<String, Object> taskParams = new HashMap<>();
taskParams.put(paramName, paramValue);
ejb.complete(taskId, userId, taskParams);
Task task = ejb.getTask(taskId);
Assertions.assertThat(task).isNotNull();
Assertions.assertThat(task.getTaskData().getStatus()).isEqualTo(Status.Completed);
VariableDesc log = ejb.getVariableHistory(pi.getId(), varName).get(0);
Assertions.assertThat(log).isNotNull();
Assertions.assertThat(log.getNewValue()).isEqualTo(paramValue.toString());
}
Aggregations