@Test public void testFindFailedCommands() { ArrayList<Object> resultQuery = new ArrayList<>(); when(jdbcTemplate.query(anyString(),any(RowMapper.class))).thenReturn(resultQuery); List<Command> findFailedCommands = commandServiceImplUnderTest.findFailedCommands(); assertThat(resultQuery).isEqualTo(findFailedCommands); verify(jdbcTemplate).query(anyString(),any(RowMapper.class)); }
public List<Command> findFailedCommands() { final Long currentTimestamp = new Date().getTime(); return jdbcTemplate.query( "SELECT id, status FROM KERMOSS_CMD cmd WHERE cmd.status = 'FAILED' " + String.format("OR (cmd.status = 'STARTED' AND (cmd.started_timestamp + %d) < %d)", maxCommandExecutionTime, currentTimestamp), new BeanPropertyRowMapper(Command.class) ); }
CommandServiceImpl implements CommandService { public List<Command> findFailedCommands() { final Long currentTimestamp = new Date().getTime(); return jdbcTemplate.query( "SELECT id, status FROM KERMOSS_CMD cmd WHERE cmd.status = 'FAILED' " + String.format("OR (cmd.status = 'STARTED' AND (cmd.started_timestamp + %d) < %d)", maxCommandExecutionTime, currentTimestamp), new BeanPropertyRowMapper(Command.class) ); } }
CommandServiceImpl implements CommandService { public List<Command> findFailedCommands() { final Long currentTimestamp = new Date().getTime(); return jdbcTemplate.query( "SELECT id, status FROM KERMOSS_CMD cmd WHERE cmd.status = 'FAILED' " + String.format("OR (cmd.status = 'STARTED' AND (cmd.started_timestamp + %d) < %d)", maxCommandExecutionTime, currentTimestamp), new BeanPropertyRowMapper(Command.class) ); } @Autowired  CommandServiceImpl(final JdbcTemplate jdbcTemplate, @Value("${kermoss.cs.config.max-cmd-exec-time}") final Long maxCommandExecutionTime); }
CommandServiceImpl implements CommandService { public List<Command> findFailedCommands() { final Long currentTimestamp = new Date().getTime(); return jdbcTemplate.query( "SELECT id, status FROM KERMOSS_CMD cmd WHERE cmd.status = 'FAILED' " + String.format("OR (cmd.status = 'STARTED' AND (cmd.started_timestamp + %d) < %d)", maxCommandExecutionTime, currentTimestamp), new BeanPropertyRowMapper(Command.class) ); } @Autowired  CommandServiceImpl(final JdbcTemplate jdbcTemplate, @Value("${kermoss.cs.config.max-cmd-exec-time}") final Long maxCommandExecutionTime); List<Command> findFailedCommands(); }
CommandServiceImpl implements CommandService { public List<Command> findFailedCommands() { final Long currentTimestamp = new Date().getTime(); return jdbcTemplate.query( "SELECT id, status FROM KERMOSS_CMD cmd WHERE cmd.status = 'FAILED' " + String.format("OR (cmd.status = 'STARTED' AND (cmd.started_timestamp + %d) < %d)", maxCommandExecutionTime, currentTimestamp), new BeanPropertyRowMapper(Command.class) ); } @Autowired  CommandServiceImpl(final JdbcTemplate jdbcTemplate, @Value("${kermoss.cs.config.max-cmd-exec-time}") final Long maxCommandExecutionTime); List<Command> findFailedCommands();  }