@Test public void deposit() { final Client jack = bankService.createClient("jack", LocalDate.parse("1966-12-31")); final AccountAccess jacksGiro = jack.createAccount("Jack's Giro"); final AccountNo accountNo = jacksGiro.getAccount().accountNo(); jack.deposit(accountNo, new Amount(999999999, 99)); final String report = jack.accountsReport(); assertEquals("Accounts of client: jack\n" + accountNo + "\tisOwner\t999999999,99\tJack's Giro\n", report); }
public void deposit(final AccountNo destination, final Amount amount) throws AmountExc, DestinationAccountNotFoundExc, DepositFailure { if (amount.compareTo(Amount.ZERO) <= 0) { throw create(Client.AmountExc.class, amount); } final Account destinationAccount = _findDestinationAccount(destination); try { destinationAccount.setBalance(destinationAccount.getBalance().plus(amount)); accountRepository.save(destinationAccount); } catch (final Exception ex) { throw create(DepositFailure.class, ex, amount, destination); } }
Client extends EntityBase<Client> { public void deposit(final AccountNo destination, final Amount amount) throws AmountExc, DestinationAccountNotFoundExc, DepositFailure { if (amount.compareTo(Amount.ZERO) <= 0) { throw create(Client.AmountExc.class, amount); } final Account destinationAccount = _findDestinationAccount(destination); try { destinationAccount.setBalance(destinationAccount.getBalance().plus(amount)); accountRepository.save(destinationAccount); } catch (final Exception ex) { throw create(DepositFailure.class, ex, amount, destination); } } }
Client extends EntityBase<Client> { public void deposit(final AccountNo destination, final Amount amount) throws AmountExc, DestinationAccountNotFoundExc, DepositFailure { if (amount.compareTo(Amount.ZERO) <= 0) { throw create(Client.AmountExc.class, amount); } final Account destinationAccount = _findDestinationAccount(destination); try { destinationAccount.setBalance(destinationAccount.getBalance().plus(amount)); accountRepository.save(destinationAccount); } catch (final Exception ex) { throw create(DepositFailure.class, ex, amount, destination); } } @SuppressWarnings("unused") private  Client();  Client(final String username, final LocalDate birthDate); }
Client extends EntityBase<Client> { public void deposit(final AccountNo destination, final Amount amount) throws AmountExc, DestinationAccountNotFoundExc, DepositFailure { if (amount.compareTo(Amount.ZERO) <= 0) { throw create(Client.AmountExc.class, amount); } final Account destinationAccount = _findDestinationAccount(destination); try { destinationAccount.setBalance(destinationAccount.getBalance().plus(amount)); accountRepository.save(destinationAccount); } catch (final Exception ex) { throw create(DepositFailure.class, ex, amount, destination); } } @SuppressWarnings("unused") private  Client();  Client(final String username, final LocalDate birthDate); @Column(unique = true, nullable = false) String getUsername(); LocalDate getBirthDate(); @Override String toString(); AccountAccess createAccount(final String accountName); void deposit(final AccountNo destination, final Amount amount); void transfer(final Account source, final AccountNo destination, final Amount amount); AccountAccess addAccountManager(final Account account, Client manager); Account findMyAccount(final AccountNo accountNo); String accountsReport(); }
Client extends EntityBase<Client> { public void deposit(final AccountNo destination, final Amount amount) throws AmountExc, DestinationAccountNotFoundExc, DepositFailure { if (amount.compareTo(Amount.ZERO) <= 0) { throw create(Client.AmountExc.class, amount); } final Account destinationAccount = _findDestinationAccount(destination); try { destinationAccount.setBalance(destinationAccount.getBalance().plus(amount)); accountRepository.save(destinationAccount); } catch (final Exception ex) { throw create(DepositFailure.class, ex, amount, destination); } } @SuppressWarnings("unused") private  Client();  Client(final String username, final LocalDate birthDate); @Column(unique = true, nullable = false) String getUsername(); LocalDate getBirthDate(); @Override String toString(); AccountAccess createAccount(final String accountName); void deposit(final AccountNo destination, final Amount amount); void transfer(final Account source, final AccountNo destination, final Amount amount); AccountAccess addAccountManager(final Account account, Client manager); Account findMyAccount(final AccountNo accountNo); String accountsReport();  }