Search in sources :

Example 6 with VariableDesc

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

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

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

Example 9 with VariableDesc

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);
        }
    }
}
Also used : TaskSummary(org.kie.api.task.model.TaskSummary) Arrays(java.util.Arrays) CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) Date(java.util.Date) CommentSortBy(org.jbpm.casemgmt.api.model.instance.CommentSortBy) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) LoggerFactory(org.slf4j.LoggerFactory) CaseAssignment(org.kie.api.runtime.process.CaseAssignment) CommentInstance(org.jbpm.casemgmt.api.model.instance.CommentInstance) DocumentImpl(org.jbpm.document.service.impl.DocumentImpl) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) KieInternalServices(org.kie.internal.KieInternalServices) Assertions(org.assertj.core.api.Assertions) AuthorizationManager(org.jbpm.casemgmt.api.auth.AuthorizationManager) CaseMilestoneInstance(org.jbpm.casemgmt.api.model.instance.CaseMilestoneInstance) CaseCommentNotFoundException(org.jbpm.casemgmt.api.CaseCommentNotFoundException) Collection(java.util.Collection) UUID(java.util.UUID) QueryContext(org.kie.api.runtime.query.QueryContext) CaseFileItem(org.jbpm.casemgmt.api.model.CaseFileItem) List(java.util.List) Assertions.fail(org.assertj.core.api.Assertions.fail) Assert.assertFalse(org.junit.Assert.assertFalse) AdHocFragment(org.jbpm.casemgmt.api.model.AdHocFragment) Person(org.jbpm.bpmn2.objects.Person) AdHocFragmentNotFoundException(org.jbpm.casemgmt.api.AdHocFragmentNotFoundException) Status(org.kie.api.task.model.Status) UserImpl(org.jbpm.services.task.impl.model.UserImpl) CaseNotFoundException(org.jbpm.casemgmt.api.CaseNotFoundException) HashMap(java.util.HashMap) QueryFilter(org.kie.internal.query.QueryFilter) ArrayList(java.util.ArrayList) CaseStageInstance(org.jbpm.casemgmt.api.model.instance.CaseStageInstance) CaseInstance(org.jbpm.casemgmt.api.model.instance.CaseInstance) StageStatus(org.jbpm.casemgmt.api.model.instance.StageStatus) CaseInstanceImpl(org.jbpm.casemgmt.impl.model.instance.CaseInstanceImpl) CaseStage(org.jbpm.casemgmt.api.model.CaseStage) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) VariableDesc(org.jbpm.services.api.model.VariableDesc) CorrelationKey(org.kie.internal.process.CorrelationKey) Assert.assertNotNull(org.junit.Assert.assertNotNull) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) GroupImpl(org.jbpm.services.task.impl.model.GroupImpl) MilestoneStatus(org.jbpm.casemgmt.api.model.instance.MilestoneStatus) NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc) Assert.assertNull(org.junit.Assert.assertNull) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) CaseStatus(org.jbpm.casemgmt.api.model.CaseStatus) Document(org.jbpm.document.Document) EchoService(org.jbpm.casemgmt.impl.objects.EchoService) Collections(java.util.Collections) CaseActiveException(org.jbpm.casemgmt.api.CaseActiveException) Assert.assertEquals(org.junit.Assert.assertEquals) CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) CaseInstance(org.jbpm.casemgmt.api.model.instance.CaseInstance) HashMap(java.util.HashMap) VariableDesc(org.jbpm.services.api.model.VariableDesc) CaseCommentNotFoundException(org.jbpm.casemgmt.api.CaseCommentNotFoundException) AdHocFragmentNotFoundException(org.jbpm.casemgmt.api.AdHocFragmentNotFoundException) CaseNotFoundException(org.jbpm.casemgmt.api.CaseNotFoundException) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) CaseActiveException(org.jbpm.casemgmt.api.CaseActiveException) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 10 with VariableDesc

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