@Test public void execute() { if (statusIsValid) { executeWithValidStatus(status, potentialOwnerBelongsToTask, previousPlanningTask); if (potentialOwnerBelongsToTask) { assertThat(potentialOwners).contains(organizationalEntity); } else { assertThat(potentialOwners).doesNotContain(organizationalEntity); } } else { executeWithInvalidStatus(status, previousPlanningTask); } }
@Override public Void execute(Context context) { super.execute(context); final Task task = taskContext.getPersistenceContext().findTask(planningItem.getTaskId()); if (task == null) { throw new PlanningException(String.format(TASK_MODIFIED_ERROR_MSG_1, planningItem.getTaskId()), planningItem.getContainerId(), PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR); } final org.kie.api.task.model.TaskData taskData = task.getTaskData(); final Status status = taskData.getStatus(); if (!(Ready == status || Reserved == status)) { throw new PlanningException(String.format(TASK_MODIFIED_ERROR_MSG, planningItem.getTaskId(), status, Arrays.toString(new Status[]{Ready, Reserved})), planningItem.getContainerId(), PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR); } final OrganizationalEntity existingPotentialOwner = findPotentialOwner(task, planningItem.getPlanningTask().getAssignedUser()); DelegateTaskCommand delegateTaskCommand = createDelegateCommand(planningItem.getTaskId(), getUserId(), planningItem.getPlanningTask().getAssignedUser()); delegateTaskCommand.execute(context); if (existingPotentialOwner == null) { OrganizationalEntity addedPotentialOwner = findPotentialOwner(task, planningItem.getPlanningTask().getAssignedUser()); if (addedPotentialOwner != null) { task.getPeopleAssignments().getPotentialOwners().remove(addedPotentialOwner); } } saveOrUpdatePlanningTask(planningItem); return null; }
DelegateAndSaveCommand extends PlanningCommand { @Override public Void execute(Context context) { super.execute(context); final Task task = taskContext.getPersistenceContext().findTask(planningItem.getTaskId()); if (task == null) { throw new PlanningException(String.format(TASK_MODIFIED_ERROR_MSG_1, planningItem.getTaskId()), planningItem.getContainerId(), PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR); } final org.kie.api.task.model.TaskData taskData = task.getTaskData(); final Status status = taskData.getStatus(); if (!(Ready == status || Reserved == status)) { throw new PlanningException(String.format(TASK_MODIFIED_ERROR_MSG, planningItem.getTaskId(), status, Arrays.toString(new Status[]{Ready, Reserved})), planningItem.getContainerId(), PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR); } final OrganizationalEntity existingPotentialOwner = findPotentialOwner(task, planningItem.getPlanningTask().getAssignedUser()); DelegateTaskCommand delegateTaskCommand = createDelegateCommand(planningItem.getTaskId(), getUserId(), planningItem.getPlanningTask().getAssignedUser()); delegateTaskCommand.execute(context); if (existingPotentialOwner == null) { OrganizationalEntity addedPotentialOwner = findPotentialOwner(task, planningItem.getPlanningTask().getAssignedUser()); if (addedPotentialOwner != null) { task.getPeopleAssignments().getPotentialOwners().remove(addedPotentialOwner); } } saveOrUpdatePlanningTask(planningItem); return null; } }
DelegateAndSaveCommand extends PlanningCommand { @Override public Void execute(Context context) { super.execute(context); final Task task = taskContext.getPersistenceContext().findTask(planningItem.getTaskId()); if (task == null) { throw new PlanningException(String.format(TASK_MODIFIED_ERROR_MSG_1, planningItem.getTaskId()), planningItem.getContainerId(), PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR); } final org.kie.api.task.model.TaskData taskData = task.getTaskData(); final Status status = taskData.getStatus(); if (!(Ready == status || Reserved == status)) { throw new PlanningException(String.format(TASK_MODIFIED_ERROR_MSG, planningItem.getTaskId(), status, Arrays.toString(new Status[]{Ready, Reserved})), planningItem.getContainerId(), PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR); } final OrganizationalEntity existingPotentialOwner = findPotentialOwner(task, planningItem.getPlanningTask().getAssignedUser()); DelegateTaskCommand delegateTaskCommand = createDelegateCommand(planningItem.getTaskId(), getUserId(), planningItem.getPlanningTask().getAssignedUser()); delegateTaskCommand.execute(context); if (existingPotentialOwner == null) { OrganizationalEntity addedPotentialOwner = findPotentialOwner(task, planningItem.getPlanningTask().getAssignedUser()); if (addedPotentialOwner != null) { task.getPeopleAssignments().getPotentialOwners().remove(addedPotentialOwner); } } saveOrUpdatePlanningTask(planningItem); return null; } DelegateAndSaveCommand(PlanningItem planningItem, String userId); }
DelegateAndSaveCommand extends PlanningCommand { @Override public Void execute(Context context) { super.execute(context); final Task task = taskContext.getPersistenceContext().findTask(planningItem.getTaskId()); if (task == null) { throw new PlanningException(String.format(TASK_MODIFIED_ERROR_MSG_1, planningItem.getTaskId()), planningItem.getContainerId(), PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR); } final org.kie.api.task.model.TaskData taskData = task.getTaskData(); final Status status = taskData.getStatus(); if (!(Ready == status || Reserved == status)) { throw new PlanningException(String.format(TASK_MODIFIED_ERROR_MSG, planningItem.getTaskId(), status, Arrays.toString(new Status[]{Ready, Reserved})), planningItem.getContainerId(), PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR); } final OrganizationalEntity existingPotentialOwner = findPotentialOwner(task, planningItem.getPlanningTask().getAssignedUser()); DelegateTaskCommand delegateTaskCommand = createDelegateCommand(planningItem.getTaskId(), getUserId(), planningItem.getPlanningTask().getAssignedUser()); delegateTaskCommand.execute(context); if (existingPotentialOwner == null) { OrganizationalEntity addedPotentialOwner = findPotentialOwner(task, planningItem.getPlanningTask().getAssignedUser()); if (addedPotentialOwner != null) { task.getPeopleAssignments().getPotentialOwners().remove(addedPotentialOwner); } } saveOrUpdatePlanningTask(planningItem); return null; } DelegateAndSaveCommand(PlanningItem planningItem, String userId); @Override Void execute(Context context); }
DelegateAndSaveCommand extends PlanningCommand { @Override public Void execute(Context context) { super.execute(context); final Task task = taskContext.getPersistenceContext().findTask(planningItem.getTaskId()); if (task == null) { throw new PlanningException(String.format(TASK_MODIFIED_ERROR_MSG_1, planningItem.getTaskId()), planningItem.getContainerId(), PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR); } final org.kie.api.task.model.TaskData taskData = task.getTaskData(); final Status status = taskData.getStatus(); if (!(Ready == status || Reserved == status)) { throw new PlanningException(String.format(TASK_MODIFIED_ERROR_MSG, planningItem.getTaskId(), status, Arrays.toString(new Status[]{Ready, Reserved})), planningItem.getContainerId(), PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR); } final OrganizationalEntity existingPotentialOwner = findPotentialOwner(task, planningItem.getPlanningTask().getAssignedUser()); DelegateTaskCommand delegateTaskCommand = createDelegateCommand(planningItem.getTaskId(), getUserId(), planningItem.getPlanningTask().getAssignedUser()); delegateTaskCommand.execute(context); if (existingPotentialOwner == null) { OrganizationalEntity addedPotentialOwner = findPotentialOwner(task, planningItem.getPlanningTask().getAssignedUser()); if (addedPotentialOwner != null) { task.getPeopleAssignments().getPotentialOwners().remove(addedPotentialOwner); } } saveOrUpdatePlanningTask(planningItem); return null; } DelegateAndSaveCommand(PlanningItem planningItem, String userId); @Override Void execute(Context context);  }