@Test public void findTest() throws Exception { Human expected = Human.builder() .id(2) .age(19) .name("Андрей") .citizen("Россия") .build(); Human actual = testedHumansDao.find(2); Assert.assertEquals(expected, actual); }
@Override public Human find(int id) { try { return template.queryForObject(SQL_SELECT_USER_BY_ID, humanRowMapper, id); } catch (EmptyResultDataAccessException e) { throw new IllegalArgumentException("User with id <" + id + "> not found"); } }
HumansJdbcTemplateDaoImpl implements HumansDao { @Override public Human find(int id) { try { return template.queryForObject(SQL_SELECT_USER_BY_ID, humanRowMapper, id); } catch (EmptyResultDataAccessException e) { throw new IllegalArgumentException("User with id <" + id + "> not found"); } } }
HumansJdbcTemplateDaoImpl implements HumansDao { @Override public Human find(int id) { try { return template.queryForObject(SQL_SELECT_USER_BY_ID, humanRowMapper, id); } catch (EmptyResultDataAccessException e) { throw new IllegalArgumentException("User with id <" + id + "> not found"); } } HumansJdbcTemplateDaoImpl(DataSource dataSource); }
HumansJdbcTemplateDaoImpl implements HumansDao { @Override public Human find(int id) { try { return template.queryForObject(SQL_SELECT_USER_BY_ID, humanRowMapper, id); } catch (EmptyResultDataAccessException e) { throw new IllegalArgumentException("User with id <" + id + "> not found"); } } HumansJdbcTemplateDaoImpl(DataSource dataSource); @Override List<Human> findAllByAge(int age); @Override void save(Human model); @Override Human find(int id); @Override void update(Human model); @Override void delete(int id); @Override List<Human> findAll(); }
HumansJdbcTemplateDaoImpl implements HumansDao { @Override public Human find(int id) { try { return template.queryForObject(SQL_SELECT_USER_BY_ID, humanRowMapper, id); } catch (EmptyResultDataAccessException e) { throw new IllegalArgumentException("User with id <" + id + "> not found"); } } HumansJdbcTemplateDaoImpl(DataSource dataSource); @Override List<Human> findAllByAge(int age); @Override void save(Human model); @Override Human find(int id); @Override void update(Human model); @Override void delete(int id); @Override List<Human> findAll();  }