Search in sources :

Example 1 with CaseFileDataItem

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

the class CaseRuntimeDataServiceIntegrationTest method testGetCaseInstanceDataItems.

@Test
public void testGetCaseInstanceDataItems() {
    String caseClaimId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN, USER_YODA);
    assertNotNull(caseClaimId);
    List<CaseFileDataItem> dataItems = caseClient.getCaseInstanceDataItems(caseClaimId, 0, 10);
    assertNotNull(dataItems);
    assertEquals(1, dataItems.size());
    List<CaseStage> stages = caseClient.getStages(CONTAINER_ID, caseClaimId, true, 0, 10);
    assertEquals(1, stages.size());
    assertBuildClaimReportCaseStage(stages.iterator().next(), "Active");
    stages = caseClient.getStages(CONTAINER_ID, caseClaimId, true, 0, 10);
    assertEquals(1, stages.size());
    assertBuildClaimReportCaseStage(stages.iterator().next(), "Active");
    caseClient.putCaseInstanceData(CONTAINER_ID, caseClaimId, "claimReportDone", Boolean.TRUE);
    dataItems = caseClient.getCaseInstanceDataItems(caseClaimId, 0, 10);
    assertNotNull(dataItems);
    assertEquals(2, dataItems.size());
    CaseFileDataItem dataItem = dataItems.stream().filter(n -> "claimReportDone".equals(n.getName())).findAny().get();
    assertEquals(caseClaimId, dataItem.getCaseId());
    assertEquals("claimReportDone", dataItem.getName());
    assertEquals("true", dataItem.getValue());
    assertEquals(Boolean.class.getName(), dataItem.getType());
    assertEquals(USER_YODA, dataItem.getLastModifiedBy());
    dataItems = caseClient.getCaseInstanceDataItemsByType(caseClaimId, Arrays.asList(Boolean.class.getName()), 0, 10);
    assertNotNull(dataItems);
    assertEquals(1, dataItems.size());
    dataItems = caseClient.getCaseInstanceDataItemsByType(caseClaimId, Arrays.asList(String.class.getName()), 0, 10);
    assertNotNull(dataItems);
    assertEquals(1, dataItems.size());
    dataItems = caseClient.getCaseInstanceDataItemsByName(caseClaimId, Arrays.asList("claimReportDone"), 0, 10);
    assertNotNull(dataItems);
    assertEquals(1, dataItems.size());
    dataItems = caseClient.getCaseInstanceDataItemsByName(caseClaimId, Arrays.asList("notExisting"), 0, 10);
    assertNotNull(dataItems);
    assertEquals(0, dataItems.size());
    stages = caseClient.getStages(CONTAINER_ID, caseClaimId, false, 0, 10);
    assertEquals(3, stages.size());
    assertBuildClaimReportCaseStage(stages.get(0), "Completed");
    assertClaimAssesmentCaseStage(stages.get(1), "Active");
    assertEscalateRejectedClaimCaseStage(stages.get(2), "Available");
    stages = caseClient.getStages(CONTAINER_ID, caseClaimId, true, 0, 10);
    assertEquals(1, stages.size());
    assertClaimAssesmentCaseStage(stages.iterator().next(), "Active");
}
Also used : CaseStage(org.kie.server.api.model.cases.CaseStage) CaseFileDataItem(org.kie.server.api.model.cases.CaseFileDataItem) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest) Test(org.junit.Test)

Example 2 with CaseFileDataItem

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

the class ConvertUtils method transformCaseFileDataItems.

public static CaseFileDataItemList transformCaseFileDataItems(Collection<CaseFileItem> caseFileItems) {
    if (caseFileItems == null) {
        return new CaseFileDataItemList(new CaseFileDataItem[0]);
    }
    List<CaseFileDataItem> caseFileDataItems = new ArrayList<CaseFileDataItem>(caseFileItems.size());
    for (CaseFileItem item : caseFileItems) {
        CaseFileDataItem caseFileDataItem = transformCaseFileDataItem(item);
        caseFileDataItems.add(caseFileDataItem);
    }
    return new CaseFileDataItemList(caseFileDataItems);
}
Also used : ArrayList(java.util.ArrayList) CaseFileDataItemList(org.kie.server.api.model.cases.CaseFileDataItemList) CaseFileDataItem(org.kie.server.api.model.cases.CaseFileDataItem) CaseFileItem(org.jbpm.casemgmt.api.model.CaseFileItem)

Aggregations

CaseFileDataItem (org.kie.server.api.model.cases.CaseFileDataItem)2 ArrayList (java.util.ArrayList)1 CaseFileItem (org.jbpm.casemgmt.api.model.CaseFileItem)1 Test (org.junit.Test)1 CaseFileDataItemList (org.kie.server.api.model.cases.CaseFileDataItemList)1 CaseStage (org.kie.server.api.model.cases.CaseStage)1 JbpmKieServerBaseIntegrationTest (org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)1