@Test public void onSolutionSynchronizedWithChanges() { prepareStart(); List<ProblemFactChange<TaskAssigningSolution>> changes = new ArrayList<>(); changes.add(new TaskPropertyChangeProblemFactChange(new Task())); SolutionSynchronizer.Result result = SolutionSynchronizer.Result.forChanges(changes); doReturn(true).when(solverExecutor).isStarted(); synchronizerConsumerCaptor.getValue().accept(result); verify(solverExecutor).addProblemFactChanges(changes); verify(solutionProcessor, never()).process(any(TaskAssigningSolution.class)); verify(solutionSynchronizer, never()).synchronizeSolution(any(TaskAssigningSolution.class), any(LocalDateTime.class)); }
private void addProblemFactChanges(List<ProblemFactChange<TaskAssigningSolution>> changes) { checkNotNull("changes", changes); if (!solverExecutor.isStarted()) { LOGGER.info("SolverExecutor has not been started. Changes will be discarded {}", changes); return; } if (!changes.isEmpty()) { onBackgroundImprovedSolutionSent.set(false); solverExecutor.addProblemFactChanges(changes); } else { LOGGER.info("It looks like an empty change list was provided. Nothing will be done since it has no effect on the solution."); } }
SolverHandler { private void addProblemFactChanges(List<ProblemFactChange<TaskAssigningSolution>> changes) { checkNotNull("changes", changes); if (!solverExecutor.isStarted()) { LOGGER.info("SolverExecutor has not been started. Changes will be discarded {}", changes); return; } if (!changes.isEmpty()) { onBackgroundImprovedSolutionSent.set(false); solverExecutor.addProblemFactChanges(changes); } else { LOGGER.info("It looks like an empty change list was provided. Nothing will be done since it has no effect on the solution."); } } }
SolverHandler { private void addProblemFactChanges(List<ProblemFactChange<TaskAssigningSolution>> changes) { checkNotNull("changes", changes); if (!solverExecutor.isStarted()) { LOGGER.info("SolverExecutor has not been started. Changes will be discarded {}", changes); return; } if (!changes.isEmpty()) { onBackgroundImprovedSolutionSent.set(false); solverExecutor.addProblemFactChanges(changes); } else { LOGGER.info("It looks like an empty change list was provided. Nothing will be done since it has no effect on the solution."); } } SolverHandler(final SolverDef solverDef,
                         final KieServerRegistry registry,
                         final TaskAssigningRuntimeDelegate delegate,
                         final UserSystemService userSystemService,
                         final ScheduledExecutorService executorService,
                         final SolverHandlerConfig config); }
SolverHandler { private void addProblemFactChanges(List<ProblemFactChange<TaskAssigningSolution>> changes) { checkNotNull("changes", changes); if (!solverExecutor.isStarted()) { LOGGER.info("SolverExecutor has not been started. Changes will be discarded {}", changes); return; } if (!changes.isEmpty()) { onBackgroundImprovedSolutionSent.set(false); solverExecutor.addProblemFactChanges(changes); } else { LOGGER.info("It looks like an empty change list was provided. Nothing will be done since it has no effect on the solution."); } } SolverHandler(final SolverDef solverDef,
                         final KieServerRegistry registry,
                         final TaskAssigningRuntimeDelegate delegate,
                         final UserSystemService userSystemService,
                         final ScheduledExecutorService executorService,
                         final SolverHandlerConfig config); void start(); void destroy(); }
SolverHandler { private void addProblemFactChanges(List<ProblemFactChange<TaskAssigningSolution>> changes) { checkNotNull("changes", changes); if (!solverExecutor.isStarted()) { LOGGER.info("SolverExecutor has not been started. Changes will be discarded {}", changes); return; } if (!changes.isEmpty()) { onBackgroundImprovedSolutionSent.set(false); solverExecutor.addProblemFactChanges(changes); } else { LOGGER.info("It looks like an empty change list was provided. Nothing will be done since it has no effect on the solution."); } } SolverHandler(final SolverDef solverDef,
                         final KieServerRegistry registry,
                         final TaskAssigningRuntimeDelegate delegate,
                         final UserSystemService userSystemService,
                         final ScheduledExecutorService executorService,
                         final SolverHandlerConfig config); void start(); void destroy();  }