Search in sources :

Example 1 with VariableDesc

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");
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) VariableDesc(org.jbpm.services.api.model.VariableDesc) TaskSummary(org.kie.api.task.model.TaskSummary) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest) Test(org.junit.Test)

Example 2 with VariableDesc

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");
}
Also used : HashMap(java.util.HashMap) VariableDesc(org.jbpm.services.api.model.VariableDesc) QueryContext(org.kie.internal.query.QueryContext) Test(org.junit.Test) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest)

Example 3 with VariableDesc

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!}");
}
Also used : MyType(org.jboss.qa.bpms.remote.ejb.domain.MyType) HashMap(java.util.HashMap) VariableDesc(org.jbpm.services.api.model.VariableDesc) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 4 with VariableDesc

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");
}
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 5 with VariableDesc

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());
}
Also used : Task(org.kie.api.task.model.Task) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) VariableDesc(org.jbpm.services.api.model.VariableDesc) ProcessInstance(org.kie.api.runtime.process.ProcessInstance)

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