PotentialMatchSyncService implements SyncService<PotentialMatch> { public List<String> getIdsToDownload() throws IOException, HttpException, JSONException { long lastUpdateMillis = context.getSharedPreferences().getLong(RapidFtrApplication.LAST_POTENTIAL_MATCH_SYNC, 0); DateTime lastUpdate = new DateTime(lastUpdateMillis); return entityHttpDao.getUpdatedResourceUrls(lastUpdate); } @Inject  PotentialMatchSyncService(RapidFtrApplication rapidFtrApplication, PotentialMatchRepository repository); @Override PotentialMatch sync(PotentialMatch record, User currentUser); @Override PotentialMatch getRecord(String resourceUrl); List<String> getIdsToDownload(); @Override void setMedia(PotentialMatch potentialMatch); @Override int getNotificationId(); @Override String getNotificationTitle(); @Override void setLastSyncedAt(PotentialMatch potentialMatch); static final String POTENTIAL_MATCH_API_PATH; static final String POTENTIAL_MATCH_API_PARAMETER; }
@Test public void shouldFetchListOfResourceUrlsToUpdate() throws Exception { String response = "[{\"location\":\"http: getFakeHttpLayer().addHttpResponseRule("http: List<String> resourceUrlsToUpdate = new PotentialMatchSyncService(mockContext(), repository).getIdsToDownload(); assertEquals(1, resourceUrlsToUpdate.size()); assertEquals("http: }
@Test public void shouldUseLastPotentialMatchSyncTimestampToRetreiveIds() throws Exception { String response = "[{\"location\":\"http: long time = 1412330399491l; getApplicationInstance().getSharedPreferences().edit().putLong(RapidFtrApplication.LAST_POTENTIAL_MATCH_SYNC, time).commit(); getFakeHttpLayer().addHttpResponseRule("http: new PotentialMatchSyncService(mockContext(), repository).getIdsToDownload(); }