Пример #1
0
 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());
 }
Пример #2
0
 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());
 }
Пример #3
0
 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());
 }
Пример #4
0
 public void testGetAggregateAccountFromDb() {
   insertData();
   Account.clear();
   String currency = Account.getLocaleCurrency().getCurrencyCode();
   Cursor c =
       getMockContentResolver()
           .query(
               TransactionProvider.CURRENCIES_URI,
               new String[] {KEY_ROWID},
               KEY_CODE + " = ?",
               new String[] {currency},
               null);
   c.moveToFirst();
   long id = 0 - c.getLong(0);
   c.close();
   AggregateAccount aa = (AggregateAccount) Account.getInstanceFromDb(id);
   assertEquals(currency, aa.currency.getCurrencyCode());
   assertEquals(openingBalance.longValue() * 2, aa.openingBalance.getAmountMinor().longValue());
 }