Search in sources :

Example 11 with PlanningTask

use of org.kie.server.api.model.taskassigning.PlanningTask 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());
}
Also used : PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) Task(org.kie.server.services.taskassigning.core.model.Task) PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) UserUtil.fromExternalUser(org.kie.server.services.taskassigning.planning.util.UserUtil.fromExternalUser) User(org.kie.server.services.taskassigning.core.model.User) AssignTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange) ArrayList(java.util.ArrayList) TaskAssigningSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution) TaskPropertyChangeProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.TaskPropertyChangeProblemFactChange) DisableUserProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.DisableUserProblemFactChange) ReleaseTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange) UserPropertyChangeProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.UserPropertyChangeProblemFactChange) AssignTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange) AddTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AddTaskProblemFactChange) AddUserProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AddUserProblemFactChange) RemoveTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveTaskProblemFactChange) ProblemFactChange(org.optaplanner.core.impl.solver.ProblemFactChange) RemoveUserProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveUserProblemFactChange) TaskData(org.kie.server.api.model.taskassigning.TaskData) TaskUtil.fromTaskData(org.kie.server.services.taskassigning.planning.util.TaskUtil.fromTaskData)

Example 12 with PlanningTask

use of org.kie.server.api.model.taskassigning.PlanningTask in project droolsjbpm-integration by kiegroup.

the class SolutionBuilderTest method buildAndCheckReservedForPlanningUserTaskWithModifiedPlanningTaskNotPublishedWasProcessedCorrect.

@Test
public void buildAndCheckReservedForPlanningUserTaskWithModifiedPlanningTaskNotPublishedWasProcessedCorrect() {
    PlanningTask planningTask = PlanningTask.builder().taskId(1L).assignedUser(USER1).published(false).index(1).build();
    TaskData taskData = mockTaskData(1L, Reserved, PLANNING_USER_ID);
    buildAndCheckTaskWithPlanningTaskWasProcessedCorrect(taskData, planningTask, taskData.getActualOwner(), false);
}
Also used : PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) TaskData(org.kie.server.api.model.taskassigning.TaskData) Test(org.junit.Test)

Example 13 with PlanningTask

use of org.kie.server.api.model.taskassigning.PlanningTask in project droolsjbpm-integration by kiegroup.

the class SolutionBuilderTest method buildAndCheckReservedTaskWithModifiedPlanningTaskPublishedWasProcessedCorrect.

@Test
public void buildAndCheckReservedTaskWithModifiedPlanningTaskPublishedWasProcessedCorrect() {
    PlanningTask planningTask = PlanningTask.builder().taskId(1L).assignedUser(USER1).published(true).index(1).build();
    TaskData taskData = mockTaskData(1L, Reserved, USER2);
    buildAndCheckTaskWithPlanningTaskWasProcessedCorrect(taskData, planningTask, taskData.getActualOwner(), true);
}
Also used : PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) TaskData(org.kie.server.api.model.taskassigning.TaskData) Test(org.junit.Test)

Example 14 with PlanningTask

use of org.kie.server.api.model.taskassigning.PlanningTask in project droolsjbpm-integration by kiegroup.

the class SolutionBuilderTest method buildAnExample.

