RestoreTask extends AsyncTask<RestoreConfig, RestoreState, RestoreState> { @NonNull protected RestoreState doInBackground(RestoreConfig... params) { if (params == null || params.length == 0) throw new IllegalArgumentException("No config passed"); RestoreConfig config = params[0]; if (!config.restoreSms && !config.restoreCallLog) { return new RestoreState(FINISHED_RESTORE, 0, 0, 0, 0, null, null); } else { try { service.acquireLocks(); return restore(config); } finally { service.releaseLocks(); } } } RestoreTask(SmsRestoreService service,
                MessageConverter converter,
                ContentResolver resolver,
                TokenRefresher tokenRefresher); @Subscribe void canceled(CancelEvent canceled);  }
@Test public void shouldAcquireAndReleaseLocksDuringRestore() throws Exception { task.doInBackground(config); verify(service).acquireLocks(); verify(service).releaseLocks(); }
@Test public void shouldVerifyStoreSettings() throws Exception { task.doInBackground(config); verify(store).checkSettings(); }
@Test public void shouldCloseFolders() throws Exception { task.doInBackground(config); verify(store).closeFolders(); }