ExecutorService { @Scheduled(fixedDelay = 2000, initialDelay = 500) public void checkExecutors() { for (Executor executor : executors) { checkExecutor(executor); } startExecutions(); } @Autowired  ExecutorService(
            ExecutionSource executions,
            ExecutorEventListener eventListener,
            Configuration configuration,
            ExecutorRestClient restClient,
            CheckExecutor checker); @PostConstruct void onInit(); @Scheduled(fixedDelay = 2000, initialDelay = 500) void checkExecutors(); @Async void asyncStartExecutions(); void cancelExecution(Execution execution, String userRequest);  }
@Test public void checkExecutors() { ExecutionSource executions = Mockito.mock(ExecutionSource.class); ExecutorEventListener eventListener = null; Configuration configuration = Mockito.mock(Configuration.class); Mockito.when(configuration.getExecutorUri()).thenReturn("iri"); ExecutorRestClient restClient = null; CheckExecutor checker = Mockito.mock(CheckExecutor.class); ExecutorService service = new ExecutorService( executions, eventListener, configuration, restClient, checker); service.onInit(); Mockito.verify(checker, Mockito.times(1)).check(Mockito.any()); service.checkExecutors(); Mockito.verify(checker, Mockito.times(2)).check(Mockito.any()); }