Search in sources :

Example 21 with Task

use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.

the class StartAndEndTimeUpdatingVariableListenerTest method setUp.

@Before
public void setUp() {
    listener = new StartAndEndTimeUpdatingVariableListener();
    anchor = new User(1, "User1");
    task1 = new Task(1, "Task1", 1);
    task1.setStartTimeInMinutes(anchor.getEndTimeInMinutes());
    task1.setDurationInMinutes(1);
    task1.setEndTime(task1.getStartTimeInMinutes() + task1.getDurationInMinutes());
    task1.setPreviousTaskOrUser(anchor);
    task2 = new Task(2, "Task2", 1);
    task2.setDurationInMinutes(2);
    task2.setPreviousTaskOrUser(task1);
    task2.setStartTimeInMinutes(task1.getEndTimeInMinutes());
    task2.setEndTime(task2.getStartTimeInMinutes() + task2.getDurationInMinutes());
    task1.setNextTask(task2);
    task3 = new Task(3, "Task3", 1);
    task3.setDurationInMinutes(3);
    task3.setPreviousTaskOrUser(task2);
    task4 = new Task(4, "Task4", 1);
    task4.setDurationInMinutes(4);
    task4.setPreviousTaskOrUser(task3);
    task3.setNextTask(task4);
    task5 = new Task(5, "Task5", 1);
    task5.setDurationInMinutes(5);
    task5.setPreviousTaskOrUser(task4);
    task4.setNextTask(task5);
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) User(org.kie.server.services.taskassigning.core.model.User) StartAndEndTimeUpdatingVariableListener(org.kie.server.services.taskassigning.core.model.solver.StartAndEndTimeUpdatingVariableListener) Before(org.junit.Before)

Example 22 with Task

use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.

the class TaskHelperTest method extractTasksFiltered.

@Test
public void extractTasksFiltered() {
    TaskOrUser taskOrUser = buildTaskOrUser();
    List<Task> result = TaskHelper.extractTasks(taskOrUser, testedTask -> testedTask.getId() == 1 || testedTask.getId() == 4);
    assertThat(result.size()).isEqualTo(2);
    assertThat(result.get(0).getId()).isEqualTo(1);
    assertThat(result.get(1).getId()).isEqualTo(4);
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) TaskOrUser(org.kie.server.services.taskassigning.core.model.TaskOrUser) Test(org.junit.Test)

Example 23 with Task

use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.

the class TaskHelperTest method extractTasks.

@Test
public void extractTasks() {
    TaskOrUser taskOrUser = buildTaskOrUser();
    List<Task> result = TaskHelper.extractTasks(taskOrUser);
    assertThat(result.size()).isEqualTo(4);
    assertThat(result.get(0).getId()).isEqualTo(1);
    assertThat(result.get(1).getId()).isEqualTo(2);
    assertThat(result.get(2).getId()).isEqualTo(3);
    assertThat(result.get(3).getId()).isEqualTo(4);
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) TaskOrUser(org.kie.server.services.taskassigning.core.model.TaskOrUser) Test(org.junit.Test)

Example 24 with Task

use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.

the class TaskHelperTest method isPotentialOwnerOfTaskWithGroupsAndUserNoGroups.

@Test
public void isPotentialOwnerOfTaskWithGroupsAndUserNoGroups() {
    Task task = new Task();
    task.getPotentialOwners().add(availableGroups.get(0));
    User user = availableUsers.get(0);
    assertThat(isPotentialOwner(task, user)).isFalse();
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) TaskOrUser(org.kie.server.services.taskassigning.core.model.TaskOrUser) User(org.kie.server.services.taskassigning.core.model.User) Test(org.junit.Test)

Example 25 with Task

use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.

the class TestSolver method assertConstraints.

/**
 * Given a TaskAssigningSolution asserts the following constraints.
 * <p>
 * 1) All tasks are assigned to a user
 * 2) The assigned user for a task is a potentialOwner for the task or the PLANNING_USER
 * 3) All tasks are assigned.
 * @param solution a solution.
 */
private void assertConstraints(TaskAssigningSolution solution) {
    int totalTasks = 0;
    for (User user : solution.getUserList()) {
        List<Task> taskList = extractTasks(user);
        totalTasks += taskList.size();
        taskList.forEach(task -> assertAssignment(user, task, solution.getUserList()));
    }
    assertEquals(solution.getTaskList().size(), totalTasks);
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) User(org.kie.server.services.taskassigning.core.model.User)

Aggregations

Task (org.kie.server.services.taskassigning.core.model.Task)63 User (org.kie.server.services.taskassigning.core.model.User)32 Test (org.junit.Test)26 TaskAssigningSolution (org.kie.server.services.taskassigning.core.model.TaskAssigningSolution)23 TaskOrUser (org.kie.server.services.taskassigning.core.model.TaskOrUser)21 PlanningTask (org.kie.server.api.model.taskassigning.PlanningTask)15 ArrayList (java.util.ArrayList)14 TaskPropertyChangeProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.TaskPropertyChangeProblemFactChange)12 ProblemFactChange (org.optaplanner.core.impl.solver.ProblemFactChange)12 AddTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AddTaskProblemFactChange)11 AssignTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange)11 TaskData (org.kie.server.api.model.taskassigning.TaskData)10 AddUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AddUserProblemFactChange)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 UserPropertyChangeProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.UserPropertyChangeProblemFactChange)10 TaskUtil.fromTaskData (org.kie.server.services.taskassigning.planning.util.TaskUtil.fromTaskData)8 UserUtil.fromExternalUser (org.kie.server.services.taskassigning.planning.util.UserUtil.fromExternalUser)8