Search in sources :

Example 11 with PlanningItemList

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

the class TaskAssigningRuntimeServiceBaseTest method executePlanningWithDetachedTask.

private void executePlanningWithDetachedTask(Status status) {
    TaskData taskData = mockTaskData(TASK_ID, status, ASSIGNED_USER_ID, CONTAINER_ID, mockPlanningTask(TASK_ID, ASSIGNED_USER_ID));
    List<TaskData> taskDataList = Collections.singletonList(taskData);
    PlanningItemList planningItemList = new PlanningItemList(Collections.emptyList());
    prepareExecution(taskDataList, CONTAINER_ID);
    PlanningExecutionResult result = serviceBase.executePlanning(planningItemList, USER_ID);
    verify(userTaskService).execute(eq(CONTAINER_ID), planningCommandCaptor.capture());
    CompositeCommand compositeCommand = (CompositeCommand) planningCommandCaptor.getValue();
    assertDeletePlanningItemCommand(compositeCommand.getCommands(), 0, TASK_ID);
    assertNoError(result);
}
Also used : PlanningItemList(org.kie.server.api.model.taskassigning.PlanningItemList) PlanningExecutionResult(org.kie.server.api.model.taskassigning.PlanningExecutionResult) TaskData(org.kie.server.api.model.taskassigning.TaskData) CompositeCommand(org.jbpm.services.task.commands.CompositeCommand)

Example 12 with PlanningItemList

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

the class TaskAssigningRuntimeServiceBaseTest method executePlanningWithTaskNoLongerInActiveStatus.

@Test
public void executePlanningWithTaskNoLongerInActiveStatus() {
    List<TaskData> taskDataList = Collections.emptyList();
    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);
    String errorMessage = String.format(TASK_MODIFIED_ERROR_MSG_3, planningItem.getPlanningTask().getTaskId(), Arrays.toString(new Status[] { Ready, Reserved, InProgress, Suspended }));
    assertHasError(result, PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR, errorMessage, CONTAINER_ID);
}
Also used : Status(org.kie.api.task.model.Status) KieContainerStatus(org.kie.server.api.model.KieContainerStatus) 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 13 with PlanningItemList

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

the class TaskAssigningRuntimeServiceBaseTest method unexpectedErrorDuringPlanExecution.

@Test
public void unexpectedErrorDuringPlanExecution() {
    TaskData taskData = mockTaskData(TASK_ID, Ready);
    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);
    when(userTaskService.execute(eq(CONTAINER_ID), any())).thenThrow(new RuntimeException(ERROR_MESSAGE));
    PlanningExecutionResult result = serviceBase.executePlanning(planningItemList, USER_ID);
    assertHasError(result, PlanningExecutionResult.ErrorCode.UNEXPECTED_ERROR, String.format(UNEXPECTED_ERROR_DURING_PLAN_EXECUTION, CONTAINER_ID, ERROR_MESSAGE), CONTAINER_ID);
}
Also used : 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 14 with PlanningItemList

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

the class TaskAssigningRuntimeServiceBaseTest method executePlanningWithTaskInReadyStatus.

@Test
public void executePlanningWithTaskInReadyStatus() {
    TaskData taskData = mockTaskData(TASK_ID, Ready);
    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 : 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)

Aggregations

PlanningItemList (org.kie.server.api.model.taskassigning.PlanningItemList)14 PlanningExecutionResult (org.kie.server.api.model.taskassigning.PlanningExecutionResult)13 TaskData (org.kie.server.api.model.taskassigning.TaskData)10 PlanningItem (org.kie.server.api.model.taskassigning.PlanningItem)9 Test (org.junit.Test)8 CompositeCommand (org.jbpm.services.task.commands.CompositeCommand)3 PlanningTask (org.kie.server.api.model.taskassigning.PlanningTask)3 StatusConverter.convertToString (org.kie.server.api.model.taskassigning.util.StatusConverter.convertToString)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 StopWatch (org.apache.commons.lang3.time.StopWatch)2 Status (org.kie.api.task.model.Status)2 KieServicesException (org.kie.server.api.exception.KieServicesException)2 KieContainerStatus (org.kie.server.api.model.KieContainerStatus)2 StatusConverter.convertFromString (org.kie.server.api.model.taskassigning.util.StatusConverter.convertFromString)2 StatusConverter.convertToStringList (org.kie.server.api.model.taskassigning.util.StatusConverter.convertToStringList)2 PlanningException (org.kie.server.services.taskassigning.runtime.command.PlanningException)2 ApiOperation (io.swagger.annotations.ApiOperation)1