use of org.kie.kogito.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange in project kogito-apps by kiegroup.
the class SolutionChangesBuilderTest method addReleasedTaskChange.
@Test
void addReleasedTaskChange() {
TaskAssignment user1Assignment = new TaskAssignment(mockTask(TASK_1_ID, RESERVED.value()));
User user1 = TestUtil.mockUser(USER_1, Collections.singletonList(user1Assignment));
TaskAssigningSolution solution = mockSolution(Collections.singletonList(user1), Collections.singletonList(user1Assignment));
TaskData taskData = mockTaskData(TASK_1_ID, READY.value(), TASK_1_LAST_UPDATE);
List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withContext(context).withUserServiceConnector(userServiceConnector).withProcessors(processorRegistry).fromTasksData(mockTaskDataList(taskData)).forSolution(solution).build();
assertChangeIsTheChangeSetId(result, 0);
assertChange(result, 1, new ReleaseTaskProblemFactChange(new TaskAssignment(fromTaskData(taskData))));
assertTaskPublishStatus(TASK_1_ID, false);
assertThatTaskProcessorsWhereNotApplied();
assertThatUserProcessorsWereNotApplied();
}
use of org.kie.kogito.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange in project kogito-apps by kiegroup.
the class SolutionChangesBuilderTest method assertChange.
private static void assertChange(List<ProblemFactChange<TaskAssigningSolution>> result, int index, ReleaseTaskProblemFactChange expected) {
assertThat(result.get(index)).isInstanceOf(ReleaseTaskProblemFactChange.class);
ReleaseTaskProblemFactChange change = (ReleaseTaskProblemFactChange) result.get(index);
assertTaskEquals(expected.getTaskAssignment(), change.getTaskAssignment());
}
use of org.kie.kogito.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange in project kogito-apps by kiegroup.
the class SolutionChangesBuilder method addTaskChanges.
private void addTaskChanges(TaskAssignment taskAssignment, TaskData taskData) {
String taskState = taskData.getState();
if (READY.value().equals(taskState)) {
context.setTaskPublished(taskData.getId(), false);
releasedTasksChanges.add(new ReleaseTaskProblemFactChange(taskAssignment));
} else if (RESERVED.value().equals(taskState)) {
context.setTaskPublished(taskData.getId(), true);
if (!taskData.getActualOwner().equals(taskAssignment.getUser().getId()) || !taskAssignment.isPinned()) {
final User user = getUser(usersById.get(taskData.getActualOwner()), taskData.getActualOwner());
AssignTaskProblemFactChange change = new AssignTaskProblemFactChange(taskAssignment, user, true);
addChangeToUser(assignToUserChangesByUserId, change, user, -1, true);
}
} else if (TaskState.isTerminal(taskState)) {
removedTasksSet.add(taskAssignment);
}
if (!removedTasksSet.contains(taskAssignment)) {
Task updatedTask = fromTaskData(taskData);
if (!equalsByTaskInfoProperties(taskAssignment.getTask(), updatedTask)) {
processorRegistry.applyAttributesProcessor(updatedTask, updatedTask.getAttributes());
} else {
updatedTask.setAttributes(taskAssignment.getTask().getAttributes());
}
taskPropertyChanges.add(new TaskInfoChangeProblemFactChange(taskAssignment, updatedTask));
}
}
Aggregations