EnquirySyncService implements SyncService<Enquiry> { @Override public List<String> getIdsToDownload() throws IOException, JSONException, HttpException { long lastUpdateMillis = sharedPreferences.getLong(RapidFtrApplication.LAST_ENQUIRY_SYNC, 0); DateTime lastUpdate = new DateTime(lastUpdateMillis); return enquiryHttpDao.getUpdatedResourceUrls(lastUpdate); } @Inject  EnquirySyncService(RapidFtrApplication rapidFtrApplication, EntityHttpDao<Enquiry> enquiryHttpDao, EnquiryRepository enquiryRepository); @Override Enquiry sync(Enquiry record, User currentUser); @Override Enquiry getRecord(String url); @Override List<String> getIdsToDownload(); @Override void setMedia(Enquiry enquiry); @Override int getNotificationId(); @Override String getNotificationTitle(); @Override void setLastSyncedAt(Enquiry enquiry); String getSyncPath(Enquiry enquiry); static final String ENQUIRIES_API_PATH; static final String ENQUIRIES_API_PARAMETER; }
@Test public void getIdsToDownloadShouldRetrieveUrlsFromApiSinceLastUpdate() throws Exception { String response = "[{\"location\":\"http: getFakeHttpLayer().addHttpResponseRule("http: List<String> enquiryIds = new EnquirySyncService(mockContext(), enquiryHttpDao, enquiryRepository).getIdsToDownload(); assertThat(enquiryIds.get(0), is("http: assertThat(enquiryIds.get(1), is("http: }
@Test public void shouldUseLastEnquirySyncTimestampToRetreiveIds() throws Exception { String response = "[{\"location\":\"http: long time = 1412330399491l; getApplicationInstance().getSharedPreferences().edit().putLong(RapidFtrApplication.LAST_ENQUIRY_SYNC, time).commit(); getFakeHttpLayer().addHttpResponseRule("http: new EnquirySyncService(mockContext(), enquiryHttpDao, enquiryRepository).getIdsToDownload(); }