@Test public void onSolutionSynchronizedWithUnchangedPeriodTimeoutAndDifferentScoreBestSolution() { TaskAssigningSolution initialSolution = prepareStartAndASolutionProduced(); BestSolutionChangedEvent<TaskAssigningSolution> event = mockEvent(true, true); TaskAssigningSolution nextBestSolution = event.getNewBestSolution(); BendableLongScore initialSolutionScore = initialSolution.getScore(); BendableLongScore modifiedScore = initialSolutionScore.multiply(123); doReturn(modifiedScore).when(nextBestSolution).getScore(); listenerCaptor.getValue().bestSolutionChanged(event); SolutionSynchronizer.Result result = SolutionSynchronizer.Result.forUnchangedPeriodTimeout(); synchronizerConsumerCaptor.getValue().accept(result); verify(solverExecutor, never()).addProblemFactChanges(any(List.class)); verify(solutionProcessor).process(nextBestSolution); 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();  }