CommandTask { @Scheduled(fixedRateString = "${kermoss.cs.config.rate}") public void scheduledCommandsStarter() { log.info("Start Processing Failed Commands"); final List<Command> commands = commandService.findFailedCommands(); log.info("Fetch {} Failed Commands", commands.size()); commands.parallelStream().forEach(c -> commandFeignClient.restartCommand(c.getId())); log.info("Finish Processing Failed Commands"); } @Autowired  CommandTask(
        final CommandService commandService,
        final CommandFeignClient commandFeignClient
    ); @Scheduled(fixedRateString = "${kermoss.cs.config.rate}") void scheduledCommandsStarter();  }
@Test public void scheduledCommandsStarterShouldFetchFailedCommands() { final List<Command> failedCommands = Arrays.asList(); when(commandService.findFailedCommands()).thenReturn(failedCommands); commandTask.scheduledCommandsStarter(); verify(commandService).findFailedCommands(); }
@Test public void scheduledCommandsStarterShouldSendRestartRequest() { final String commandId = UUID.randomUUID().toString(); final Command cmd = new Command(commandId, "FAILED"); final List<Command> failedCommands = Arrays.asList(cmd); when(commandService.findFailedCommands()).thenReturn(failedCommands); commandTask.scheduledCommandsStarter(); verify(commandFeignClient).restartCommand(same(commandId)); }