use of org.jbpm.casemgmt.api.model.instance.CaseStageInstance in project jbpm by kiegroup.
the class CaseServiceImplTest method testUserTaskToCaseWithStageComplete.
@Test
public void testUserTaskToCaseWithStageComplete() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("owner", new UserImpl("john"));
Map<String, Object> data = new HashMap<>();
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), USER_TASK_CASE_P_ID, data, roleAssignments);
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), USER_TASK_STAGE_CASE_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());
CaseDefinition caseDef = caseRuntimeDataService.getCase(deploymentUnit.getIdentifier(), USER_TASK_STAGE_CASE_P_ID);
assertNotNull(caseDef);
assertEquals(1, caseDef.getCaseStages().size());
assertEquals(deploymentUnit.getIdentifier(), caseDef.getDeploymentId());
Collection<CaseStageInstance> activeStages = caseRuntimeDataService.getCaseInstanceStages(caseId, true, new QueryContext());
assertNotNull(activeStages);
assertEquals(1, activeStages.size());
caseService.addDataToCaseFile(caseId, "dataComplete", true);
activeStages = caseRuntimeDataService.getCaseInstanceStages(caseId, true, new QueryContext());
assertNotNull(activeStages);
assertEquals(0, activeStages.size());
} catch (Exception e) {
logger.error("Unexpected error {}", e.getMessage(), e);
fail("Unexpected exception " + e.getMessage());
} finally {
if (caseId != null) {
caseService.cancelCase(caseId);
}
}
}
use of org.jbpm.casemgmt.api.model.instance.CaseStageInstance in project jbpm by kiegroup.
the class StageActivationConditionTest method testAutoComplete.
@Test
public void testAutoComplete() {
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), STAGE_WITH_ACTIVATION_COND);
assertThat(caseId).isNotNull().isEqualTo(FIRST_CASE_ID);
assertCaseInstanceActive(caseId);
Collection<CaseStageInstance> activeStages = caseRuntimeDataService.getCaseInstanceStages(caseId, true, new QueryContext());
assertThat(activeStages).hasSize(0);
caseService.addDataToCaseFile(caseId, "readyToActivate", true);
activeStages = caseRuntimeDataService.getCaseInstanceStages(caseId, true, new QueryContext());
assertThat(activeStages).hasSize(1);
caseService.addDataToCaseFile(caseId, "readyToComplete", true);
assertCaseInstanceNotActive(caseId);
}
use of org.jbpm.casemgmt.api.model.instance.CaseStageInstance in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method assertClaimAssesmentStage.
protected void assertClaimAssesmentStage() {
Collection<CaseStageInstance> activeStages = caseRuntimeDataService.getCaseInstanceStages(CAR_INS_CASE_ID, true, new QueryContext());
assertEquals(1, activeStages.size());
CaseStageInstance stage = activeStages.iterator().next();
assertEquals("Claim assesment", stage.getName());
}
use of org.jbpm.casemgmt.api.model.instance.CaseStageInstance in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method assertAndNegotiateClaimOffer.
protected void assertAndNegotiateClaimOffer(int numberOfNegotiations) {
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertTask(tasks.get(0), "john", "Present calculated claim", Status.Reserved);
// let's accept the calculated claim
Map<String, Object> params = new HashMap<>();
params.put("accepted", false);
userTaskService.completeAutoProgress(tasks.get(0).getId(), "john", params);
Collection<CaseStageInstance> activeStages = caseRuntimeDataService.getCaseInstanceStages(CAR_INS_CASE_ID, true, new QueryContext());
assertEquals(1, activeStages.size());
CaseStageInstance stage = activeStages.iterator().next();
assertEquals("Escalate rejected claim", stage.getName());
while (numberOfNegotiations > 0) {
params.clear();
params.put("Offer", 1000);
caseService.triggerAdHocFragment(CAR_INS_CASE_ID, "Negotiation meeting", params);
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertTask(tasks.get(0), null, "Negotiation meeting", Status.Ready);
boolean accepted = false;
if (numberOfNegotiations == 1) {
accepted = true;
}
params.put("accepted", accepted);
userTaskService.completeAutoProgress(tasks.get(0).getId(), "john", params);
numberOfNegotiations--;
}
}
use of org.jbpm.casemgmt.api.model.instance.CaseStageInstance in project jbpm by kiegroup.
the class CaseRuntimeDataServiceImpl method getCaseInstanceStages.
@Override
public Collection<CaseStageInstance> getCaseInstanceStages(String caseId, boolean activeOnly, QueryContext queryContext) {
ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceByCorrelationKey(correlationKeyFactory.newCorrelationKey(caseId));
if (pi == null || !pi.getState().equals(ProcessInstance.STATE_ACTIVE)) {
throw new CaseNotFoundException("No case instance found with id " + caseId + " or it's not active anymore");
}
CaseDefinition caseDef = getCase(pi.getDeploymentId(), pi.getProcessId());
List<CaseStageInstance> stages = internalGetCaseStages(caseDef, caseId, activeOnly, queryContext);
return applyPagination(stages, queryContext);
}
Aggregations