use of org.optaplanner.core.api.solver.ProblemFactChange 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();
}
use of org.optaplanner.core.api.solver.ProblemFactChange in project kogito-apps by kiegroup.
the class SolutionChangesBuilderTest method addReservedTaskChangeForAnotherUser.
private void addReservedTaskChangeForAnotherUser(TaskAssigningSolution solution, TaskData taskData, User user) {
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 AssignTaskProblemFactChange(new TaskAssignment(fromTaskData(taskData)), user, true));
assertTaskPublishStatus(TASK_1_ID, true);
assertThatTaskProcessorsWhereNotApplied();
}
use of org.optaplanner.core.api.solver.ProblemFactChange in project kogito-apps by kiegroup.
the class SolutionChangesBuilderTest method addNewUserChange.
@Test
void addNewUserChange() {
org.kie.kogito.taskassigning.user.service.User newExternalUser = mockExternalUser(USER_1);
User newUser = mockUser(USER_1);
TaskAssigningSolution solution = mockSolution(Collections.emptyList(), Collections.emptyList());
UserDataEvent event = new UserDataEvent(Collections.singletonList(newExternalUser), ZonedDateTime.now());
List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withContext(context).withUserServiceConnector(userServiceConnector).withProcessors(processorRegistry).fromTasksData(Collections.emptyList()).fromUserDataEvent(event).forSolution(solution).build();
AddUserProblemFactChange expected = new AddUserProblemFactChange(newUser);
assertChangeIsTheChangeSetId(result, 0);
assertChange(result, 1, expected);
assertThatUserProcessorsWereApplied(newExternalUser);
}
use of org.optaplanner.core.api.solver.ProblemFactChange 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.optaplanner.core.api.solver.ProblemFactChange in project kogito-apps by kiegroup.
the class SolutionChangesBuilderTest method addNewReservedTaskChangeWithActualOwner.
private void addNewReservedTaskChangeWithActualOwner(TaskAssigningSolution solution, TaskData taskData) {
List<TaskData> taskDataList = mockTaskDataList(taskData);
List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withContext(context).withUserServiceConnector(userServiceConnector).withProcessors(processorRegistry).fromTasksData(taskDataList).forSolution(solution).build();
AssignTaskProblemFactChange expected = new AssignTaskProblemFactChange(new TaskAssignment(fromTaskData(taskData)), mockUser(USER_1), true);
assertChangeIsTheChangeSetId(result, 0);
assertChange(result, 1, expected);
assertTaskPublishStatus(taskData.getId(), true);
assertThatTaskProcessorsWereApplied(taskData.getId());
}
Aggregations