use of org.jbpm.services.task.impl.model.GroupImpl in project jbpm by kiegroup.
the class TaskFluent method setAdminGroup.
public TaskFluent setAdminGroup(String groupId) {
if (assignments.getBusinessAdministrators().isEmpty()) {
List<OrganizationalEntity> businessAdmins = new ArrayList<OrganizationalEntity>();
assignments.setBusinessAdministrators(businessAdmins);
}
assignments.getBusinessAdministrators().add(new GroupImpl(groupId));
return this;
}
use of org.jbpm.services.task.impl.model.GroupImpl in project jbpm by kiegroup.
the class CaseServiceImplTest method testInclusiveGatewayWithDynamicActivity.
@Test
public void testInclusiveGatewayWithDynamicActivity() {
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(), "InclusiveGatewayCase", data, roleAssignments);
((CaseAssignment) caseFile).assignUser("generalRole", "john");
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), "InclusiveGatewayCase", 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, "john", null, new QueryContext());
assertThat(tasks).hasSize(2);
caseService.addDynamicTask(caseId, caseService.newHumanTaskSpec("First task", "another test", "actorRole", null, new HashMap<>()));
List<TaskSummary> allTasks = caseRuntimeDataService.getCaseTasksAssignedAsPotentialOwner(caseId, "john", null, new QueryContext());
assertThat(allTasks).hasSize(3);
// now complete only tasks from case definition and leave dynamic task alone
for (TaskSummary task : tasks) {
userTaskService.completeAutoProgress(task.getId(), "john", null);
}
// dynamic task should still be there
allTasks = caseRuntimeDataService.getCaseTasksAssignedAsPotentialOwner(caseId, "john", null, new QueryContext());
assertThat(allTasks).hasSize(1);
cInstance = caseService.getCaseInstance(caseId);
assertNotNull(cInstance);
} 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.services.task.impl.model.GroupImpl in project jbpm by kiegroup.
the class CaseServiceImplTest method testCaseRolesWithQueries.
@Test
public void testCaseRolesWithQueries() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("owner", new UserImpl("john"));
roleAssignments.put("contact", new GroupImpl("HR"));
Map<String, Object> data = new HashMap<>();
data.put("s", "description");
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), USER_TASK_CASE_P_ID, data, roleAssignments);
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), USER_TASK_CASE_P_ID, caseFile);
assertNotNull(caseId);
assertEquals(HR_CASE_ID, caseId);
try {
CaseInstance cInstance = caseService.getCaseInstance(caseId);
assertNotNull(cInstance);
assertEquals(HR_CASE_ID, cInstance.getCaseId());
assertEquals(CaseStatus.OPEN.getId(), cInstance.getStatus().intValue());
assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId());
// only john is now included in case roles
Collection<CaseInstance> instances = caseRuntimeDataService.getCaseInstancesAnyRole(null, new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
List<CaseStatus> status = Arrays.asList(CaseStatus.CANCELLED);
instances = caseRuntimeDataService.getCaseInstancesAnyRole(status, new QueryContext());
assertNotNull(instances);
assertFalse("Opened case was returned when searching for cancelled case instances.", instances.stream().anyMatch(n -> n.getCaseId().equals(caseId)));
status = Arrays.asList(CaseStatus.OPEN);
instances = caseRuntimeDataService.getCaseInstancesAnyRole(status, new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
instances = caseRuntimeDataService.getCaseInstancesByRole(null, status, new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
instances = caseRuntimeDataService.getCaseInstancesByRole("owner", status, new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
identityProvider.setName("mary");
instances = caseRuntimeDataService.getCaseInstancesByRole("owner", status, new QueryContext());
assertNotNull(instances);
assertEquals("Mary shouldn't be owner of any opened case instance.", 0, instances.size());
identityProvider.setRoles(Arrays.asList("HR"));
instances = caseRuntimeDataService.getCaseInstancesByRole("contact", status, new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
} catch (Exception e) {
logger.error("Unexpected error {}", e.getMessage(), e);
fail("Unexpected exception " + e.getMessage());
} finally {
identityProvider.setName("john");
if (caseId != null) {
caseService.cancelCase(caseId);
}
}
}
use of org.jbpm.services.task.impl.model.GroupImpl in project jbpm by kiegroup.
the class CaseAssignmentServiceImplTest method testProperRoleAssignedAutoStart.
@Test
public void testProperRoleAssignedAutoStart() {
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");
((CaseAssignment) caseFile).assignUser("generalRole", "john");
String caseId = caseService.startCase(deploymentUnit.getIdentifier(), CASE_X_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());
} 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.services.task.impl.model.GroupImpl in project jbpm by kiegroup.
the class CaseAssignmentServiceImplTest method testRoleAssignedMissingRole.
@Test
public void testRoleAssignedMissingRole() {
Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
roleAssignments.put("groupRole", new GroupImpl("managers"));
Map<String, Object> data = new HashMap<>();
CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), CASE_Y_P_ID, data, roleAssignments);
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> {
caseService.startCase(deploymentUnit.getIdentifier(), CASE_Y_P_ID, caseFile);
}).withMessageContaining("Case role 'actorRole' has no matching assignments");
}
Aggregations