use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class SolverHandlerTest method onUpdateSolutionSolverNotStarted.
@Test
public void onUpdateSolutionSolverNotStarted() {
prepareStart();
List<ProblemFactChange<TaskAssigningSolution>> changes = new ArrayList<>();
changes.add(new TaskPropertyChangeProblemFactChange(new Task()));
SolutionSynchronizer.Result result = SolutionSynchronizer.Result.forChanges(changes);
doReturn(false).when(solverExecutor).isStarted();
synchronizerConsumerCaptor.getValue().accept(result);
verify(solverExecutor, never()).addProblemFactChanges(changes);
}
use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class SolutionSynchronizerTest method initSolverExecutor.
@Test(timeout = TEST_TIMEOUT)
@SuppressWarnings("unchecked")
public void initSolverExecutor() throws Exception {
CompletableFuture future = startRunnableBase();
LocalDateTime firstQueryTime = LocalDateTime.now();
List<User> userList = mockUserList();
List<TaskAssigningRuntimeDelegate.FindTasksResult> results = mockTasksQueryExecutions(firstQueryTime);
LocalDateTime firstSuccessfulQueryTime = results.get(results.size() - 1).getQueryTime();
queryExecutionsCountDown = new CountDownLatch(results.size());
prepareQueryExecutionsWithOutEmptyStatus(results);
when(emptySolution.getTaskList()).thenReturn(Collections.emptyList());
when(generatedSolution.getTaskList()).thenReturn(Collections.singletonList(new Task()));
when(solverExecutor.isStopped()).thenReturn(true);
when(userSystemService.findAllUsers()).thenReturn(userList);
runnableBase.initSolverExecutor();
// wait for the query executions to happen
queryExecutionsCountDown.await();
verify(delegate, times(results.size())).findTasks(anyList(), eq(null), anyObject());
verify(solverExecutor).start(solutionCaptor.capture());
assertEquals(generatedSolution, solutionCaptor.getValue());
LocalDateTime nextQueryTime = context.shiftQueryTime(firstSuccessfulQueryTime.withNano(0));
LocalDateTime previousQueryTime = context.shiftQueryTime(nextQueryTime);
assertEquals(previousQueryTime, context.getPreviousQueryTime());
assertEquals(nextQueryTime, context.getNextQueryTime());
runnableBase.destroy();
future.get();
assertTrue(runnableBase.isDestroyed());
}
use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class TaskUtilTest method fromTaskData.
private void fromTaskData(Map<String, Object> inputData, Set<Object> expectedSkills, Set<Object> expectedAffinities) {
Set<OrganizationalEntity> potentialOwners = new HashSet<>();
potentialOwners.add(OE_1);
potentialOwners.add(OE_2);
TaskData taskData = TaskData.builder().taskId(TASK_ID).processInstanceId(PROCESS_INSTANCE_ID).processId(PROCESS_ID).containerId(CONTAINER_ID).name(NAME).priority(PRIORITY).status(STATUS).inputData(inputData).potentialOwners(potentialOwners).build();
Task task = TaskUtil.fromTaskData(taskData);
assertEquals(TASK_ID, task.getId(), 0);
assertEquals(PROCESS_INSTANCE_ID, task.getProcessInstanceId(), 0);
assertEquals(PROCESS_ID, task.getProcessId());
assertEquals(CONTAINER_ID, task.getContainerId());
assertEquals(NAME, task.getName());
assertEquals(PRIORITY, task.getPriority(), 0);
assertEquals(STATUS, task.getStatus());
assertEquals(inputData, task.getInputData());
assertEquals(potentialOwners.size(), task.getPotentialOwners().size(), 2);
User user = task.getPotentialOwners().stream().filter(u -> OE_1.getName().equals(u.getEntityId()) && u.isUser()).map(u -> (User) u).findFirst().orElse(null);
assertNotNull(user);
Group group = task.getPotentialOwners().stream().filter(g -> OE_2.getName().equals(g.getEntityId()) && !g.isUser()).map(g -> (Group) g).findFirst().orElse(null);
assertNotNull(group);
assertEquals(expectedSkills, task.getLabelValues(SKILLS.name()));
assertEquals(expectedAffinities, task.getLabelValues(AFFINITIES.name()));
}
use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class TestUtil method initializeUser.
public static User initializeUser(User user, List<Task> tasks) {
TaskOrUser previous = user;
for (Task task : tasks) {
previous.setNextTask(task);
task.setPreviousTaskOrUser(previous);
task.setUser(user);
previous = task;
}
return user;
}
use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class RemoveUserProblemFactChangeTest method doChange.
@Test
public void doChange() {
List<Task> workingUserTasks = Arrays.asList(mockTask(TASK_ID1, true), mockTask(TASK_ID2, true), mockTask(TASK_ID3, false), mockTask(TASK_ID4, false));
User workingUser = mockUser(USER_ID_1, workingUserTasks);
workingUser.setEnabled(true);
workingSolution.getUserList().add(workingUser);
int originalUsersSize = workingSolution.getUserList().size();
when(scoreDirector.lookUpWorkingObjectOrReturnNull(user)).thenReturn(workingUser);
change.doChange(scoreDirector);
verify(scoreDirector).beforeProblemPropertyChanged(workingUser);
verify(scoreDirector).afterProblemPropertyChanged(workingUser);
verify(scoreDirector).triggerVariableListeners();
assertThat(workingUser.isEnabled()).isFalse();
workingUserTasks.forEach(task -> assertTaskWasReleased(task, scoreDirector));
verify(scoreDirector).beforeProblemFactRemoved(workingUser);
verify(scoreDirector).afterProblemFactRemoved(workingUser);
assertThat(workingSolution.getUserList().size()).isEqualTo(originalUsersSize - 1);
assertThat(workingSolution.getUserList()).contains(user2, user3);
assertThat(workingSolution.getUserList()).doesNotContain(workingUser);
}
Aggregations