@Test public void findRichClients() { final Client kim = bankService.createClient("kim", LocalDate.parse("1994-05-21")); final Client chloe = bankService.createClient("chloe", LocalDate.parse("1992-12-01")); final AccountAccess kimAccount = kim.createAccount("Kim's Account"); final AccountAccess chloeAccount = chloe.createAccount("Chloe's Account"); kim.deposit(kimAccount.getAccount().accountNo(), new Amount(1000, 01)); chloe.deposit(chloeAccount.getAccount().accountNo(), new Amount(1000, 00)); { final Iterable<Client> noClients = bankService.findRichClients(new Amount(1000, 02)); final String result = stringize(noClients); assertEquals("", result); } { final Iterable<Client> oneClients = bankService.findRichClients(new Amount(1000, 01)); final String result = stringize(oneClients); assertEquals("1994-05-21 kim", result); } { final Iterable<Client> twoClients = bankService.findRichClients(new Amount(1000, 00)); final String result = stringize(twoClients); assertEquals("1994-05-21 kim, 1992-12-01 chloe", result); } chloe.deposit(chloeAccount.getAccount().accountNo(), new Amount(0, 01)); { final Iterable<Client> twoClients = bankService.findRichClients(new Amount(1000, 01)); final String result = stringize(twoClients); assertEquals("1992-12-01 chloe, 1994-05-21 kim", result); } }
public List<Client> findRichClients(final Amount minBalance) { final List<AccountAccess> fullAccounts = accountAccessRepository.findFullAccounts(minBalance); final Stream<Client> richClients = fullAccounts.stream().map(accountAccess -> accountAccess.getClient()) .distinct(); return richClients.collect(Collectors.toList()); }
BankService { public List<Client> findRichClients(final Amount minBalance) { final List<AccountAccess> fullAccounts = accountAccessRepository.findFullAccounts(minBalance); final Stream<Client> richClients = fullAccounts.stream().map(accountAccess -> accountAccess.getClient()) .distinct(); return richClients.collect(Collectors.toList()); } }
BankService { public List<Client> findRichClients(final Amount minBalance) { final List<AccountAccess> fullAccounts = accountAccessRepository.findFullAccounts(minBalance); final Stream<Client> richClients = fullAccounts.stream().map(accountAccess -> accountAccess.getClient()) .distinct(); return richClients.collect(Collectors.toList()); } @Autowired  BankService(final ClientRepository clientRepository, final AccountAccessRepository accountAccessRepository); }
BankService { public List<Client> findRichClients(final Amount minBalance) { final List<AccountAccess> fullAccounts = accountAccessRepository.findFullAccounts(minBalance); final Stream<Client> richClients = fullAccounts.stream().map(accountAccess -> accountAccess.getClient()) .distinct(); return richClients.collect(Collectors.toList()); } @Autowired  BankService(final ClientRepository clientRepository, final AccountAccessRepository accountAccessRepository); Client createClient(final String username, final LocalDate birthDate); void deleteClient(final Client client); Client findClient(final String username); List<Client> findAllClients(); List<Client> findYoungClients(final LocalDate fromBirth); List<Client> findRichClients(final Amount minBalance); }
BankService { public List<Client> findRichClients(final Amount minBalance) { final List<AccountAccess> fullAccounts = accountAccessRepository.findFullAccounts(minBalance); final Stream<Client> richClients = fullAccounts.stream().map(accountAccess -> accountAccess.getClient()) .distinct(); return richClients.collect(Collectors.toList()); } @Autowired  BankService(final ClientRepository clientRepository, final AccountAccessRepository accountAccessRepository); Client createClient(final String username, final LocalDate birthDate); void deleteClient(final Client client); Client findClient(final String username); List<Client> findAllClients(); List<Client> findYoungClients(final LocalDate fromBirth); List<Client> findRichClients(final Amount minBalance);  }