use of org.kie.server.api.model.cases.CaseStage in project droolsjbpm-integration by kiegroup.
the class CaseRuntimeDataServiceIntegrationTest method testGetCaseInstanceCarInsuranceClaimCaseWithData.
@Test
public void testGetCaseInstanceCarInsuranceClaimCaseWithData() {
String caseId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN, USER_YODA);
CaseInstance caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId, true, true, true, true);
assertCarInsuranceCaseInstance(caseInstance, caseId, USER_YODA);
KieServerAssert.assertNullOrEmpty("Milestones should be empty.", caseInstance.getMilestones());
// Assert case file
assertNotNull(caseInstance.getCaseFile());
assertEquals("first case started", caseInstance.getCaseFile().getData().get("s"));
// Assert role assignments
assertNotNull(caseInstance.getRoleAssignments());
assertEquals(4, caseInstance.getRoleAssignments().size());
CaseRoleAssignment ownerRole = caseInstance.getRoleAssignments().get(0);
assertEquals("owner", ownerRole.getName());
assertEquals(1, ownerRole.getUsers().size());
assertEquals(USER_YODA, ownerRole.getUsers().get(0));
KieServerAssert.assertNullOrEmpty("Groups should be empty.", ownerRole.getGroups());
CaseRoleAssignment insuredRole = caseInstance.getRoleAssignments().get(1);
assertEquals("insured", insuredRole.getName());
assertEquals(1, insuredRole.getUsers().size());
assertEquals(USER_YODA, insuredRole.getUsers().get(0));
KieServerAssert.assertNullOrEmpty("Groups should be empty.", insuredRole.getGroups());
CaseRoleAssignment assessorRole = caseInstance.getRoleAssignments().get(2);
assertEquals("assessor", assessorRole.getName());
assertEquals(USER_YODA, assessorRole.getUsers().get(0));
KieServerAssert.assertNullOrEmpty("Groups should be empty.", assessorRole.getGroups());
CaseRoleAssignment insuranceRepresentativeRole = caseInstance.getRoleAssignments().get(3);
assertEquals("insuranceRepresentative", insuranceRepresentativeRole.getName());
assertEquals(1, insuranceRepresentativeRole.getUsers().size());
assertEquals(USER_JOHN, insuranceRepresentativeRole.getUsers().get(0));
KieServerAssert.assertNullOrEmpty("Groups should be empty.", insuranceRepresentativeRole.getGroups());
// Assert stages
assertNotNull(caseInstance.getStages());
assertEquals(1, caseInstance.getStages().size());
CaseStage stage = caseInstance.getStages().get(0);
assertNotNull(stage.getIdentifier());
assertEquals("Build claim report", stage.getName());
assertEquals("Active", stage.getStatus());
List<NodeInstance> activeNodes = stage.getActiveNodes();
assertEquals(1, activeNodes.size());
assertEquals("Provide accident information", activeNodes.get(0).getName());
assertEquals("HumanTaskNode", activeNodes.get(0).getNodeType());
assertEquals(2, stage.getAdHocFragments().size());
}
use of org.kie.server.api.model.cases.CaseStage in project droolsjbpm-integration by kiegroup.
the class CaseRuntimeDataServiceIntegrationTest method testCreateDifferentTypesCases.
@Test
public void testCreateDifferentTypesCases() {
String caseId = startUserTaskCase(USER_YODA, USER_JOHN);
String caseClaimId = startCarInsuranceClaimCase(USER_JOHN, USER_YODA, USER_YODA);
assertNotNull(caseId);
assertTrue(caseId.startsWith(CASE_HR_ID_PREFIX));
assertNotNull(caseClaimId);
assertTrue(caseClaimId.startsWith(CLAIM_CASE_ID_PREFIX));
List<CaseInstance> caseInstances = caseClient.getCaseInstancesByContainer(CONTAINER_ID, Arrays.asList(CaseStatus.OPEN.getName()), 0, 10);
assertEquals(2, caseInstances.size());
List<String> caseDefs = caseInstances.stream().map(c -> c.getCaseDefinitionId()).collect(toList());
assertTrue(caseDefs.contains(CASE_HR_DEF_ID));
assertTrue(caseDefs.contains(CLAIM_CASE_DEF_ID));
caseInstances = caseClient.getCaseInstancesByDefinition(CONTAINER_ID, CLAIM_CASE_DEF_ID, Arrays.asList(CaseStatus.OPEN.getName()), 0, 10);
assertEquals(1, caseInstances.size());
List<CaseStage> stages = caseClient.getStages(CONTAINER_ID, caseClaimId, true, 0, 10);
assertEquals(1, stages.size());
CaseStage caseStage = stages.get(0);
assertEquals("Build claim report", caseStage.getName());
assertEquals(2, caseStage.getAdHocFragments().size());
List<CaseRoleAssignment> roles = caseClient.getRoleAssignments(CONTAINER_ID, caseClaimId);
assertEquals(4, roles.size());
Map<String, CaseRoleAssignment> mappedRoles = roles.stream().collect(toMap(CaseRoleAssignment::getName, r -> r));
assertTrue(mappedRoles.containsKey(CASE_OWNER_ROLE));
assertTrue(mappedRoles.containsKey(CASE_INSURED_ROLE));
assertTrue(mappedRoles.containsKey(CASE_INS_REP_ROLE));
assertTrue(mappedRoles.containsKey(CASE_ASSESSOR_ROLE));
CaseRoleAssignment ownerRole = mappedRoles.get(CASE_OWNER_ROLE);
assertTrue(ownerRole.getUsers().contains(USER_YODA));
KieServerAssert.assertNullOrEmpty("Groups should be empty", ownerRole.getGroups());
CaseRoleAssignment insuredRole = mappedRoles.get(CASE_INSURED_ROLE);
assertTrue(insuredRole.getUsers().contains(USER_JOHN));
KieServerAssert.assertNullOrEmpty("Groups should be empty", insuredRole.getGroups());
CaseRoleAssignment insRepRole = mappedRoles.get(CASE_INS_REP_ROLE);
assertTrue(insRepRole.getUsers().contains(USER_YODA));
KieServerAssert.assertNullOrEmpty("Groups should be empty", insRepRole.getGroups());
CaseRoleAssignment assessorRole = mappedRoles.get(CASE_ASSESSOR_ROLE);
assertTrue(assessorRole.getUsers().contains(USER_YODA));
KieServerAssert.assertNullOrEmpty("Groups should be empty", assessorRole.getGroups());
caseClient.assignUserToRole(CONTAINER_ID, caseClaimId, CASE_ASSESSOR_ROLE, USER_MARY);
caseClient.assignGroupToRole(CONTAINER_ID, caseClaimId, CASE_ASSESSOR_ROLE, "managers");
roles = caseClient.getRoleAssignments(CONTAINER_ID, caseClaimId);
assertEquals(4, roles.size());
mappedRoles = roles.stream().collect(toMap(CaseRoleAssignment::getName, r -> r));
assessorRole = mappedRoles.get(CASE_ASSESSOR_ROLE);
assertTrue(assessorRole.getUsers().contains(USER_MARY));
assertTrue(assessorRole.getGroups().contains("managers"));
caseClient.removeUserFromRole(CONTAINER_ID, caseClaimId, CASE_ASSESSOR_ROLE, USER_MARY);
caseClient.removeUserFromRole(CONTAINER_ID, caseClaimId, CASE_ASSESSOR_ROLE, USER_YODA);
caseClient.removeGroupFromRole(CONTAINER_ID, caseClaimId, CASE_ASSESSOR_ROLE, "managers");
roles = caseClient.getRoleAssignments(CONTAINER_ID, caseClaimId);
assertEquals(4, roles.size());
mappedRoles = roles.stream().collect(toMap(CaseRoleAssignment::getName, r -> r));
assessorRole = mappedRoles.get(CASE_ASSESSOR_ROLE);
KieServerAssert.assertNullOrEmpty("Users should be empty", assessorRole.getUsers());
KieServerAssert.assertNullOrEmpty("Groups should be empty", assessorRole.getGroups());
}
use of org.kie.server.api.model.cases.CaseStage in project droolsjbpm-integration by kiegroup.
the class CaseRuntimeDataServiceIntegrationTest method testTriggerTaskIntoStage.
@Test
public void testTriggerTaskIntoStage() throws Exception {
String caseClaimId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN, USER_YODA);
assertNotNull(caseClaimId);
List<CaseStage> stages = caseClient.getStages(CONTAINER_ID, caseClaimId, true, 0, 10);
assertEquals(1, stages.size());
CaseStage stage = stages.iterator().next();
assertBuildClaimReportCaseStage(stage, "Active");
List<TaskSummary> tasks = caseClient.findCaseTasksAssignedAsPotentialOwner(caseClaimId, USER_YODA, 0, 10);
assertNotNull(tasks);
int countOfTaskBefore = tasks.size();
assertNotNull(stage.getIdentifier());
caseClient.triggerAdHocFragmentInStage(CONTAINER_ID, caseClaimId, stage.getIdentifier(), SUBMIT_POLICE_REPORT_TASK, Collections.EMPTY_MAP);
tasks = caseClient.findCaseTasksAssignedAsPotentialOwner(caseClaimId, USER_YODA, 0, 10);
assertNotNull(tasks);
assertEquals(countOfTaskBefore + 1, tasks.size());
TaskSummary task = tasks.get(0);
assertNotNull(task);
assertEquals(SUBMIT_POLICE_REPORT_TASK, task.getName());
caseClient.putCaseInstanceData(CONTAINER_ID, caseClaimId, "claimReportDone", Boolean.TRUE);
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");
tasks = caseClient.findCaseTasksAssignedAsPotentialOwner(caseClaimId, USER_YODA, 0, 10);
assertNotNull(tasks);
assertEquals(1, tasks.size());
task = tasks.get(0);
assertNotEquals(SUBMIT_POLICE_REPORT_TASK, task.getName());
assertClientException(() -> caseClient.triggerAdHocFragmentInStage(CONTAINER_ID, caseClaimId, stage.getIdentifier(), SUBMIT_POLICE_REPORT_TASK, Collections.EMPTY_MAP), 404, "No stage found with id " + stage.getIdentifier());
caseClient.destroyCaseInstance(CONTAINER_ID, caseClaimId);
}
use of org.kie.server.api.model.cases.CaseStage 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");
}
use of org.kie.server.api.model.cases.CaseStage in project droolsjbpm-integration by kiegroup.
the class CaseServiceIntegrationTest method testAddDynamicTaskToStageInvalidContainer.
@Test
public void testAddDynamicTaskToStageInvalidContainer() {
String caseId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN, USER_YODA);
Assertions.assertThat(caseId).isNotNull();
List<CaseStage> caseStages = caseClient.getStages(CONTAINER_ID, caseId, false, 0, 100);
Assertions.assertThat(caseStages).isNotNull();
Assertions.assertThat(caseStages).isNotEmpty();
CaseStage firstCaseStage = caseStages.iterator().next();
String firstStageId = firstCaseStage.getIdentifier();
assertClientException(() -> caseClient.addDynamicTaskToStage(BAD_CONTAINER_ID, caseId, firstStageId, "ContactCarProducer", "Contact car producer", null), 404, BAD_CONTAINER_ID);
}
Aggregations