@Test
public void buildAnExample() {
    PlanningTask planningTask1 = PlanningTask.builder().taskId(1L).assignedUser(USER1).published(false).index(1).build();
    TaskData taskData1 = mockTaskData(1L, Reserved, USER1);
    taskData1.setPlanningTask(planningTask1);
    PlanningTask planningTask2 = PlanningTask.builder().taskId(2L).assignedUser(USER1).published(true).index(2).build();
    TaskData taskData2 = mockTaskData(2L, Suspended, USER1);
    taskData2.setPlanningTask(planningTask2);
    PlanningTask planningTask3 = PlanningTask.builder().taskId(3L).assignedUser(USER1).published(true).index(3).build();
    TaskData taskData3 = mockTaskData(3L, InProgress, USER1);
    taskData3.setPlanningTask(planningTask3);
    PlanningTask planningTask4 = PlanningTask.builder().taskId(4L).assignedUser(USER2).published(false).index(4).build();
    TaskData taskData4 = mockTaskData(4L, InProgress, USER1);
    taskData4.setPlanningTask(planningTask4);
    List<org.kie.server.services.taskassigning.user.system.api.User> externalUsers = buildExternalUsers();
    List<TaskData> taskDataList = Arrays.asList(taskData4, taskData1, taskData3, taskData2);
    TaskAssigningSolution solution = SolutionBuilder.create().withTasks(taskDataList).withUsers(externalUsers).withContext(context).build();
    assertEquals(5, solution.getTaskList().size());
    User user1 = solution.getUserList().stream().filter(user -> user.getEntityId().equals(USER1)).findFirst().orElse(null);
    assertNotNull(user1);
    List<Task> user1Tasks = extractTasks(user1, (task) -> true);
    assertEquals(4L, user1Tasks.size(), 0);
    assertExpectedTaskAtPosition(taskData2.getTaskId(), 0, true, user1Tasks);
    assertExpectedTaskAtPosition(taskData3.getTaskId(), 1, true, user1Tasks);
    assertExpectedTaskAtPosition(taskData4.getTaskId(), 2, true, user1Tasks);
    assertExpectedTaskAtPosition(taskData1.getTaskId(), 3, false, user1Tasks);
    taskDataList.forEach(taskData -> assertTaskChangeWasProcessed(taskData.getTaskId(), taskData.getLastModificationDate()));
}
Also used : PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) Task(org.kie.server.services.taskassigning.core.model.Task) PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) User(org.kie.server.services.taskassigning.core.model.User) TestUtil.mockExternalUser(org.kie.server.services.taskassigning.planning.TestUtil.mockExternalUser) TaskAssigningSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution) TaskData(org.kie.server.api.model.taskassigning.TaskData) Test(org.junit.Test)

Example 15 with PlanningTask

use of org.kie.server.api.model.taskassigning.PlanningTask in project droolsjbpm-integration by kiegroup.

the class SolutionBuilderTest method buildAndCheckInProgressTaskWithUnChangedPlanningTaskNotPublishedWasProcessedCorrect.

@Test
public void buildAndCheckInProgressTaskWithUnChangedPlanningTaskNotPublishedWasProcessedCorrect() {
    PlanningTask planningTask = PlanningTask.builder().taskId(1L).assignedUser(USER1).published(false).index(1).build();
    TaskData taskData = mockTaskData(1L, InProgress, planningTask.getAssignedUser());
    buildAndCheckTaskWithPlanningTaskWasProcessedCorrect(taskData, planningTask, planningTask.getAssignedUser(), true);
}
Also used : PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) TaskData(org.kie.server.api.model.taskassigning.TaskData) Test(org.junit.Test)

Aggregations

PlanningTask (org.kie.server.api.model.taskassigning.PlanningTask)23 TaskData (org.kie.server.api.model.taskassigning.TaskData)20 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)5 PlanningItem (org.kie.server.api.model.taskassigning.PlanningItem)4 Task (org.kie.server.services.taskassigning.core.model.Task)4 List (java.util.List)3 PlanningExecutionResult (org.kie.server.api.model.taskassigning.PlanningExecutionResult)3 PlanningItemList (org.kie.server.api.model.taskassigning.PlanningItemList)3 TaskAssigningSolution (org.kie.server.services.taskassigning.core.model.TaskAssigningSolution)3 User (org.kie.server.services.taskassigning.core.model.User)3 HashMap (java.util.HashMap)2 Status (org.kie.api.task.model.Status)2 StatusConverter.convertFromString (org.kie.server.api.model.taskassigning.util.StatusConverter.convertFromString)2 Arrays (java.util.Arrays)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 StringUtils.isNotEmpty (org.apache.commons.lang3.StringUtils.isNotEmpty)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1