AccountService { public Integer saveAccount(Account accountRequest) { logger.debug("AccountService.saveAccount:" + accountRequest.toString()); if (accountRequest.getLogincount() == null) { accountRequest.setLogincount(0); } if (accountRequest.getLogoutcount() == null) { accountRequest.setLogoutcount(0); } Account account = accounts.save(accountRequest); logger.info("AccountService.saveAccount: account saved: " + account); return account.getId(); }  Account findAccount(Integer id); Account findAccount(String id); @Cacheable(value = "authorizationCache") Account findAccountprofileByAuthtoken(String token); Integer saveAccount(Account accountRequest); Map<String, Object> login(String username, String password); Account logout(String userId);  }
@Test public void saveAccount() { Account acc = ServiceTestConfiguration.account(); when(repo.save(acc)).thenReturn(acc); assertEquals(service.saveAccount(acc),acc.getId()); }
@Test public void saveAccountWithNullCounts() { Account acc = ServiceTestConfiguration.account(); Account accNull = ServiceTestConfiguration.account(); accNull.setLogincount(null); accNull.setLogoutcount(null); acc.setLogincount(0); acc.setLogoutcount(0); when(repo.save(acc)).thenReturn(acc); assertEquals(service.saveAccount(accNull),acc.getId()); }