Search in sources :

Example 21 with PlanningTask

use of org.kie.server.api.model.taskassigning.PlanningTask 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);
}
Also used : PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) PlanningItemList(org.kie.server.api.model.taskassigning.PlanningItemList) PlanningExecutionResult(org.kie.server.api.model.taskassigning.PlanningExecutionResult) StatusConverter.convertToString(org.kie.server.api.model.taskassigning.util.StatusConverter.convertToString) PlanningItem(org.kie.server.api.model.taskassigning.PlanningItem) TaskData(org.kie.server.api.model.taskassigning.TaskData) Test(org.junit.Test)

Example 22 with PlanningTask

use of org.kie.server.api.model.taskassigning.PlanningTask 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);
}
Also used : PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) PlanningItemList(org.kie.server.api.model.taskassigning.PlanningItemList) PlanningExecutionResult(org.kie.server.api.model.taskassigning.PlanningExecutionResult) PlanningItem(org.kie.server.api.model.taskassigning.PlanningItem) TaskData(org.kie.server.api.model.taskassigning.TaskData) Test(org.junit.Test)

Example 23 with PlanningTask

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

the class AbstractTaskAssigningDataQueryMapperTest method createTestValues.

protected List<List<Object>> createTestValues() {
    PlanningTask task1PlanningTask = PlanningTask.builder().taskId(TASK1_PLANNING_TASK_ID).assignedUser(TASK1_PLANNING_TASK_ASSIGNED_USER).index(TASK1_PLANNING_TASK_INDEX).published(TASK1_PLANNING_TASK_PUBLISHED).build();
    List<Pair<String, String>> task1PotentialOwners = Arrays.asList(Pair.of(TASK1_PO_1_ID, TASK1_PO_1_TYPE), Pair.of(TASK1_PO_2_ID, TASK1_PO_2_TYPE));
    List<List<Object>> task1RawValues = mockRawValues(TASK1_ID, TASK1_CREATED_ON, TASK1_ACTUAL_OWNER, TASK1_DEPLOYMENT_ID, TASK1_NAME, TASK1_PRIORITY, TASK1_PROCESS_ID, TASK1_PROCESS_INSTANCE_ID, TASK1_STATUS, TASK1_LAST_MODIFICATION_DATE, task1PlanningTask, task1PotentialOwners);
    PlanningTask task2PlanningTask = PlanningTask.builder().taskId(TASK2_PLANNING_TASK_ID).assignedUser(TASK2_PLANNING_TASK_ASSIGNED_USER).index(TASK2_PLANNING_TASK_INDEX).published(TASK2_PLANNING_TASK_PUBLISHED).build();
    List<List<Object>> task2RawValues = mockRawValues(TASK2_ID, TASK2_CREATED_ON, TASK2_ACTUAL_OWNER, TASK2_DEPLOYMENT_ID, TASK2_NAME, TASK2_PRIORITY, TASK2_PROCESS_ID, TASK2_PROCESS_INSTANCE_ID, TASK2_STATUS, TASK2_LAST_MODIFICATION_DATE, task2PlanningTask, Collections.emptyList());
    List<Pair<String, String>> task3PotentialOwners = Arrays.asList(Pair.of(TASK3_PO_1_ID, TASK3_PO_1_TYPE), Pair.of(TASK3_PO_2_ID, TASK3_PO_2_TYPE));
    List<List<Object>> task3RawValues = mockRawValues(TASK3_ID, TASK3_CREATED_ON, TASK3_ACTUAL_OWNER, TASK3_DEPLOYMENT_ID, TASK3_NAME, TASK3_PRIORITY, TASK3_PROCESS_ID, TASK3_PROCESS_INSTANCE_ID, TASK3_STATUS, TASK3_LAST_MODIFICATION_DATE, null, task3PotentialOwners);
    List<List<Object>> rawValues = new ArrayList<>();
    rawValues.addAll(task1RawValues);
    rawValues.addAll(task2RawValues);
    rawValues.addAll(task3RawValues);
    return rawValues;
}
Also used : PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair)

Aggregations

PlanningTask (org.kie.server.api.model.taskassigning.PlanningTask)23 TaskData (org.kie.server.api.model.taskassigning.TaskData)20 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)5 PlanningItem (org.kie.server.api.model.taskassigning.PlanningItem)4 Task (org.kie.server.services.taskassigning.core.model.Task)4 List (java.util.List)3 PlanningExecutionResult (org.kie.server.api.model.taskassigning.PlanningExecutionResult)3 PlanningItemList (org.kie.server.api.model.taskassigning.PlanningItemList)3 TaskAssigningSolution (org.kie.server.services.taskassigning.core.model.TaskAssigningSolution)3 User (org.kie.server.services.taskassigning.core.model.User)3 HashMap (java.util.HashMap)2 Status (org.kie.api.task.model.Status)2 StatusConverter.convertFromString (org.kie.server.api.model.taskassigning.util.StatusConverter.convertFromString)2 Arrays (java.util.Arrays)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 StringUtils.isNotEmpty (org.apache.commons.lang3.StringUtils.isNotEmpty)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1