Search in sources :

Example 71 with TaskAssignment

use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.

the class AssignTaskExecutableProblemFactChangeTest method assignTaskProblemFactChangeUserNotFound.

@Test
void assignTaskProblemFactChangeUserNotFound() {
    TaskAssigningSolution solution = readTaskAssigningSolution(SET_OF_24TASKS_8USERS_SOLUTION.resource());
    TaskAssignment taskAssignment = solution.getTaskAssignmentList().get(0);
    User user = new User("Non Existing");
    Assertions.assertThatThrownBy(() -> executeSequentialChanges(solution, Collections.singletonList(new ProgrammedAssignTaskProblemFactChange(taskAssignment, user)))).hasMessage("Expected user: %s was not found in current working solution", user);
}
Also used : User(org.kie.kogito.taskassigning.core.model.User) TaskAssigningSolution(org.kie.kogito.taskassigning.core.model.TaskAssigningSolution) TaskAssignment(org.kie.kogito.taskassigning.core.model.TaskAssignment) Test(org.junit.jupiter.api.Test)

Example 72 with TaskAssignment

use of org.kie.kogito.taskassigning.core.model.TaskAssignment in project kogito-apps by kiegroup.

the class AssignTaskExecutableProblemFactChangeTest method assignTaskProblemFactChangeRandomChangeSet.

private void assignTaskProblemFactChangeRandomChangeSet(String solutionResource) throws Exception {
    TaskAssigningSolution solution = readTaskAssigningSolution(solutionResource);
    solution.getUserList().add(PLANNING_USER);
    int taskCount = solution.getTaskAssignmentList().size();
    int userCount = solution.getUserList().size();
    int randomChanges = taskCount / 2 + random.nextInt(taskCount / 2);
    // prepare the list of changes to program
    List<ProgrammedAssignTaskProblemFactChange> programmedChanges = new ArrayList<>();
    TaskAssignment randomTask;
    User randomUser;
    for (int i = 0; i < randomChanges; i++) {
        randomTask = solution.getTaskAssignmentList().get(random.nextInt(taskCount));
        randomUser = solution.getUserList().get(random.nextInt(userCount));
        programmedChanges.add(new ProgrammedAssignTaskProblemFactChange(randomTask, randomUser));
    }
    assignTaskProblemFactChange(solution, solutionResource, RANDOM_TEST, programmedChanges);
}
Also used : User(org.kie.kogito.taskassigning.core.model.User) TaskAssigningSolution(org.kie.kogito.taskassigning.core.model.TaskAssigningSolution) ArrayList(java.util.ArrayList) TaskAssignment(org.kie.kogito.taskassigning.core.model.TaskAssignment)

Aggregations

TaskAssignment (org.kie.kogito.taskassigning.core.model.TaskAssignment)72 User (org.kie.kogito.taskassigning.core.model.User)39 Test (org.junit.jupiter.api.Test)27 TaskAssigningSolution (org.kie.kogito.taskassigning.core.model.TaskAssigningSolution)23 ChainElement (org.kie.kogito.taskassigning.core.model.ChainElement)14 ArrayList (java.util.ArrayList)12 TestUtil.mockTaskAssignment (org.kie.kogito.taskassigning.core.model.TestUtil.mockTaskAssignment)12 TestUtil.mockUser (org.kie.kogito.taskassigning.core.model.TestUtil.mockUser)11 TaskUtil.fromTaskData (org.kie.kogito.taskassigning.service.util.TaskUtil.fromTaskData)10 Task (org.kie.kogito.taskassigning.core.model.Task)8 AddTaskProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.AddTaskProblemFactChange)8 AssignTaskProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange)8 TestUtil.mockTaskData (org.kie.kogito.taskassigning.service.TestUtil.mockTaskData)8 RemoveTaskProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.RemoveTaskProblemFactChange)6 List (java.util.List)5 AddUserProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.AddUserProblemFactChange)5 ProblemFactChange (org.optaplanner.core.api.solver.ProblemFactChange)5 DisableUserProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.DisableUserProblemFactChange)4 ProblemFactChangeUtil.unlinkTaskAssignment (org.kie.kogito.taskassigning.core.model.solver.realtime.ProblemFactChangeUtil.unlinkTaskAssignment)4 ReleaseTaskProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange)4