public void testReset() {
   insertData();
   Money initialtotalBalance = account1.getTotalBalance();
   assertEquals(6, count(account1.getId(), null));
   account1.reset(null, Account.EXPORT_HANDLE_DELETED_UPDATE_BALANCE, null);
   Account.clear();
   assertEquals(0, count(account1.getId(), null));
   Account resetAccount = Account.getInstanceFromDb(account1.getId());
   assertEquals(initialtotalBalance, resetAccount.getTotalBalance());
 }
 public void testResetWithFilterUpdateBalance() {
   insertData();
   Money initialtotalBalance = account1.getTotalBalance();
   assertEquals(6, count(account1.getId(), null));
   WhereFilter filter = WhereFilter.empty();
   filter.put(0, new CategoryCriteria(TEST_CAT, catId));
   account1.reset(filter, Account.EXPORT_HANDLE_DELETED_UPDATE_BALANCE, null);
   Account.clear();
   assertEquals(5, count(account1.getId(), null)); // 1 Transaction deleted
   Account resetAccount = Account.getInstanceFromDb(account1.getId());
   assertEquals(initialtotalBalance, resetAccount.getTotalBalance());
 }
 public void testResetWithFilterCreateHelper() {
   insertData();
   Money initialtotalBalance = account1.getTotalBalance();
   assertEquals(6, count(account1.getId(), null));
   assertEquals(1, count(account1.getId(), KEY_CATID + "=" + catId));
   assertEquals(0, count(account1.getId(), KEY_STATUS + "=" + STATUS_HELPER));
   WhereFilter filter = WhereFilter.empty();
   filter.put(0, new CategoryCriteria(TEST_CAT, catId));
   account1.reset(filter, Account.EXPORT_HANDLE_DELETED_CREATE_HELPER, null);
   Account.clear();
   assertEquals(6, count(account1.getId(), null)); // -1 Transaction deleted;+1 helper
   assertEquals(0, count(account1.getId(), KEY_CATID + "=" + catId));
   assertEquals(1, count(account1.getId(), KEY_STATUS + "=" + STATUS_HELPER));
   Account resetAccount = Account.getInstanceFromDb(account1.getId());
   assertEquals(initialtotalBalance, resetAccount.getTotalBalance());
 }
 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()));
 }