@Test public void shouldAddAccountsToDatabase() { Account account1 = new Account("AlphaAccount"); Account account2 = new Account("BetaAccount"); Transaction transaction = new Transaction("MyTransaction"); Split split = new Split(Money.getZeroInstance(), account1.getUID()); transaction.addSplit(split); transaction.addSplit(split.createPair(account2.getUID())); account1.addTransaction(transaction); account2.addTransaction(transaction); mAccountsDbAdapter.addRecord(account1); mAccountsDbAdapter.addRecord(account2); Account firstAccount = mAccountsDbAdapter.getRecord(account1.getUID()); assertThat(firstAccount).isNotNull(); assertThat(firstAccount.getUID()).isEqualTo(account1.getUID()); assertThat(firstAccount.getFullName()).isEqualTo(account1.getFullName()); Account secondAccount = mAccountsDbAdapter.getRecord(account2.getUID()); assertThat(secondAccount).isNotNull(); assertThat(secondAccount.getUID()).isEqualTo(account2.getUID()); assertThat(mTransactionsDbAdapter.getRecordsCount()).isEqualTo(1); }
@Test public void shouldUpdateFullNameAfterParentChange() { Account parent = new Account("Test"); Account child = new Account("Child"); mAccountsDbAdapter.addRecord(parent); mAccountsDbAdapter.addRecord(child); child.setParentUID(parent.getUID()); mAccountsDbAdapter.addRecord(child); child = mAccountsDbAdapter.getRecord(child.getUID()); parent = mAccountsDbAdapter.getRecord(parent.getUID()); assertThat(mAccountsDbAdapter.getSubAccountCount(parent.getUID())).isEqualTo(1); assertThat(parent.getUID()).isEqualTo(child.getParentUID()); assertThat(child.getFullName()).isEqualTo("Test:Child"); }