AccountService { public void transfer(Long fromId, Long toId, BigDecimal amount) { withdraw(fromId, amount); deposit(toId, amount); }  @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) BigDecimal getBalance(Long id); BigDecimal deposit(Long id, BigDecimal amount); BigDecimal withdraw(Long id, BigDecimal amount); void transfer(Long fromId, Long toId, BigDecimal amount);  }
@Test public void testTransfer() throws Exception { BigDecimal acct1start = service.getBalance(1L); BigDecimal acct2start = service.getBalance(2L); BigDecimal amount = new BigDecimal("50.0"); service.transfer(1L, 2L, amount); BigDecimal acct1finish = acct1start.subtract(amount); BigDecimal acct2finish = acct2start.add(amount); assertThat(acct1finish, is(closeTo(service.getBalance(1L), new BigDecimal("0.01")))); assertThat(acct2finish, is(closeTo(service.getBalance(2L), new BigDecimal("0.01")))); }