public BigDecimal deposit(Long id, BigDecimal amount) { Account account = repository.findOne(id); BigDecimal newBalance = account.getBalance().add(amount); account.setBalance(newBalance); repository.save(account); return newBalance; }
public BigDecimal deposit(Long id, BigDecimal amount) { Account account = repository.getAccount(id); BigDecimal newBalance = account.getBalance().add(amount); account.setBalance(newBalance); repository.updateAccount(account); return newBalance; }
public BigDecimal deposit(Long id, BigDecimal amount) { Account account = repository.getAccount(id); BigDecimal newBalance = account.getBalance().add(amount); account.setBalance(newBalance); repository.updateAccount(account); return newBalance; }
@Test public void testUpdateAccount() throws Exception { Account account = repository.findOne(1L); BigDecimal current = account.getBalance(); BigDecimal amount = new BigDecimal("50.0"); account.setBalance(current.add(amount)); repository.save(account); Account again = repository.findOne(1L); assertThat(again.getBalance(), is(closeTo(current.add(amount), new BigDecimal("0.01")))); }
@Test public void testUpdateAccount() throws Exception { Account account = repository.getAccount(1L); BigDecimal current = account.getBalance(); BigDecimal amount = new BigDecimal("50.0"); account.setBalance(current.add(amount)); repository.updateAccount(account); Account again = repository.getAccount(1L); assertThat(again.getBalance(), is(closeTo(current.add(amount), new BigDecimal("0.01")))); }
@Test public void testUpdateAccount() throws Exception { Account account = repository.getAccount(1L); BigDecimal current = account.getBalance(); BigDecimal amount = new BigDecimal("50.0"); account.setBalance(current.add(amount)); repository.updateAccount(account); Account again = repository.getAccount(1L); assertThat(again.getBalance(), is(closeTo(current.add(amount), new BigDecimal("0.01")))); }
@Test public void testUpdateAccount() throws Exception { Account account = repository.getAccount(1L); BigDecimal current = account.getBalance(); BigDecimal amount = new BigDecimal("50.0"); account.setBalance(current.add(amount)); repository.updateAccount(account); Account again = repository.getAccount(1L); assertThat(again.getBalance(), is(closeTo(current.add(amount), new BigDecimal("0.01")))); }
@Test public void testUpdateAccount() throws Exception { Account account = repository.findOne(1L); BigDecimal current = account.getBalance(); BigDecimal amount = new BigDecimal("50.0"); account.setBalance(current.add(amount)); repository.save(account); Account again = repository.findOne(1L); assertThat(again.getBalance(), is(closeTo(current.add(amount), new BigDecimal("0.01")))); }