Search in sources :

Example 26 with TaskData

use of org.kie.server.api.model.taskassigning.TaskData 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 27 with TaskData

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

the class SolutionBuilderTest method buildAndCheckReadyTaskWasProcessedCorrect.

@Test
public void buildAndCheckReadyTaskWasProcessedCorrect() {
    List<org.kie.server.services.taskassigning.user.system.api.User> externalUsers = buildExternalUsers();
    TaskData taskData = mockTaskData(1L, Ready);
    TaskAssigningSolution solution = SolutionBuilder.create().withTasks(Collections.singletonList(taskData)).withUsers(externalUsers).withContext(context).build();
    assertEquals(2, solution.getTaskList().size());
    assertContainsNotAssignedTask(taskData, solution);
}
Also used : 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 28 with TaskData

use of org.kie.server.api.model.taskassigning.TaskData 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)

Example 29 with TaskData

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

the class SolutionBuilderTest method buildAndCheckSuspendedTaskWithModifiedPlanningTaskNotPublishedWasProcessedCorrect.

@Test
public void buildAndCheckSuspendedTaskWithModifiedPlanningTaskNotPublishedWasProcessedCorrect() {
    PlanningTask planningTask = PlanningTask.builder().taskId(1L).assignedUser(USER1).published(false).index(1).build();
    TaskData taskData = mockTaskData(1L, Suspended, 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 30 with TaskData

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

the class SolutionBuilderTest method buildAndCheckInProgressTaskWithUnChangedPlanningTaskPublishedWasProcessedCorrect.

@Test
public void buildAndCheckInProgressTaskWithUnChangedPlanningTaskPublishedWasProcessedCorrect() {
    PlanningTask planningTask = PlanningTask.builder().taskId(1L).assignedUser(USER1).published(true).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

TaskData (org.kie.server.api.model.taskassigning.TaskData)55 Test (org.junit.Test)30 PlanningTask (org.kie.server.api.model.taskassigning.PlanningTask)26 TaskAssigningSolution (org.kie.server.services.taskassigning.core.model.TaskAssigningSolution)14 TaskUtil.fromTaskData (org.kie.server.services.taskassigning.planning.util.TaskUtil.fromTaskData)13 PlanningExecutionResult (org.kie.server.api.model.taskassigning.PlanningExecutionResult)10 PlanningItemList (org.kie.server.api.model.taskassigning.PlanningItemList)10 Task (org.kie.server.services.taskassigning.core.model.Task)10 AddTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AddTaskProblemFactChange)10 AddUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AddUserProblemFactChange)10 AssignTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange)10 DisableUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.DisableUserProblemFactChange)10 ReleaseTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange)10 RemoveTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveTaskProblemFactChange)10 RemoveUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveUserProblemFactChange)10 TaskPropertyChangeProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.TaskPropertyChangeProblemFactChange)10 UserPropertyChangeProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.UserPropertyChangeProblemFactChange)10 ProblemFactChange (org.optaplanner.core.impl.solver.ProblemFactChange)10 PlanningItem (org.kie.server.api.model.taskassigning.PlanningItem)9 ArrayList (java.util.ArrayList)8