use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class DefaultTaskAssigningConstraintProviderTest method prepareTaskAssignment.
private static TaskAssignment prepareTaskAssignment(User user, Task task, int endTimeInMinutes) {
TaskAssignment taskAssignment = prepareTaskAssignment(user, task);
taskAssignment.setEndTimeInMinutes(endTimeInMinutes);
return taskAssignment;
}
use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class SolverTest method assertAssignment.
private void assertAssignment(User user, TaskAssignment taskAssignment, List<User> availableUsers) {
assertThat(taskAssignment.getUser()).isNotNull();
assertThat(taskAssignment.getUser().getId()).as("TaskAssignment: %s is not assigned to expected user: %s ", taskAssignment, user).isEqualTo(user.getId());
Task task = taskAssignment.getTask();
if (task.getPotentialUsers().isEmpty() && task.getPotentialGroups().isEmpty()) {
assertThat(user.getId()).as("TaskAssignment: %s without potentialOwners can only be assigned to the PLANNING_USER", taskAssignment).isEqualTo(PLANNING_USER.getId());
} else if (PLANNING_USER.getId().equals(user.getId())) {
availableUsers.forEach(availableUser -> assertThat(isPotentialOwner(taskAssignment.getTask(), user)).as(String.format("PLANNING_USER user was assigned but another potential owner was found, user: %s taskAssignment: %s", user, taskAssignment)).isFalse());
} else {
assertThat(isPotentialOwner(taskAssignment.getTask(), user)).as(String.format("User: %s is not a potential owner for the taskAssignment: %s", user, taskAssignment)).isTrue();
}
}
use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class TaskHelperTest method filterNonDummyAssignments.
@Test
void filterNonDummyAssignments() {
List<TaskAssignment> taskAssignments = Arrays.asList(new TaskAssignment(Task.newBuilder().id(TASK_ID_1).build()), new TaskAssignment(Task.newBuilder().id(DUMMY_TASK_ASSIGNMENT.getId()).build()), new TaskAssignment(Task.newBuilder().id(TASK_ID_2).build()), new TaskAssignment(Task.newBuilder().id(DUMMY_TASK_ASSIGNMENT_PLANNER_1738.getId()).build()));
List<TaskAssignment> result = TaskHelper.filterNonDummyAssignments(taskAssignments);
assertThat(result).hasSize(2);
assertThat(result.get(0)).isSameAs(taskAssignments.get(0));
assertThat(result.get(1)).isSameAs(taskAssignments.get(2));
}
use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class AssignTaskProblemFactChangeTest method doChangeForNonExistingUserAndNotAddIt.
@Test
void doChangeForNonExistingUserAndNotAddIt() {
User user = new User();
when(scoreDirector.lookUpWorkingObjectOrReturnNull(user)).thenReturn(null);
change = new AssignTaskProblemFactChange(new TaskAssignment(), user, false);
assertThatThrownBy(() -> change.doChange(scoreDirector)).hasMessage("Expected user: %s was not found in current working solution", user);
assertThat(solution.getUserList()).isEmpty();
}
use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class AssignTaskProblemFactChangeTest method doChangeForNewTaskAssignment.
@Test
void doChangeForNewTaskAssignment() {
// Initial assignments:
// User <- TASK_0 <- TASK_1 <- TASK_2 <- TASK_3 <- TASK_4
List<TaskAssignment> userTasks = buildUserTasks();
User user = buildUser(userTasks);
TaskAssignment taskAssignment = mockTaskAssignment(NEW_TASK_ID, false);
when(scoreDirector.lookUpWorkingObjectOrReturnNull(user)).thenReturn(user);
when(scoreDirector.lookUpWorkingObjectOrReturnNull(taskAssignment)).thenReturn(null);
change = new AssignTaskProblemFactChange(taskAssignment, user);
change.doChange(scoreDirector);
assertThat(solution.getTaskAssignmentList()).contains(taskAssignment);
assertPinning(taskAssignment);
verify(scoreDirector).beforeEntityAdded(taskAssignment);
verify(scoreDirector).afterEntityAdded(taskAssignment);
verify(scoreDirector).triggerVariableListeners();
// Expected assignments:
// User <- TASK_0 <- TASK_1 <- TASK_2 <- NEW_TASK_ID <- TASK_3 <- TASK_4
assertTaskPositions(user, userTasks.get(0), userTasks.get(1), taskAssignment, userTasks.get(2), userTasks.get(3), userTasks.get(4));
}
Aggregations