Search in sources :

Example 41 with CaseFileInstance

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;
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) HashMap(java.util.HashMap) UserImpl(org.jbpm.services.task.impl.model.UserImpl)

Example 42 with CaseFileInstance

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);
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) HashMap(java.util.HashMap) ClaimReport(org.jbpm.casemgmt.demo.insurance.ClaimReport) Date(java.util.Date)

Example 43 with CaseFileInstance

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");
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) HashMap(java.util.HashMap) GroupImpl(org.jbpm.services.task.impl.model.GroupImpl) UserImpl(org.jbpm.services.task.impl.model.UserImpl) CaseAssignment(org.kie.api.runtime.process.CaseAssignment) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 44 with CaseFileInstance

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");
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) HashMap(java.util.HashMap) GroupImpl(org.jbpm.services.task.impl.model.GroupImpl) UserImpl(org.jbpm.services.task.impl.model.UserImpl) CaseAssignment(org.kie.api.runtime.process.CaseAssignment) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 45 with CaseFileInstance

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);
        }
    }
}
Also used : OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) HashMap(java.util.HashMap) CaseAssignment(org.kie.api.runtime.process.CaseAssignment) QueryContext(org.kie.api.runtime.query.QueryContext) CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) CaseInstance(org.jbpm.casemgmt.api.model.instance.CaseInstance) GroupImpl(org.jbpm.services.task.impl.model.GroupImpl) UserImpl(org.jbpm.services.task.impl.model.UserImpl) TaskSummary(org.kie.api.task.model.TaskSummary) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Aggregations

CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)121 HashMap (java.util.HashMap)95 Test (org.junit.Test)86 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)81 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)66 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)61 UserImpl (org.jbpm.services.task.impl.model.UserImpl)54 QueryContext (org.kie.api.runtime.query.QueryContext)46 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)44 CaseCommentNotFoundException (org.jbpm.casemgmt.api.CaseCommentNotFoundException)42 TaskSummary (org.kie.api.task.model.TaskSummary)40 AdHocFragmentNotFoundException (org.jbpm.casemgmt.api.AdHocFragmentNotFoundException)39 CaseActiveException (org.jbpm.casemgmt.api.CaseActiveException)39 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)39 QueryFilter (org.kie.internal.query.QueryFilter)26 ArrayList (java.util.ArrayList)21 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)20 Collection (java.util.Collection)17 List (java.util.List)17 Map (java.util.Map)16