Search in sources :

Example 1 with CaseUserTaskWithVariables

use of org.kie.server.api.model.cases.CaseUserTaskWithVariables in project droolsjbpm-integration by kiegroup.

the class CaseServiceIntegrationTest method testQueryByVariable.

@Test
public void testQueryByVariable() {
    Assume.assumeTrue(configuration.isRest());
    String caseId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN, USER_YODA);
    Assertions.assertThat(caseId).isNotNull();
    Assertions.assertThat(caseId).startsWith(CLAIM_CASE_ID_PREFIX);
    CaseInstance caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    assertCarInsuranceCaseInstance(caseInstance, caseId, USER_YODA);
    caseClient.closeCaseInstance(CONTAINER_ID, caseId, "work done at the moment");
    CaseInstance closed = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    Assertions.assertThat(closed.getCaseStatus()).isEqualTo(2);
    Assertions.assertThat(closed.getCompletionMessage()).isEqualTo("work done at the moment");
    Map<String, Object> data = new HashMap<>();
    data.put("additionalComment", "reopening the case");
    caseClient.reopenCase(caseId, CONTAINER_ID, CLAIM_CASE_DEF_ID, data);
    caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
    Assertions.assertThat(caseInstance).isNotNull();
    Assertions.assertThat(caseInstance.getCaseId()).isEqualTo(caseId);
    Object additionalComment = caseClient.getCaseInstanceData(CONTAINER_ID, caseId, "additionalComment");
    Assertions.assertThat(additionalComment).isNotNull();
    Assertions.assertThat(additionalComment).isEqualTo("reopening the case");
    List<QueryParam> attrs = list(equalsTo(CASE_ATTR_CORRELATION_KEY, caseId));
    SearchQueryFilterSpec filter = new SearchQueryFilterSpec();
    filter.setAttributesQueryParams(attrs);
    List<CaseInstanceCustomVars> caseInstanceCustomVarsList = caseClient.queryCasesByVariables(filter, 0, 2);
    assertNotNull(caseInstanceCustomVarsList);
    Assertions.assertThat(caseInstanceCustomVarsList).hasSize(2);
    attrs = list(likeTo(CASE_ATTR_CORRELATION_KEY, false, CLAIM_CASE_ID_PREFIX + "%"));
    filter = new SearchQueryFilterSpec();
    filter.setAttributesQueryParams(attrs);
    caseInstanceCustomVarsList = caseClient.queryCasesByVariables(filter, 0, 2);
    assertNotNull(caseInstanceCustomVarsList);
    caseInstanceCustomVarsList.stream().forEach(e -> assertTrue(e.getCaseId().startsWith(CLAIM_CASE_ID_PREFIX)));
    List<CaseUserTaskWithVariables> caseUserTaskWithVariablesList = caseClient.queryUserTaskByVariables(new SearchQueryFilterSpec(), 0, 2);
    assertNotNull(caseUserTaskWithVariablesList);
    Assertions.assertThat(caseUserTaskWithVariablesList.size()).isGreaterThan(0);
}
Also used : CaseInstance(org.kie.server.api.model.cases.CaseInstance) HashMap(java.util.HashMap) QueryParam(org.kie.server.api.model.definition.QueryParam) SearchQueryFilterSpec(org.kie.server.api.model.definition.SearchQueryFilterSpec) CaseInstanceCustomVars(org.kie.server.api.model.cases.CaseInstanceCustomVars) CaseUserTaskWithVariables(org.kie.server.api.model.cases.CaseUserTaskWithVariables) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 2 with CaseUserTaskWithVariables

use of org.kie.server.api.model.cases.CaseUserTaskWithVariables in project droolsjbpm-integration by kiegroup.

the class ConvertUtils method convertToCaseUserTaskWithVariablesList.

public static CaseUserTaskWithVariablesList convertToCaseUserTaskWithVariablesList(List<UserTaskInstanceWithPotOwnerDesc> queryUserTasksByVariables) {
    List<CaseUserTaskWithVariables> data = new ArrayList<>();
    for (UserTaskInstanceWithPotOwnerDesc desc : queryUserTasksByVariables) {
        CaseUserTaskWithVariables var = new CaseUserTaskWithVariables();
        var.setId(desc.getTaskId());
        var.setName(desc.getName());
        var.setDescription(desc.getDescription());
        var.setProcessInstanceId(desc.getProcessInstanceId());
        var.setCorrelationKey(desc.getCorrelationKey());
        var.setActualOwner(desc.getActualOwner());
        var.setCaseDefinitionId(desc.getProcessId());
        var.setPotentialOwners(desc.getPotentialOwners());
        var.setCaseId(desc.getCorrelationKey());
        var.setProcessVariables(desc.getProcessVariables());
        var.setInputVariables(desc.getInputdata());
        var.setCaseVariables(desc.getExtraData());
        var.setStatus(desc.getStatus());
        data.add(var);
    }
    CaseUserTaskWithVariablesList result = new CaseUserTaskWithVariablesList();
    result.setCaseUserTaskWithVariables(data.stream().toArray(CaseUserTaskWithVariables[]::new));
    return result;
}
Also used : UserTaskInstanceWithPotOwnerDesc(org.jbpm.services.api.model.UserTaskInstanceWithPotOwnerDesc) CaseUserTaskWithVariablesList(org.kie.server.api.model.cases.CaseUserTaskWithVariablesList) ArrayList(java.util.ArrayList) CaseUserTaskWithVariables(org.kie.server.api.model.cases.CaseUserTaskWithVariables)

Aggregations

CaseUserTaskWithVariables (org.kie.server.api.model.cases.CaseUserTaskWithVariables)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 UserTaskInstanceWithPotOwnerDesc (org.jbpm.services.api.model.UserTaskInstanceWithPotOwnerDesc)1 Test (org.junit.Test)1 CaseInstance (org.kie.server.api.model.cases.CaseInstance)1 CaseInstanceCustomVars (org.kie.server.api.model.cases.CaseInstanceCustomVars)1 CaseUserTaskWithVariablesList (org.kie.server.api.model.cases.CaseUserTaskWithVariablesList)1 QueryParam (org.kie.server.api.model.definition.QueryParam)1 SearchQueryFilterSpec (org.kie.server.api.model.definition.SearchQueryFilterSpec)1 JbpmKieServerBaseIntegrationTest (org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)1