Search in sources :

Example 1 with TaskOrUser

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

the class TestUtil method initializeUser.

public static User initializeUser(User user, List<Task> tasks) {
    TaskOrUser previous = user;
    for (Task task : tasks) {
        previous.setNextTask(task);
        task.setPreviousTaskOrUser(previous);
        task.setUser(user);
        previous = task;
    }
    return user;
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) TaskOrUser(org.kie.server.services.taskassigning.core.model.TaskOrUser)

Example 2 with TaskOrUser

use of org.kie.server.services.taskassigning.core.model.TaskOrUser 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();
    }
}
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) TaskOrUser(org.kie.server.services.taskassigning.core.model.TaskOrUser)

Example 3 with TaskOrUser

use of org.kie.server.services.taskassigning.core.model.TaskOrUser 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 4 with TaskOrUser

use of org.kie.server.services.taskassigning.core.model.TaskOrUser 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 5 with TaskOrUser

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

the class TaskByGroupAndSkillsChangeMoveFilterTest method mockChangeMove.

@SuppressWarnings("unchecked")
private static ChangeMove<TaskAssigningSolution> mockChangeMove(Task task, User user) {
    ChangeMove<TaskAssigningSolution> changeMove = mock(ChangeMove.class);
    TaskOrUser taskOrUser = mock(TaskOrUser.class);
    when(changeMove.getToPlanningValue()).thenReturn(taskOrUser);
    when(taskOrUser.getUser()).thenReturn(user);
    when(changeMove.getEntity()).thenReturn(task);
    return changeMove;
}
Also used : TaskOrUser(org.kie.server.services.taskassigning.core.model.TaskOrUser) TaskAssigningSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution)

Aggregations

TaskOrUser (org.kie.server.services.taskassigning.core.model.TaskOrUser)14 Task (org.kie.server.services.taskassigning.core.model.Task)12 Test (org.junit.Test)3 TaskAssigningSolution (org.kie.server.services.taskassigning.core.model.TaskAssigningSolution)3 User (org.kie.server.services.taskassigning.core.model.User)3 PlanningTask (org.kie.server.api.model.taskassigning.PlanningTask)1 TaskAssigningRuntimeException (org.kie.server.services.taskassigning.core.TaskAssigningRuntimeException)1