@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()); prepareQueryExecutions(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(); 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()); }
public void initSolverExecutor() { if (!status.compareAndSet(STOPPED, STARTED)) { throw new IllegalStateException("SolutionSynchronizer initSolverExecutor method can only be invoked when the status is STOPPED"); } action.set(Action.INIT_SOLVER_EXECUTOR); startPermit.release(); }
SolutionSynchronizer extends RunnableBase { public void initSolverExecutor() { if (!status.compareAndSet(STOPPED, STARTED)) { throw new IllegalStateException("SolutionSynchronizer initSolverExecutor method can only be invoked when the status is STOPPED"); } action.set(Action.INIT_SOLVER_EXECUTOR); startPermit.release(); } }
SolutionSynchronizer extends RunnableBase { public void initSolverExecutor() { if (!status.compareAndSet(STOPPED, STARTED)) { throw new IllegalStateException("SolutionSynchronizer initSolverExecutor method can only be invoked when the status is STOPPED"); } action.set(Action.INIT_SOLVER_EXECUTOR); startPermit.release(); } SolutionSynchronizer(final SolverExecutor solverExecutor,
                                final TaskAssigningRuntimeDelegate delegate,
                                final UserSystemService userSystem,
                                final Duration syncInterval,
                                final Duration usersSyncInterval,
                                final SolverHandlerContext context,
                                final Consumer<Result> resultConsumer); }
SolutionSynchronizer extends RunnableBase { public void initSolverExecutor() { if (!status.compareAndSet(STOPPED, STARTED)) { throw new IllegalStateException("SolutionSynchronizer initSolverExecutor method can only be invoked when the status is STOPPED"); } action.set(Action.INIT_SOLVER_EXECUTOR); startPermit.release(); } SolutionSynchronizer(final SolverExecutor solverExecutor,
                                final TaskAssigningRuntimeDelegate delegate,
                                final UserSystemService userSystem,
                                final Duration syncInterval,
                                final Duration usersSyncInterval,
                                final SolverHandlerContext context,
                                final Consumer<Result> resultConsumer); void initSolverExecutor(); void synchronizeSolution(TaskAssigningSolution solution, LocalDateTime fromLastModificationDate); void synchronizeSolution(TaskAssigningSolution solution, LocalDateTime fromLastModificationDate, Duration unchangedPeriodTimeout); @Override void destroy(); @Override void run(); }
SolutionSynchronizer extends RunnableBase { public void initSolverExecutor() { if (!status.compareAndSet(STOPPED, STARTED)) { throw new IllegalStateException("SolutionSynchronizer initSolverExecutor method can only be invoked when the status is STOPPED"); } action.set(Action.INIT_SOLVER_EXECUTOR); startPermit.release(); } SolutionSynchronizer(final SolverExecutor solverExecutor,
                                final TaskAssigningRuntimeDelegate delegate,
                                final UserSystemService userSystem,
                                final Duration syncInterval,
                                final Duration usersSyncInterval,
                                final SolverHandlerContext context,
                                final Consumer<Result> resultConsumer); void initSolverExecutor(); void synchronizeSolution(TaskAssigningSolution solution, LocalDateTime fromLastModificationDate); void synchronizeSolution(TaskAssigningSolution solution, LocalDateTime fromLastModificationDate, Duration unchangedPeriodTimeout); @Override void destroy(); @Override void run();  }