assertEquals("Positive amount with exhange rates", BigDecimal.TEN, accountService.calculateTargetAmount(BigDecimal.ONE, -10));
}
@Test
public void testTransferMoney() {
Account origin = Account.findAccount(1L);
Account target = Account.findAccount(2L);
assertEquals("Six initial transactions", 6, origin.getTransactions().size());
assertEquals("Two initial transactions", 2, target.getTransactions().size());
UserDetails user = new UserDetails();
accountService.transferMoney(user, origin, target, null, BigDecimal.ZERO, BigDecimal.ZERO, 0, null);
assertEquals("Six initial transactions", 6, origin.getTransactions().size());
assertEquals("Two initial transactions", 2, target.getTransactions().size());
user = origin.getOwner();
accountService.transferMoney(user, origin, target, new Date(), BigDecimal.ONE, BigDecimal.ZERO, 1, null);
assertEquals("One transaction added to origin", 7, origin.getTransactions().size());
assertEquals("One transaction added to target", 3, target.getTransactions().size());
accountService.transferMoney(user, origin, target, new Date(), BigDecimal.ONE, BigDecimal.ONE, 1, null);
assertEquals("Two transactions added to origin", 9, origin.getTransactions().size());
assertEquals("One more transaction added to target", 4, target.getTransactions().size());
}