use of org.kie.server.services.taskassigning.core.model.Task 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.Task in project droolsjbpm-integration by kiegroup.
the class AddTaskProblemFactChangeTest method addTaskProblemFactChange.
private void addTaskProblemFactChange(TaskAssigningSolution solution, List<Long> taskIds) throws Exception {
solution.getUserList().add(PLANNING_USER);
List<ProgrammedProblemFactChange<AddTaskProblemFactChange>> programmedChanges = taskIds.stream().map(id -> new ProgrammedProblemFactChange<>(new AddTaskProblemFactChange(new Task(id, "NewTask_" + id, 1)))).collect(Collectors.toList());
// each partial solution must have the change that was applied on it.
executeSequentialChanges(solution, programmedChanges);
programmedChanges.forEach(change -> assertAddTaskProblemFactChangeWasProduced(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 -> assertAddTaskProblemFactChangeWasProduced(change.getChange(), lastSolution));
}
use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class AssignTaskProblemFactChangeTest method assertAssignTaskProblemFactChangeWasProduced.
/**
* Given an AssignTaskProblemFactChange and a solution that was produced as the result of applying the change,
* asserts that the assignment defined by the change is not violated (exists in) by the solution.
* The assignment defined in the change must also be pinned in the produced solution as well as any other
* previous assignment for the given user.
* @param change The change that was executed for producing the solution.
* @param solution The produced solution.
*/
private void assertAssignTaskProblemFactChangeWasProduced(AssignTaskProblemFactChange change, TaskAssigningSolution solution) throws Exception {
User internalUser = solution.getUserList().stream().filter(user -> Objects.equals(user.getId(), change.getUser().getId())).findFirst().orElseThrow(() -> new Exception("User: " + change.getUser() + " was not found in solution."));
Task internalTask = solution.getTaskList().stream().filter(task -> Objects.equals(task.getId(), change.getTask().getId())).findFirst().orElseThrow(() -> new Exception("Task: " + change + " was not found in solution."));
assertEquals(internalUser, internalTask.getUser());
assertTrue(internalTask.isPinned());
// all the previous tasks must be pinned by construction and be assigned to the user
TaskOrUser previousTaskOrUser = internalTask.getPreviousTaskOrUser();
while (previousTaskOrUser != null) {
if (previousTaskOrUser instanceof Task) {
Task previousTask = (Task) previousTaskOrUser;
assertTrue(previousTask.isPinned());
assertEquals(internalUser, previousTask.getUser());
previousTaskOrUser = previousTask.getPreviousTaskOrUser();
} else {
assertEquals(internalUser, previousTaskOrUser);
previousTaskOrUser = null;
}
}
// all the next tasks must to the user.
Task nextTask = internalTask.getNextTask();
while (nextTask != null) {
assertEquals(internalUser, nextTask.getUser());
nextTask = nextTask.getNextTask();
}
}
use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class ReleaseTaskProblemFactChangeTest method setUp.
@Before
public void setUp() {
task = new Task();
previousTaskOrUser = spy(new Task());
workingTask = spy(new Task());
nextTask = spy(new Task());
change = new ReleaseTaskProblemFactChange(task);
}
use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class RemoveTaskProblemFactChangeTest method removeTaskProblemFactChange.
private void removeTaskProblemFactChange(TaskAssigningSolution solution, List<Long> taskIds) throws Exception {
List<ProgrammedProblemFactChange<RemoveTaskProblemFactChange>> programmedChanges = taskIds.stream().map(id -> findTaskOrCreate(solution, id)).map(task -> new ProgrammedProblemFactChange<>(new RemoveTaskProblemFactChange(task))).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));
}
Aggregations