LoginTask { protected void migrateIfVerified(@NonNull User onlineUser) { User offlineUser = null; try { offlineUser = loadOffline(onlineUser.getUserName(), onlineUser.getPassword()); } catch (LoginException e) { return; } if (offlineUser != null && onlineUser.isVerified() && !offlineUser.isVerified()) { try { notifyProgress(login_migrate_progress); new MigrateUnverifiedDataToVerified(new JSONObject(onlineUser.asJSON()), offlineUser, application).execute(); } catch (Exception e) { throw new LoginException(login_migrate_failed, null); } } }  void login(String userName, String password, String url); @UiThread void notifyProgress(Integer message); @UiThread void notifyToast(LoginException e); @UiThread void notifyToast(int message);  }
@Test @Ignore public void testMigrateShouldMigrate() throws Exception { User onlineUser = new User("test1", "test2", false); User offlineUser = mock(User.class); MigrateUnverifiedDataToVerified task = mock(MigrateUnverifiedDataToVerified.class, RETURNS_DEEP_STUBS); whenNew(MigrateUnverifiedDataToVerified.class).withArguments(onlineUser.asJSON(), offlineUser).thenReturn(task); loginTask.migrateIfVerified(onlineUser); verify(task).execute(); }