use of org.jbpm.casemgmt.api.model.instance.CaseFileInstance in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method startAndAssertCaseInstance.
protected String startAndAssertCaseInstance(String deploymentId, String insured, String insuranceRepresentative) {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("insured", new UserImpl(insured));
roleAssignments.put("insuranceRepresentative", new UserImpl(insuranceRepresentative));
roleAssignments.put("assessor", new UserImpl("krisv"));
// start new instance of a case with data and role assignment
Map<String, Object> data = new HashMap<>();
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentId, CAR_INSURANCE_CLAIM_PROC_ID, data, roleAssignments);
String caseId = caseService.startCase(deploymentId, CAR_INSURANCE_CLAIM_PROC_ID, caseFile);
assertNotNull(caseId);
assertEquals(CAR_INS_CASE_ID, caseId);
return caseId;
}
use of org.jbpm.casemgmt.api.model.instance.CaseFileInstance in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method provideAndAssertClaimReport.
protected void provideAndAssertClaimReport(Long taskId) {
ClaimReport claimReport = new ClaimReport();
claimReport.setName("John Doe");
claimReport.setAddress("Main street, NY");
claimReport.setAccidentDescription("It happened so sudden...");
claimReport.setAccidentDate(new Date());
Map<String, Object> params = new HashMap<>();
params.put("claimReport_", claimReport);
userTaskService.completeAutoProgress(taskId, "john", params);
// claim report should be stored in case file data
CaseFileInstance caseFile = caseService.getCaseFileInstance(CAR_INS_CASE_ID);
assertNotNull(caseFile);
ClaimReport caseClaimReport = (ClaimReport) caseFile.getData("claimReport");
assertNotNull(caseClaimReport);
}
use of org.jbpm.casemgmt.api.model.instance.CaseFileInstance in project jbpm by kiegroup.
the class CaseAssignmentServiceImplTest method testRoleAssignedMissingGroupAutoStart.
@Test
public void testRoleAssignedMissingGroupAutoStart() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("actorRole", new UserImpl("john"));
roleAssignments.put("groupRole", new GroupImpl("managers"));
Map<String, Object> data = new HashMap<>();
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), CASE_X_P_ID, data, roleAssignments);
((CaseAssignment) caseFile).assignGroup("generalRole", "managers");
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> {
caseService.startCase(deploymentUnit.getIdentifier(), CASE_X_P_ID, caseFile);
}).withMessageContaining("Case role 'generalRole' has no matching assignments");
}
use of org.jbpm.casemgmt.api.model.instance.CaseFileInstance in project jbpm by kiegroup.
the class CaseAssignmentServiceImplTest method testRoleAssignedMissingUserAutoStart.
@Test
public void testRoleAssignedMissingUserAutoStart() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("actorRole", new UserImpl("john"));
roleAssignments.put("groupRole", new GroupImpl("managers"));
Map<String, Object> data = new HashMap<>();
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), CASE_X_P_ID, data, roleAssignments);
((CaseAssignment) caseFile).assignUser("generalRole", "john");
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> {
caseService.startCase(deploymentUnit.getIdentifier(), CASE_X_P_ID, caseFile);
}).withMessageContaining("Case role 'generalRole' has no matching assignments");
}
use of org.jbpm.casemgmt.api.model.instance.CaseFileInstance in project jbpm by kiegroup.
the class CaseAssignmentServiceImplTest method testProperRoleAssigned.
@Test
public void testProperRoleAssigned() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("actorRole", new UserImpl("mary"));
roleAssignments.put("groupRole", new GroupImpl("managers"));
Map<String, Object> data = new HashMap<>();
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), CASE_Y_P_ID, data, roleAssignments);
((CaseAssignment) caseFile).assignGroup("generalRole", "managers");
((CaseAssignment) caseFile).assignUser("generalRole", "john");
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), CASE_Y_P_ID, caseFile);
assertNotNull(caseId);
assertEquals(FIRST_CASE_ID, caseId);
try {
CaseInstance cInstance = caseService.getCaseInstance(caseId);
assertNotNull(cInstance);
assertEquals(FIRST_CASE_ID, cInstance.getCaseId());
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
List<TaskSummary> tasks = caseRuntimeDataService.getCaseTasksAssignedAsPotentialOwner(caseId, "mary", null, new QueryContext());
assertEquals(5, tasks.size());
TaskSummary foundTask = tasks.stream().filter(task -> task.getName().equals("Task E")).findFirst().get();
userTaskService.completeAutoProgress(foundTask.getId(), "mary", new HashMap<>());
tasks = caseRuntimeDataService.getCaseTasksAssignedAsPotentialOwner(caseId, "john", null, new QueryContext());
assertEquals(1, tasks.size());
} catch (Exception e) {
logger.error("Unexpected error {}", e.getMessage(), e);
fail("Unexpected exception " + e.getMessage());
} finally {
if (caseId != null) {
caseService.cancelCase(caseId);
}
}
}
Aggregations