예제 #1
0
 public void testAccount() throws RemoteException, OperationApplicationException {
   Account account, restored = null;
   Long openingBalance = (long) 100;
   account = new Account("TestAccount", openingBalance, "Testing with Junit");
   account.setCurrency("EUR");
   assertEquals("EUR", account.currency.getCurrencyCode());
   account.save();
   assertTrue(account.getId() > 0);
   restored = Account.getInstanceFromDb(account.getId());
   assertEquals(account, restored);
   Long trAmount = (long) 100;
   Transaction op1 = Transaction.getNewInstance(account.getId());
   op1.setAmount(new Money(account.currency, trAmount));
   op1.comment = "test transaction";
   op1.save();
   assertEquals(account.getTotalBalance().getAmountMinor().longValue(), openingBalance + trAmount);
   Account.delete(account.getId());
   assertNull(
       "Account deleted, but can still be retrieved", Account.getInstanceFromDb(account.getId()));
   assertNull(
       "Account delete should delete transaction, but operation can still be retrieved",
       Transaction.getInstanceFromDb(op1.getId()));
 }
예제 #2
0
 private void insertData() {
   Transaction op;
   account1 = new Account("Account 1", openingBalance, "Account 1");
   account1.save();
   account2 = new Account("Account 2", openingBalance, "Account 2");
   account2.save();
   catId = Category.write(0, TEST_CAT, null);
   op = Transaction.getNewInstance(account1.getId());
   op.setAmount(new Money(account1.currency, -expense1));
   op.crStatus = CrStatus.CLEARED;
   op.save();
   op.setAmount(new Money(account1.currency, -expense2));
   op.saveAsNew();
   op.setAmount(new Money(account1.currency, income1));
   op.saveAsNew();
   op.setAmount(new Money(account1.currency, income2));
   op.setCatId(catId);
   op.saveAsNew();
   Transfer op1 = Transfer.getNewInstance(account1.getId(), account2.getId());
   op1.setAmount(new Money(account1.currency, transferP));
   op1.save();
   op1.setAmount(new Money(account1.currency, -transferN));
   op1.saveAsNew();
 }