@@ -96,7 +96,7 @@ public void setUp() throws Exception {
9696 mSplitsDbAdapter = new SplitsDbAdapter (mDb );
9797 mTransactionsDbAdapter = new TransactionsDbAdapter (mDb , mSplitsDbAdapter );
9898 mAccountsDbAdapter = new AccountsDbAdapter (mDb , mTransactionsDbAdapter );
99-
99+
100100 Account account = new Account (DUMMY_ACCOUNT_NAME );
101101 account .setUID (DUMMY_ACCOUNT_UID );
102102 account .setCurrency (Currency .getInstance (DUMMY_ACCOUNT_CURRENCY_CODE ));
@@ -246,43 +246,47 @@ public void testDeleteAccount() {
246246 transaction .addSplit (new Split (Money .getZeroInstance (), DUMMY_ACCOUNT_UID ));
247247 mTransactionsDbAdapter .addTransaction (transaction );
248248
249- onView (withId ( R . id . primary_text )).perform (longClick ());
249+ onView (withText ( DUMMY_ACCOUNT_NAME )).perform (longClick ());
250250 onView (withId (R .id .context_menu_delete )).perform (click ());
251- onView (withText (R .string .label_delete_sub_accounts )).perform (click ());
251+
252+ //the account has no sub-accounts
253+ onView (withId (R .id .accounts_options )).check (matches (not (isDisplayed ())));
254+ onView (withId (R .id .transactions_options )).check (matches (isDisplayed ()));
255+
256+ onView (withText (R .string .label_delete_transactions )).perform (click ());
252257 onView (withId (R .id .btn_save )).perform (click ());
253258
254259 //should throw expected exception
255260 mAccountsDbAdapter .getID (DUMMY_ACCOUNT_UID );
256261
257262 List <Transaction > transactions = mTransactionsDbAdapter .getAllTransactionsForAccount (DUMMY_ACCOUNT_UID );
258- assertThat (transactions ).hasSize ( 0 );
263+ assertThat (transactions ).isEmpty ( );
259264 }
260265
261266 //TODO: Test import of account file
262267 //TODO: test settings activity
263268 @ Test
264269 public void testIntentAccountCreation (){
265270 Intent intent = new Intent (Intent .ACTION_INSERT );
266- intent .putExtra (Intent .EXTRA_TITLE , "Intent Account" );
267- intent .putExtra (Intent .EXTRA_UID , "intent-account" );
271+ intent .putExtra (Intent .EXTRA_TITLE , "Intent Account" );
272+ intent .putExtra (Intent .EXTRA_UID , "intent-account" );
268273 intent .putExtra (Account .EXTRA_CURRENCY_CODE , "EUR" );
269274 intent .setType (Account .MIME_TYPE );
270275
271- AccountCreator accountCreator = new AccountCreator ();
272- accountCreator .onReceive (mAcccountsActivity , intent );
276+ new AccountCreator ().onReceive (mAcccountsActivity , intent );
273277
274278 Account account = mAccountsDbAdapter .getAccount ("intent-account" );
275- assertNotNull (account );
276- assertEquals ( "Intent Account" , account .getName ());
277- assertEquals ( "intent- account" , account .getUID ());
278- assertEquals ( "EUR" , account .getCurrency ().getCurrencyCode ());
279+ assertThat (account ). isNotNull ( );
280+ assertThat ( account .getName ()). isEqualTo ( "Intent Account" );
281+ assertThat ( account .getUID ()). isEqualTo ( "intent-account" );
282+ assertThat ( account .getCurrency ().getCurrencyCode ()). isEqualTo ( "EUR" );
279283 }
280284
281285 @ After
282286 public void tearDown () throws Exception {
283287 mAcccountsActivity .finish ();
284- Thread .sleep (1000 );
285- mAccountsDbAdapter .deleteAllRecords ();
288+ Thread .sleep (2000 );
289+ mAccountsDbAdapter .deleteAllRecords (); //clear the data
286290 super .tearDown ();
287291 }
288292
0 commit comments