SyncUnverifiedDataAsyncTask extends SynchronisationAsyncTask<T> { protected void sync() throws JSONException, IOException, HttpException { setProgressAndNotify(context.getString(R.string.synchronize_step_1), 0); registerUser(); JSONObject response = login(); RapidFtrApplication application = RapidFtrApplication.getApplicationInstance(); if(response != null && response.optBoolean("verified") && !application.getCurrentUser().isVerified()){ startMigrationTask(response, application); } getFormSections(); sendRecordsToServer(repository.currentUsersUnsyncedRecords()); List<String> idsToDownload = recordSyncService.getIdsToDownload(); List<T> recordsToSyncWithServer = repository.toBeSynced(); if(!application.getCurrentUser().isVerified()) { List<String> idsOfCurrentUser = repository.getRecordIdsByOwner(); Iterator<String> idIterator = idsToDownload.iterator(); while (idIterator.hasNext()) { String id = idIterator.next(); if(!idsOfCurrentUser.contains(id)) { idIterator.remove(); } } } int startProgressForDownloadingChildren = formSectionProgress + recordsToSyncWithServer.size(); saveIncomingRecords(idsToDownload, startProgressForDownloadingChildren); setProgressAndNotify(context.getString(R.string.sync_complete), maxProgress); } @Inject  SyncUnverifiedDataAsyncTask(FormService formService,
                                       SyncService<T> recordService,
                                       Repository<T> repository,
                                       LoginService loginService,
                                       RegisterUserService registerUserService,
                                       User user); @Override void setContext(RapidFtrActivity context);  }
@Test public void shouldSyncAllChildrenForGivenUser() throws Exception { Child child = mock(Child.class); given(childRepository.currentUsersUnsyncedRecords()).willReturn(newArrayList(child)); task.onPreExecute(); task.execute(); verify(childSyncService).sync(child, currentUser); }