use of org.optaplanner.core.impl.solver.ProblemFactChange 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.optaplanner.core.impl.solver.ProblemFactChange in project droolsjbpm-integration by kiegroup.
the class SolverExecutorTest method addProblemFactChanges.
@Test(timeout = TEST_TIMEOUT)
public void addProblemFactChanges() throws Exception {
CompletableFuture future = startRunnableBase();
runnableBase.start(solution);
// wait for the start initialization to finish
startFinished.await();
List<ProblemFactChange<TaskAssigningSolution>> changes = Collections.emptyList();
runnableBase.addProblemFactChanges(changes);
verify(solver).addProblemFactChanges(changes);
runnableBase.destroy();
future.get();
assertTrue(runnableBase.isDestroyed());
}
use of org.optaplanner.core.impl.solver.ProblemFactChange in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilder method addUserChanges.
private void addUserChanges(final Map<String, User> usersById, final List<AddUserProblemFactChange> newUserChanges, final List<ProblemFactChange<TaskAssigningSolution>> updateUserChanges) {
final Set<String> updatedUserIds = new HashSet<>();
filterDuplicates(externalUserList).filter(externalUser -> !IS_PLANNING_USER.test(externalUser.getId())).map(UserUtil::fromExternalUser).forEach(user -> {
final User previousUser = usersById.get(user.getEntityId());
updatedUserIds.add(user.getEntityId());
if (previousUser == null) {
newUserChanges.add(new AddUserProblemFactChange(user));
} else if (!equalsByProperties(previousUser, user)) {
updateUserChanges.add(new UserPropertyChangeProblemFactChange(previousUser, true, user.getAttributes(), user.getAllLabelValues(), user.getGroups()));
}
});
usersById.values().stream().filter(user -> !IS_PLANNING_USER.test(user.getEntityId())).filter(user -> !updatedUserIds.contains(user.getEntityId())).filter(User::isEnabled).forEach(user -> updateUserChanges.add(new DisableUserProblemFactChange(user)));
}
use of org.optaplanner.core.impl.solver.ProblemFactChange in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilderTest method addNewUserChange.
@Test
public void addNewUserChange() {
List<User> userList = mockUserList(mockUser(USER1_ID), mockUser(USER2_ID));
org.kie.server.services.taskassigning.user.system.api.User newExternalUser = mockExternalUser(USER3_ID);
org.kie.server.services.taskassigning.user.system.api.User newExternalUserRepeated1 = mockExternalUser(USER3_ID);
org.kie.server.services.taskassigning.user.system.api.User newExternalUserRepeated2 = mockExternalUser(USER3_ID);
List<org.kie.server.services.taskassigning.user.system.api.User> externalUserList = mockExternalUserList(newExternalUser, newExternalUserRepeated1, newExternalUserRepeated2);
TaskAssigningSolution solution = mockSolution(Collections.emptyList(), userList);
List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(Collections.emptyList()).withUserSystem(userSystemService).withUsersUpdate(externalUserList).withContext(context).build();
AddUserProblemFactChange expected = new AddUserProblemFactChange(fromExternalUser(newExternalUser));
assertChangeIsTheChangeSetId(result, 0);
assertOneChange(result, 1, expected);
}
use of org.optaplanner.core.impl.solver.ProblemFactChange in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilderTest method addNewReadyTaskChange.
@Test
public void addNewReadyTaskChange() {
TaskData taskData = mockTaskData(TASK_ID, NAME, Ready, null);
List<TaskData> taskDataList = mockTaskDataList(taskData);
TaskAssigningSolution solution = mockSolution(Collections.emptyList(), Collections.emptyList());
List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(taskDataList).withUserSystem(userSystemService).withContext(context).build();
AddTaskProblemFactChange expected = new AddTaskProblemFactChange(fromTaskData(taskData));
assertChangeIsTheChangeSetId(result, 0);
assertChange(result, 1, expected);
assertTaskChangeRegistered(taskData.getTaskId(), taskData.getLastModificationDate());
}
Aggregations