use of org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilderTest method addReassignReservedOrInProgressOrSuspendedTaskWhenItWasManuallyReassigned.
private void addReassignReservedOrInProgressOrSuspendedTaskWhenItWasManuallyReassigned(Status status, boolean addActualOwnerToSolution) {
TaskData taskData = mockTaskData(TASK_ID, NAME, status, ACTUAL_OWNER_ENTITY_ID);
Task task = fromTaskData(taskData);
User user = mockUser(USER_ENTITY_ID);
task.setUser(user);
List<User> userList = new ArrayList<>();
userList.add(user);
if (addActualOwnerToSolution) {
User actualOwner = mockUser(ACTUAL_OWNER_ENTITY_ID);
userList.add(actualOwner);
}
TaskAssigningSolution solution = mockSolution(Collections.singletonList(task), userList);
List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(mockTaskDataList(taskData)).withUserSystem(userSystemService).withContext(context).build();
assertChangeIsTheChangeSetId(result, 0);
assertChange(result, 1, new AssignTaskProblemFactChange(task, mockUser(ACTUAL_OWNER_ENTITY_ID), true));
assertTaskChangeRegistered(taskData.getTaskId(), taskData.getLastModificationDate());
}
use of org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilderTest method addPinReservedOrInProgressOrSuspendedTaskWhenPublishedAndNotYetPinned.
private void addPinReservedOrInProgressOrSuspendedTaskWhenPublishedAndNotYetPinned(Status status, boolean addActualOwnerToSolution) {
TaskData taskData = mockTaskData(TASK_ID, NAME, status, ACTUAL_OWNER_ENTITY_ID);
PlanningTask planningTask = mockPlanningTask(taskData.getTaskId(), true);
planningTask.setIndex(0);
taskData.setPlanningTask(planningTask);
Task task = fromTaskData(taskData);
task.setPinned(false);
User actualOwner = mockUser(ACTUAL_OWNER_ENTITY_ID);
task.setUser(actualOwner);
List<User> userList = new ArrayList<>();
if (addActualOwnerToSolution) {
userList.add(actualOwner);
}
TaskAssigningSolution solution = mockSolution(Collections.singletonList(task), userList);
List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(mockTaskDataList(taskData)).withUserSystem(userSystemService).withContext(context).build();
assertChangeIsTheChangeSetId(result, 0);
assertChange(result, 1, new AssignTaskProblemFactChange(task, mockUser(ACTUAL_OWNER_ENTITY_ID), true));
assertTaskChangeRegistered(taskData.getTaskId(), taskData.getLastModificationDate());
}
use of org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilderTest method assertChange.
private void assertChange(List<ProblemFactChange<TaskAssigningSolution>> result, int index, AssignTaskProblemFactChange expected) {
AssignTaskProblemFactChange change = (AssignTaskProblemFactChange) result.get(index);
assertTaskEquals(expected.getTask(), change.getTask());
assertUserEquals(expected.getUser(), change.getUser());
}
use of org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilderTest method assertChangeIsTheDummyTaskAssigned.
private void assertChangeIsTheDummyTaskAssigned(List<ProblemFactChange<TaskAssigningSolution>> result, Task dummyTask, int index) {
assertTrue(result.get(index) instanceof AssignTaskProblemFactChange);
AssignTaskProblemFactChange change = (AssignTaskProblemFactChange) result.get(index);
assertEquals(dummyTask, change.getTask());
}
use of org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilder method addNewTaskChanges.
private void addNewTaskChanges(final TaskData taskData, final Map<String, User> usersById, final List<AddTaskProblemFactChange> newTaskChanges, final Map<String, List<IndexedElement<AssignTaskProblemFactChange>>> changesByUserId) {
Task newTask;
final Status taskDataStatus = convertFromString(taskData.getStatus());
switch(taskDataStatus) {
case Ready:
newTask = fromTaskData(taskData);
newTaskChanges.add(new AddTaskProblemFactChange(newTask));
break;
case Reserved:
case InProgress:
case Suspended:
if (taskData.getActualOwner() != null) {
newTask = fromTaskData(taskData);
final User user = getUser(usersById, taskData.getActualOwner());
// assign and ensure the task is published since the task was already seen by the public audience.
AssignTaskProblemFactChange change = new AssignTaskProblemFactChange(newTask, user, true);
addChangeToUser(changesByUserId, change, user, -1, true);
}
break;
default:
// out of the refresh interval, so there's nothing to do with them.
break;
}
}
Aggregations