use of org.kie.server.api.model.cases.CaseMilestone in project droolsjbpm-integration by kiegroup.
the class CaseManagementRuntimeDataServiceBase method getMilestones.
public CaseMilestoneList getMilestones(String containerId, String caseId, boolean achievedOnly, Integer page, Integer pageSize) {
Collection<CaseMilestoneInstance> caseMilestones = caseRuntimeDataService.getCaseInstanceMilestones(caseId, achievedOnly, ConvertUtils.buildQueryContext(page, pageSize));
List<CaseMilestone> milestones = ConvertUtils.transformMilestones(caseMilestones);
CaseMilestoneList milestoneList = new CaseMilestoneList(milestones);
return milestoneList;
}
use of org.kie.server.api.model.cases.CaseMilestone in project droolsjbpm-integration by kiegroup.
the class CaseRuntimeDataServiceIntegrationTest method testCreateCaseWithCaseFileAndTriggerMilestones.
@Test
public void testCreateCaseWithCaseFileAndTriggerMilestones() {
String caseId = startUserTaskCase(USER_YODA, USER_JOHN);
assertNotNull(caseId);
assertTrue(caseId.startsWith(CASE_HR_ID_PREFIX));
CaseInstance caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
assertHrCaseInstance(caseInstance, caseId, USER_YODA);
List<CaseInstance> caseInstances = caseClient.getCaseInstancesOwnedBy(USER_YODA, null, 0, 10);
assertEquals(1, caseInstances.size());
List<CaseMilestone> milestones = caseClient.getMilestones(CONTAINER_ID, caseId, true, 0, 10);
assertNotNull(milestones);
assertEquals(0, milestones.size());
caseClient.triggerAdHocFragment(CONTAINER_ID, caseId, "Milestone1", null);
milestones = caseClient.getMilestones(CONTAINER_ID, caseId, true, 0, 10);
assertNotNull(milestones);
assertEquals(1, milestones.size());
CaseMilestone milestone = milestones.get(0);
assertNotNull(milestone);
assertEquals("Milestone1", milestone.getName());
assertEquals(true, milestone.isAchieved());
assertEquals("2", milestone.getIdentifier());
assertNotNull(milestone.getAchievedAt());
caseClient.triggerAdHocFragment(CONTAINER_ID, caseId, "Milestone2", null);
milestones = caseClient.getMilestones(CONTAINER_ID, caseId, true, 0, 10);
assertNotNull(milestones);
assertEquals(1, milestones.size());
milestones = caseClient.getMilestones(CONTAINER_ID, caseId, false, 0, 10);
assertNotNull(milestones);
assertEquals(2, milestones.size());
Map<String, CaseMilestone> mappedMilestones = milestones.stream().collect(Collectors.toMap(CaseMilestone::getName, d -> d));
assertTrue(mappedMilestones.containsKey("Milestone1"));
assertTrue(mappedMilestones.containsKey("Milestone2"));
assertTrue(mappedMilestones.get("Milestone1").isAchieved());
assertFalse(mappedMilestones.get("Milestone2").isAchieved());
caseInstances = caseClient.getCaseInstances(0, 10);
assertEquals(1, caseInstances.size());
assertHrCaseInstance(caseInstances.get(0), caseId, USER_YODA);
// now auto complete milestone by inserting data
caseClient.putCaseInstanceData(CONTAINER_ID, caseId, "dataComplete", true);
milestones = caseClient.getMilestones(CONTAINER_ID, caseId, true, 0, 10);
assertNotNull(milestones);
assertEquals(2, milestones.size());
}
use of org.kie.server.api.model.cases.CaseMilestone in project droolsjbpm-integration by kiegroup.
the class CaseRuntimeDataServiceIntegrationTest method testGetCaseInstanceUserTaskCaseWithData.
@Test
public void testGetCaseInstanceUserTaskCaseWithData() {
String caseId = startUserTaskCase(USER_YODA, USER_JOHN);
caseClient.triggerAdHocFragment(CONTAINER_ID, caseId, "Milestone1", null);
CaseInstance caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId, true, true, true, true);
assertHrCaseInstance(caseInstance, caseId, USER_YODA);
KieServerAssert.assertNullOrEmpty("Stages should be empty.", caseInstance.getStages());
// Assert case file
assertNotNull(caseInstance.getCaseFile());
assertEquals("first case started", caseInstance.getCaseFile().getData().get("s"));
// Assert role assignments
assertNotNull(caseInstance.getRoleAssignments());
assertEquals(3, 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 contactRole = caseInstance.getRoleAssignments().get(1);
assertEquals("contact", contactRole.getName());
assertEquals(1, contactRole.getUsers().size());
assertEquals(USER_JOHN, contactRole.getUsers().get(0));
KieServerAssert.assertNullOrEmpty("Groups should be empty.", contactRole.getGroups());
CaseRoleAssignment participantRole = caseInstance.getRoleAssignments().get(2);
assertEquals("participant", participantRole.getName());
KieServerAssert.assertNullOrEmpty("Users should be empty.", participantRole.getUsers());
KieServerAssert.assertNullOrEmpty("Groups should be empty.", participantRole.getGroups());
// Assert milestones
assertNotNull(caseInstance.getMilestones());
assertEquals(2, caseInstance.getMilestones().size());
CaseMilestone milestone = caseInstance.getMilestones().get(0);
assertNotNull(milestone.getIdentifier());
assertEquals("Milestone2", milestone.getName());
assertEquals("Available", milestone.getStatus());
assertNull(milestone.getAchievedAt());
assertFalse(milestone.isAchieved());
milestone = caseInstance.getMilestones().get(1);
assertEquals("2", milestone.getIdentifier());
assertEquals("Milestone1", milestone.getName());
assertEquals("Completed", milestone.getStatus());
assertNotNull(milestone.getAchievedAt());
assertTrue(milestone.isAchieved());
}
use of org.kie.server.api.model.cases.CaseMilestone in project droolsjbpm-integration by kiegroup.
the class CaseRuntimeDataServiceIntegrationTest method testTriggerNotExistingAdHocFragments.
@Test
public void testTriggerNotExistingAdHocFragments() {
String caseId = startUserTaskCase(USER_YODA, USER_JOHN);
assertNotNull(caseId);
assertTrue(caseId.startsWith(CASE_HR_ID_PREFIX));
CaseInstance caseInstance = caseClient.getCaseInstance(CONTAINER_ID, caseId);
assertHrCaseInstance(caseInstance, caseId, USER_YODA);
List<CaseInstance> caseInstances = caseClient.getCaseInstancesOwnedBy(USER_YODA, null, 0, 10);
assertEquals(1, caseInstances.size());
List<CaseMilestone> milestones = caseClient.getMilestones(CONTAINER_ID, caseId, true, 0, 10);
assertNotNull(milestones);
assertEquals(0, milestones.size());
final String nonExistingAdHocFragment = "not existing";
assertClientException(() -> caseClient.triggerAdHocFragment(CONTAINER_ID, caseId, nonExistingAdHocFragment, Collections.EMPTY_MAP), 404, "AdHoc fragment '" + nonExistingAdHocFragment + "' not found in case " + caseId);
}
Aggregations