Search in sources :

Example 1 with PlanningExecutionResult

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

the class TaskAssigningRuntimeServiceBaseTest method unexpectedErrorDuringPlanCalculation.

@Test
public void unexpectedErrorDuringPlanCalculation() {
    when(queryHelper.readTasksDataSummary(anyLong(), any(), anyInt())).thenThrow(new RuntimeException(ERROR_MESSAGE));
    PlanningExecutionResult result = serviceBase.executePlanning(new PlanningItemList(Collections.emptyList()), USER_ID);
    assertHasError(result, PlanningExecutionResult.ErrorCode.UNEXPECTED_ERROR, String.format(UNEXPECTED_ERROR_DURING_PLAN_CALCULATION, ERROR_MESSAGE), null);
}
Also used : PlanningItemList(org.kie.server.api.model.taskassigning.PlanningItemList) PlanningExecutionResult(org.kie.server.api.model.taskassigning.PlanningExecutionResult) Test(org.junit.Test)

Example 2 with PlanningExecutionResult

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

the class TaskAssigningRuntimeServiceBaseTest method executePlanningWithTaskInInProgressOrSuspendedStatusWithActualOwnerUnChanged.

private void executePlanningWithTaskInInProgressOrSuspendedStatusWithActualOwnerUnChanged(Status status) {
    TaskData taskData = mockTaskData(TASK_ID, status, ASSIGNED_USER_ID, 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).execute(eq(CONTAINER_ID), planningCommandCaptor.capture());
    CompositeCommand compositeCommand = (CompositeCommand) planningCommandCaptor.getValue();
    assertSavePlanningItemCommand(compositeCommand.getCommands(), 0, 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) CompositeCommand(org.jbpm.services.task.commands.CompositeCommand)

Example 3 with PlanningExecutionResult

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

the class TaskAssigningRuntimeServiceBaseTest method executePlanningWithTaskInReservedStatusWithNoPlanningTask.

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

Example 4 with PlanningExecutionResult

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

Example 5 with PlanningExecutionResult

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

the class TaskAssigningRuntimeClientImplTest method executePlanningRest.

@Test
public void executePlanningRest() {
    when(config.isRest()).thenReturn(true);
    String expectedUri = SERVER_URL + "/" + TASK_ASSIGNING_RUNTIME_URI + "/" + TASK_ASSIGNING_EXECUTE_PLANNING_URI + "?user=" + USER_ID;
    doReturn(planningExecutionResult).when(runtimeClient).makeHttpPostRequestAndCreateCustomResponse(eq(expectedUri), eq(planningItemList), eq(PlanningExecutionResult.class));
    PlanningExecutionResult result = runtimeClient.executePlanning(planningItemList, USER_ID);
    assertEquals(planningExecutionResult, result);
}
Also used : PlanningExecutionResult(org.kie.server.api.model.taskassigning.PlanningExecutionResult) Test(org.junit.Test)

Aggregations

PlanningExecutionResult (org.kie.server.api.model.taskassigning.PlanningExecutionResult)14 PlanningItemList (org.kie.server.api.model.taskassigning.PlanningItemList)12 Test (org.junit.Test)9 PlanningItem (org.kie.server.api.model.taskassigning.PlanningItem)9 TaskData (org.kie.server.api.model.taskassigning.TaskData)9 StatusConverter.convertToString (org.kie.server.api.model.taskassigning.util.StatusConverter.convertToString)3 CompositeCommand (org.jbpm.services.task.commands.CompositeCommand)2 PlanningTask (org.kie.server.api.model.taskassigning.PlanningTask)2 ApiOperation (io.swagger.annotations.ApiOperation)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Variant (javax.ws.rs.core.Variant)1 Status (org.kie.api.task.model.Status)1 Marshaller (org.kie.server.api.marshalling.Marshaller)1 KieContainerStatus (org.kie.server.api.model.KieContainerStatus)1 Header (org.kie.server.remote.rest.common.Header)1 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)1 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)1