use of org.kie.server.api.model.cases.CaseInstanceCustomVars in project droolsjbpm-integration by kiegroup.
the class ConvertUtils method convertToCaseInstanceCustomVarsList.
public static CaseInstanceCustomVarsList convertToCaseInstanceCustomVarsList(List<ProcessInstanceWithVarsDesc> queryCaseByVariables) {
List<CaseInstanceCustomVars> processInstances = new ArrayList<>();
for (ProcessInstanceWithVarsDesc proc : queryCaseByVariables) {
CaseInstanceCustomVars tmp = new CaseInstanceCustomVars();
tmp.setProcessInstanceId(proc.getId());
tmp.setProcessName(proc.getProcessName());
tmp.setProcessVersion(proc.getProcessVersion());
tmp.setCaseId(proc.getCorrelationKey());
tmp.setCaseDefinitionId(proc.getProcessId());
tmp.setCorrelationKey(proc.getCorrelationKey());
tmp.setProcessVariables(proc.getVariables());
tmp.setCaseVariables(proc.getExtraData());
tmp.setInitiator(proc.getInitiator());
tmp.setState(proc.getState());
tmp.setContainerId(proc.getDeploymentId());
processInstances.add(tmp);
}
CaseInstanceCustomVarsList result = new CaseInstanceCustomVarsList();
result.setCaseInstances(processInstances.stream().toArray(CaseInstanceCustomVars[]::new));
return result;
}
use of org.kie.server.api.model.cases.CaseInstanceCustomVars 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);
}
Aggregations