use of org.jbpm.casemgmt.api.model.instance.CaseInstance in project jbpm by kiegroup.
the class CaseSLAComplianceTest method testStartCaseWithSLAForGoldCustomerByRules.
@Test
public void testStartCaseWithSLAForGoldCustomerByRules() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("owner", new UserImpl("john"));
roleAssignments.put("admin", new UserImpl("mary"));
Map<String, Object> data = new HashMap<>();
data.put("s", "Case with SLA");
data.put("CustomerType", "Gold");
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), USER_TASK_SLA_EXPR_CASE_P_ID, data, roleAssignments);
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), USER_TASK_SLA_EXPR_CASE_P_ID, caseFile);
assertNotNull(caseId);
assertEquals(HR_CASE_ID, caseId);
try {
CaseInstance cInstance = caseService.getCaseInstance(caseId, true, false, false, false);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
assertEquals(ProcessInstance.SLA_PENDING, cInstance.getSlaCompliance().intValue());
Object calcualtedSlaDueDate = cInstance.getCaseFile().getData("slaDueDate");
assertNotNull(calcualtedSlaDueDate);
assertThat(calcualtedSlaDueDate).isEqualTo("1s");
CountDownListenerFactory.getExisting("slaCompliance").waitTillCompleted();
cInstance = caseService.getCaseInstance(caseId);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
assertEquals(ProcessInstance.SLA_VIOLATED, cInstance.getSlaCompliance().intValue());
caseService.cancelCase(caseId);
CaseInstance instance = caseService.getCaseInstance(caseId);
Assertions.assertThat(instance.getStatus()).isEqualTo(CaseStatus.CANCELLED.getId());
caseId = null;
} 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.CaseInstance in project jbpm by kiegroup.
the class CaseSLAComplianceTest method testStartCaseWithSLAForSilverCustomerByRules.
@Test
public void testStartCaseWithSLAForSilverCustomerByRules() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("owner", new UserImpl("john"));
roleAssignments.put("admin", new UserImpl("mary"));
Map<String, Object> data = new HashMap<>();
data.put("s", "Case with SLA");
data.put("CustomerType", "Silver");
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), USER_TASK_SLA_EXPR_CASE_P_ID, data, roleAssignments);
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), USER_TASK_SLA_EXPR_CASE_P_ID, caseFile);
assertNotNull(caseId);
assertEquals(HR_CASE_ID, caseId);
try {
CaseInstance cInstance = caseService.getCaseInstance(caseId, true, false, false, false);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
assertEquals(ProcessInstance.SLA_PENDING, cInstance.getSlaCompliance().intValue());
Object calcualtedSlaDueDate = cInstance.getCaseFile().getData("slaDueDate");
assertNotNull(calcualtedSlaDueDate);
assertThat(calcualtedSlaDueDate).isEqualTo("2s");
CountDownListenerFactory.getExisting("slaCompliance").waitTillCompleted();
cInstance = caseService.getCaseInstance(caseId);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
assertEquals(ProcessInstance.SLA_VIOLATED, cInstance.getSlaCompliance().intValue());
caseService.cancelCase(caseId);
CaseInstance instance = caseService.getCaseInstance(caseId);
Assertions.assertThat(instance.getStatus()).isEqualTo(CaseStatus.CANCELLED.getId());
caseId = null;
} 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.CaseInstance in project jbpm by kiegroup.
the class CaseSLAComplianceTest method testStartCaseWithSLAEscalation.
@Test
public void testStartCaseWithSLAEscalation() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("owner", new UserImpl("john"));
roleAssignments.put("admin", new UserImpl("mary"));
Map<String, Object> data = new HashMap<>();
data.put("s", "Case with SLA");
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), USER_TASK_SLA_CASE_P_ID, data, roleAssignments);
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), USER_TASK_SLA_CASE_P_ID, caseFile);
assertNotNull(caseId);
assertEquals(HR_CASE_ID, caseId);
try {
CaseInstance cInstance = caseService.getCaseInstance(caseId);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
assertEquals(ProcessInstance.SLA_PENDING, cInstance.getSlaCompliance().intValue());
List<TaskSummary> escalationTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("mary", new QueryFilter());
assertThat(escalationTasks).hasSize(0);
CountDownListenerFactory.getExisting("slaCompliance").waitTillCompleted();
cInstance = caseService.getCaseInstance(caseId);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
assertEquals(ProcessInstance.SLA_VIOLATED, cInstance.getSlaCompliance().intValue());
escalationTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("mary", new QueryFilter());
assertThat(escalationTasks).hasSize(1);
TaskSummary task = escalationTasks.get(0);
assertThat(task.getName()).isEqualTo("SLA violation for case " + caseId);
assertThat(task.getDescription()).isEqualTo("Service Level Agreement has been violated for case " + caseId);
caseService.cancelCase(caseId);
CaseInstance instance = caseService.getCaseInstance(caseId);
Assertions.assertThat(instance.getStatus()).isEqualTo(CaseStatus.CANCELLED.getId());
caseId = null;
} 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.CaseInstance in project jbpm by kiegroup.
the class CaseSLAComplianceTest method testStartCaseWithSLASubprocess.
@Test
public void testStartCaseWithSLASubprocess() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("owner", new UserImpl("john"));
roleAssignments.put("admin", new UserImpl("mary"));
Map<String, Object> data = new HashMap<>();
data.put("s", "Case with SLA");
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), USER_TASK_SLA_CASE_P_ID, data, roleAssignments);
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), USER_TASK_SLA_CASE_P_ID, caseFile);
assertNotNull(caseId);
assertEquals(HR_CASE_ID, caseId);
try {
CaseInstance cInstance = caseService.getCaseInstance(caseId);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
assertEquals(ProcessInstance.SLA_PENDING, cInstance.getSlaCompliance().intValue());
Collection<ProcessInstanceDesc> caseProcessInstances = caseRuntimeDataService.getProcessInstancesForCase(caseId, new QueryContext());
assertNotNull(caseProcessInstances);
assertEquals(1, caseProcessInstances.size());
CountDownListenerFactory.getExisting("slaCompliance").waitTillCompleted();
cInstance = caseService.getCaseInstance(caseId);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
assertEquals(ProcessInstance.SLA_VIOLATED, cInstance.getSlaCompliance().intValue());
caseProcessInstances = caseRuntimeDataService.getProcessInstancesForCase(caseId, new QueryContext());
assertNotNull(caseProcessInstances);
assertEquals(2, caseProcessInstances.size());
for (ProcessInstanceDesc pi : caseProcessInstances) {
assertThat(pi.getCorrelationKey()).startsWith(HR_CASE_ID);
}
caseService.cancelCase(caseId);
CaseInstance instance = caseService.getCaseInstance(caseId);
Assertions.assertThat(instance.getStatus()).isEqualTo(CaseStatus.CANCELLED.getId());
caseId = null;
} 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.CaseInstance in project jbpm by kiegroup.
the class CaseSLAComplianceTest method testStartCaseWithSLAForNewCustomerByRules.
@Test
public void testStartCaseWithSLAForNewCustomerByRules() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("owner", new UserImpl("john"));
roleAssignments.put("admin", new UserImpl("mary"));
Map<String, Object> data = new HashMap<>();
data.put("s", "Case with SLA");
data.put("CustomerType", "New");
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), USER_TASK_SLA_EXPR_CASE_P_ID, data, roleAssignments);
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), USER_TASK_SLA_EXPR_CASE_P_ID, caseFile);
assertNotNull(caseId);
assertEquals(HR_CASE_ID, caseId);
try {
CaseInstance cInstance = caseService.getCaseInstance(caseId, true, false, false, false);
assertNotNull(cInstance);
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
assertEquals(ProcessInstance.SLA_NA, cInstance.getSlaCompliance().intValue());
Object calcualtedSlaDueDate = cInstance.getCaseFile().getData("slaDueDate");
assertNotNull(calcualtedSlaDueDate);
assertThat(calcualtedSlaDueDate).isEqualTo("");
caseService.cancelCase(caseId);
CaseInstance instance = caseService.getCaseInstance(caseId);
Assertions.assertThat(instance.getStatus()).isEqualTo(CaseStatus.CANCELLED.getId());
caseId = null;
} catch (Exception e) {
logger.error("Unexpected error {}", e.getMessage(), e);
fail("Unexpected exception " + e.getMessage());
} finally {
if (caseId != null) {
caseService.cancelCase(caseId);
}
}
}
Aggregations