### Question:
AccountServiceImpl implements AccountService { @Override @Transactional(readOnly = true) public Optional<Account> getAccountByUsername(String username) { return accountDAO.findByUsername(username); } @Autowired  AccountServiceImpl(AccountDAO accountDAO); @Override @Transactional(readOnly = true) Optional<Account> getAccountByUsername(String username); @Override @Transactional(readOnly = true) Collection<AccountDTO> getAccounts(); @Override @Transactional(readOnly = true) Collection<AccountDTO> getAccounts(int offset, int limit); @Override @Transactional(readOnly = true) AccountDTO getAccountById(Long id); @Override @Transactional AccountDTO updateAccount(AccountDTO accountDTO); @Override @Transactional void updatePassword(Long id, String password); @Override @Transactional(readOnly = true) long getTotalCount();  }### Answer:
@Test public void shouldGetAccountByUsernameFromDao() throws Exception { String username = "john.doe"; Optional<Account> accountOptional = Optional.empty(); Mockito.when(accountDAO.findByUsername(username)).thenReturn(accountOptional); Optional<Account> result = accountService.getAccountByUsername(username); Assertions.assertThat(result).isSameAs(accountOptional); }