use of org.kie.server.api.model.taskassigning.PlanningItem in project droolsjbpm-integration by kiegroup.
the class PlanningBuilderTest method build.
@Test
public void build() {
List<Task> user1Tasks = mockTasks(USER1_TOTAL_TASKS, USER1_PINNED_TASKS, "container1", 1L);
User user1 = mockUser(1, user1Tasks);
List<Task> user2Tasks = mockTasks(USER2_TOTAL_TASKS, USER2_PINNED_TASKS, "container2", 2L);
User user2 = mockUser(2, user2Tasks);
List<Task> user3Tasks = mockTasks(USER3_TOTAL_TASKS, USER3_PINNED_TASKS, "container3", 3L);
User user3 = mockUser(3, user3Tasks);
List<Task> user4Tasks = mockTasks(USER4_TOTAL_TASKS, USER4_PINNED_TASKS, "container4", 4L);
User user4 = mockUser(4, user4Tasks);
List<Task> user5Tasks = mockTasks(USER5_TOTAL_TASKS, USER5_PINNED_TASKS, "container5", 5L);
User user5 = mockUser(5, user5Tasks);
List<Task> user6Tasks = mockTasks(USER6_TOTAL_TASKS, USER6_PINNED_TASKS, "container6", 6L);
User user6 = mockUser(6, user6Tasks);
List<Task> planningUserTasks = mockTasks(PLANNING_USER_TASKS, 0, "container7", 7L);
User planningUser = initializeUser(new User(-1, PLANNING_USER_ID), planningUserTasks);
List<Task> totalTasks = new ArrayList<>();
totalTasks.addAll(user1Tasks);
totalTasks.addAll(user2Tasks);
totalTasks.addAll(user3Tasks);
totalTasks.addAll(user4Tasks);
totalTasks.addAll(user5Tasks);
totalTasks.addAll(user6Tasks);
totalTasks.addAll(planningUserTasks);
List<User> totalUsers = Arrays.asList(user1, user2, user3, user4, user5, user6, planningUser);
TaskAssigningSolution solution = new TaskAssigningSolution(1, totalUsers, totalTasks);
List<PlanningItem> planningItems = PlanningBuilder.create().withPublishWindowSize(publishWindowSize).withSolution(solution).build();
assertPlanningItems(user1, publishWindowSize, planningItems);
assertPlanningItems(user2, publishWindowSize, planningItems);
assertPlanningItems(user3, publishWindowSize, planningItems);
assertPlanningItems(user4, publishWindowSize, planningItems);
assertPlanningItems(user5, publishWindowSize, planningItems);
assertPlanningItems(user6, publishWindowSize, planningItems);
assertPlanningUserPlanningItems(planningUser, publishWindowSize, planningItems);
}
use of org.kie.server.api.model.taskassigning.PlanningItem in project droolsjbpm-integration by kiegroup.
the class SolutionProcessor method doProcess.
protected void doProcess(final TaskAssigningSolution solution) {
LOGGER.debug("Starting processing of solution: {}", solution);
final List<PlanningItem> publishedTasks = buildPlanning(solution, publishWindowSize);
if (LOGGER.isTraceEnabled()) {
traceSolution(LOGGER, solution);
tracePublishedTasks(LOGGER, publishedTasks);
}
Result result;
try {
PlanningExecutionResult executeResult = delegate.executePlanning(publishedTasks, targetUserId);
result = new Result(executeResult);
} catch (Exception e) {
LOGGER.error("An error was produced during solution processing, planning execution failed.", e);
result = new Result(e);
}
LOGGER.debug("Solution processing finished: {}", solution);
if (isAlive()) {
resultConsumer.accept(result);
status.compareAndSet(STARTED, STOPPED);
}
}
use of org.kie.server.api.model.taskassigning.PlanningItem in project droolsjbpm-integration by kiegroup.
the class TaskAssigningRuntimeServiceBaseTest method executePlanningWithTaskInInProgressOrSuspendedStatusWithActualOwnerChanged.
private void executePlanningWithTaskInInProgressOrSuspendedStatusWithActualOwnerChanged(Status status) {
TaskData taskData = mockTaskData(TASK_ID, status, PREVIOUS_ASSIGNED_USER_ID_CHANGED, null);
List<TaskData> taskDataList = Collections.singletonList(taskData);
PlanningItem planningItem = mockPlanningItem(TASK_ID, CONTAINER_ID, ASSIGNED_USER_ID);
PlanningItemList planningItemList = new PlanningItemList(Collections.singletonList(planningItem));
prepareExecution(taskDataList, CONTAINER_ID);
PlanningExecutionResult result = serviceBase.executePlanning(planningItemList, USER_ID);
verify(userTaskService, never()).execute(eq(CONTAINER_ID), any());
String errorMessage = String.format(TASK_MODIFIED_ERROR_MSG_2, planningItem.getPlanningTask().getTaskId(), PREVIOUS_ASSIGNED_USER_ID_CHANGED, ASSIGNED_USER_ID);
assertHasError(result, PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR, errorMessage, CONTAINER_ID);
}
use of org.kie.server.api.model.taskassigning.PlanningItem in project droolsjbpm-integration by kiegroup.
the class TaskAssigningRuntimeServiceBaseTest method executePlanningWithTaskInReservedStatusWithPlanningTaskButReassigned.
@Test
public void executePlanningWithTaskInReservedStatusWithPlanningTaskButReassigned() {
PlanningTask planningTask = mockPlanningTask(TASK_ID, PREVIOUS_ASSIGNED_USER_ID);
TaskData taskData = mockTaskData(TASK_ID, Reserved, PREVIOUS_ASSIGNED_USER_ID_CHANGED, planningTask);
List<TaskData> taskDataList = Collections.singletonList(taskData);
PlanningItem planningItem = mockPlanningItem(TASK_ID, CONTAINER_ID, ASSIGNED_USER_ID);
PlanningItemList planningItemList = new PlanningItemList(Collections.singletonList(planningItem));
prepareExecution(taskDataList, CONTAINER_ID);
PlanningExecutionResult result = serviceBase.executePlanning(planningItemList, USER_ID);
verify(userTaskService, never()).execute(eq(CONTAINER_ID), any());
String errorMessage = String.format(TASK_MODIFIED_ERROR_MSG_1, taskData.getTaskId(), PREVIOUS_ASSIGNED_USER_ID_CHANGED, PREVIOUS_ASSIGNED_USER_ID);
assertHasError(result, PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR, errorMessage, CONTAINER_ID);
}
use of org.kie.server.api.model.taskassigning.PlanningItem in project droolsjbpm-integration by kiegroup.
the class TaskAssigningRuntimeServiceBaseTest method executePlanningWithTaskInReservedStatusWithPlanningTaskDontReassigned.
@Test
public void executePlanningWithTaskInReservedStatusWithPlanningTaskDontReassigned() {
PlanningTask planningTask = mockPlanningTask(TASK_ID, PREVIOUS_ASSIGNED_USER_ID);
TaskData taskData = mockTaskData(TASK_ID, Reserved, PREVIOUS_ASSIGNED_USER_ID, planningTask);
List<TaskData> taskDataList = Collections.singletonList(taskData);
PlanningItem planningItem = mockPlanningItem(TASK_ID, CONTAINER_ID, ASSIGNED_USER_ID);
PlanningItemList planningItemList = new PlanningItemList(Collections.singletonList(planningItem));
prepareExecution(taskDataList, CONTAINER_ID);
PlanningExecutionResult result = serviceBase.executePlanning(planningItemList, USER_ID);
verify(userTaskService).execute(eq(CONTAINER_ID), planningCommandCaptor.capture());
assertDelegateAndSaveCommand(planningCommandCaptor.getAllValues(), 0, USER_ID, planningItem);
assertNoError(result);
}
Aggregations