Search in sources :

Example 31 with TaskData

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

the class SolutionChangesBuilderTest method addStatusAndPriorityPropertyChange.

@Test
public void addStatusAndPriorityPropertyChange() {
    TaskData taskData = mockTaskData(TASK_ID, NAME, Reserved, ACTUAL_OWNER_ENTITY_ID);
    User actualOwner = mockUser(ACTUAL_OWNER_ENTITY_ID);
    Task task = fromTaskData(taskData);
    task.setUser(actualOwner);
    task.setPinned(true);
    task.setStatus(convertToString(InProgress));
    task.setPriority(taskData.getPriority() + 1);
    TaskAssigningSolution solution = mockSolution(Collections.singletonList(task), Collections.singletonList(actualOwner));
    List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(mockTaskDataList(taskData)).withUserSystem(userSystemService).withContext(context).build();
    TaskPropertyChangeProblemFactChange change = new TaskPropertyChangeProblemFactChange(task);
    change.setStatus(taskData.getStatus());
    change.setPriority(taskData.getPriority());
    assertChangeIsTheChangeSetId(result, 0);
    assertChange(result, 1, new TaskPropertyChangeProblemFactChange(task));
    assertTaskChangeRegistered(taskData.getTaskId(), taskData.getLastModificationDate());
}
Also used : 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) TaskAssigningSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution) TaskPropertyChangeProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.TaskPropertyChangeProblemFactChange) 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) Test(org.junit.Test)

Example 32 with TaskData

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

the class SolutionChangesBuilderTest method addNewReservedOrInProgressOrSuspendedTaskChangeWithActualOwnerMissing.

private void addNewReservedOrInProgressOrSuspendedTaskChangeWithActualOwnerMissing(Status status) {
    TaskData taskData = mockTaskData(TASK_ID, NAME, status, USER_ENTITY_ID);
    TaskAssigningSolution solution = mockSolution(Collections.emptyList(), Collections.emptyList());
    addNewReservedOrInProgressOrSuspendedTaskChangeWithActualOwner(solution, taskData);
    verify(userSystemService).findUser(USER_ENTITY_ID);
}
Also used : TaskAssigningSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution) TaskData(org.kie.server.api.model.taskassigning.TaskData) TaskUtil.fromTaskData(org.kie.server.services.taskassigning.planning.util.TaskUtil.fromTaskData)

Example 33 with TaskData

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

the class SolutionChangesBuilderTest method addReleasedTaskChange.

@Test
public void addReleasedTaskChange() {
    TaskData taskData = mockTaskData(TASK_ID, NAME, Ready, USER_ENTITY_ID);
    Task task = fromTaskData(taskData);
    task.setStatus(convertToString(Reserved));
    TaskAssigningSolution solution = mockSolution(Collections.singletonList(task), Collections.emptyList());
    List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(mockTaskDataList(taskData)).withUserSystem(userSystemService).withContext(context).build();
    assertChangeIsTheChangeSetId(result, 0);
    assertChange(result, 1, new ReleaseTaskProblemFactChange(task));
    assertTaskChangeRegistered(taskData.getTaskId(), taskData.getLastModificationDate());
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) ReleaseTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange) 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) Test(org.junit.Test)

Example 34 with TaskData

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

the class SolutionChangesBuilderTest method addNewReservedOrInProgressOrSuspendedTaskChangeWithActualOwner.

private void addNewReservedOrInProgressOrSuspendedTaskChangeWithActualOwner(TaskAssigningSolution solution, TaskData taskData) {
    List<TaskData> taskDataList = mockTaskDataList(taskData);
    List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(taskDataList).withUserSystem(userSystemService).withContext(context).build();
    AssignTaskProblemFactChange expected = new AssignTaskProblemFactChange(fromTaskData(taskData), mockUser(USER_ENTITY_ID), true);
    assertChangeIsTheChangeSetId(result, 0);
    assertChange(result, 1, expected);
    assertTaskChangeRegistered(taskData.getTaskId(), taskData.getLastModificationDate());
}
Also used : AssignTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange) 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 35 with TaskData

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

the class SolutionChangesBuilderTest method addRemoveTaskInSinkStatus.

private void addRemoveTaskInSinkStatus(Status sinkStatus) {
    TaskData taskData = mockTaskData(TASK_ID, NAME, sinkStatus, ACTUAL_OWNER_ENTITY_ID);
    User actualOwner = mockUser(ACTUAL_OWNER_ENTITY_ID);
    Task task = fromTaskData(taskData);
    task.setUser(actualOwner);
    task.setStatus(convertToString(Reserved));
    TaskAssigningSolution solution = mockSolution(Collections.singletonList(task), Collections.singletonList(actualOwner));
    List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(mockTaskDataList(taskData)).withUserSystem(userSystemService).withContext(context).build();
    RemoveTaskProblemFactChange change = new RemoveTaskProblemFactChange(task);
    assertChangeIsTheChangeSetId(result, 0);
    assertChange(result, 1, change);
    assertTaskChangeRegistered(taskData.getTaskId(), taskData.getLastModificationDate());
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) RemoveTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveTaskProblemFactChange) UserUtil.fromExternalUser(org.kie.server.services.taskassigning.planning.util.UserUtil.fromExternalUser) User(org.kie.server.services.taskassigning.core.model.User) 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)

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