AccountService { public List<Account> findAccounts(String user) { logger.debug("AccountService.findAccounts: id=" + user); List<Account> account = accounts.findByUserid(user); logger.debug("Found " + account.size() + " account(s)."); logger.info(String.format("AccountService.findAccount - retrieved account for user id: %s. Payload is: %s", user, account)); return account; }  Account findAccount(Integer id); List<Account> findAccounts(String user); List<Account> findAccountsByType(String id, AccountType type); Integer saveAccount(Account accountRequest);  }
@Test public void doFindAccountUserId() { when(repo.findByUserid(ServiceTestConfiguration.USER_ID)).thenReturn(ServiceTestConfiguration.accountList()); List<Account> accounts = service.findAccounts(ServiceTestConfiguration.USER_ID); assertEquals(accounts.size(),1); assertEquals(accounts.get(0), ServiceTestConfiguration.account()); }
@Test public void doFindAccountUserIdNotFound() { when(repo.findByUserid(ServiceTestConfiguration.BAD_USER_ID)).thenReturn(new ArrayList()); List<Account> accounts = service.findAccounts(ServiceTestConfiguration.BAD_USER_ID); assertEquals(accounts.size(),0); }