use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class RemoveTaskExecutableProblemFactChangeTest method removeTaskProblemFactChange.
private void removeTaskProblemFactChange(TaskAssigningSolution solution, List<String> taskIds) {
List<ProgrammedProblemFactChange<RemoveTaskProblemFactChange>> programmedChanges = taskIds.stream().map(id -> findTaskAssignmentOrCreate(solution, id)).map(taskAssignment -> new ProgrammedProblemFactChange<>(new RemoveTaskProblemFactChange(taskAssignment))).collect(Collectors.toList());
// each partial solution must have the change that was applied on it.
executeSequentialChanges(solution, programmedChanges);
programmedChanges.forEach(change -> assertRemoveTaskProblemFactChangeWasProduced(change.getChange(), change.getSolutionAfterChange()));
// finally the last solution must have the result of all the changes.
TaskAssigningSolution lastSolution = programmedChanges.get(programmedChanges.size() - 1).getSolutionAfterChange();
programmedChanges.forEach(change -> assertRemoveTaskProblemFactChangeWasProduced(change.getChange(), lastSolution));
}
use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class SolutionBuilderTest method assertThatTaskProcessorsWereApplied.
public static void assertThatTaskProcessorsWereApplied(TaskAssigningSolution solution, AttributesProcessorRegistry processorRegistry, String... taskIds) {
for (String taskId : taskIds) {
TaskAssignment taskAssignment = solution.getTaskAssignmentList().stream().filter(ta -> taskId.equals(ta.getId())).findFirst().orElseThrow(() -> new RuntimeException("Expected task was not found in solution, taskId:" + taskId));
verify(processorRegistry).applyAttributesProcessor(eq(taskAssignment.getTask()), any());
}
}
use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class SolutionBuilderTest method assertThatTaskIsAssignedToUser.
private void assertThatTaskIsAssignedToUser(TaskAssigningSolution solution, String taskId, String userId) {
TaskAssignment taskAssignment = solution.getTaskAssignmentList().stream().filter(ta -> taskId.equals(ta.getId())).findFirst().orElse(null);
assertThat(taskAssignment).withFailMessage("Task %s is not present in solution.", taskId).isNotNull();
User user = solution.getUserList().stream().filter(u -> userId.equals(u.getId())).findFirst().orElse(null);
assertThat(user).withFailMessage("User %s is not present in solution.", userId).isNotNull();
assertThat(taskAssignment.getUser()).withFailMessage("Task %s must be assigned to user %s but is assigned to nobody.", taskId, userId).isNotNull();
assertThat(taskAssignment.getUser().getId()).withFailMessage("Task %s must be assigned to user %s.", taskId, userId).isEqualTo(userId);
}
use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class SolutionChangesBuilderTest method addReservedTaskChangeForSameUserButNotPinned.
@Test
void addReservedTaskChangeForSameUserButNotPinned() {
TaskAssignment user1Assignment = new TaskAssignment(mockTask(TASK_1_ID));
User user1 = TestUtil.mockUser(USER_1, Collections.singletonList(user1Assignment));
user1Assignment.setPinned(false);
TaskAssigningSolution solution = mockSolution(Collections.singletonList(user1), Collections.singletonList(user1Assignment));
TaskData taskData = mockTaskData(TASK_1_ID, RESERVED.value(), USER_1, TASK_1_LAST_UPDATE);
addReservedTaskChangeForAnotherUser(solution, taskData, user1);
assertThatTaskProcessorsWhereNotApplied();
assertThatUserProcessorsWereNotApplied();
}
use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.
the class SolutionChangesBuilderTest method addNewReadyTaskChange.
@Test
void addNewReadyTaskChange() {
TaskData taskData = mockTaskData(TASK_1_ID, READY.value(), TASK_1_LAST_UPDATE);
List<TaskData> taskDataList = mockTaskDataList(taskData);
TaskAssigningSolution solution = mockSolution(Collections.emptyList(), Collections.emptyList());
List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withContext(context).withUserServiceConnector(userServiceConnector).withProcessors(processorRegistry).fromTasksData(taskDataList).forSolution(solution).build();
AddTaskProblemFactChange expected = new AddTaskProblemFactChange(new TaskAssignment(fromTaskData(taskData)));
assertChangeIsTheChangeSetId(result, 0);
assertChange(result, 1, expected);
assertTaskPublishStatus(taskData.getId(), false);
assertThatTaskProcessorsWereApplied(TASK_1_ID);
assertThatUserProcessorsWereNotApplied();
}
Aggregations