ChildSyncService implements SyncService<Child> { public List<String> getIdsToDownload() throws IOException, JSONException, HttpException { long lastUpdateMillis = context.getSharedPreferences().getLong(RapidFtrApplication.LAST_CHILD_SYNC, 0); DateTime lastUpdate = new DateTime(lastUpdateMillis); return childEntityHttpDao.getUpdatedResourceUrls(lastUpdate); } @Inject  ChildSyncService(RapidFtrApplication context, EntityHttpDao<Child> childHttpDao, ChildRepository childRepository); @Override Child sync(Child child, User currentUser); String getSyncPath(Child child, User currentUser); @Override void setMedia(Child child); @Override int getNotificationId(); @Override String getNotificationTitle(); @Override void setLastSyncedAt(Child child); @Override Child getRecord(String resourceUrl); List<String> getIdsToDownload(); static final String CHILDREN_API_PATH; static final String CHILDREN_API_PARAMETER; static final String UNVERIFIED_USER_CHILDREN_API_PATH; }
@Test public void shouldFetchListOfResourceUrlsToUpdate() throws Exception { String response = "[{\"location\":\"http: getFakeHttpLayer().addHttpResponseRule("http: List<String> idsToChange = new ChildSyncService(mockContext(), childHttpDao, repository).getIdsToDownload(); assertEquals(2, idsToChange.size()); assertEquals("http: }
@Test public void shouldUseLastChildSyncTimestampToRetreiveIds() throws Exception { String response = "[{\"location\":\"http: long time = 1412330399491l; getApplicationInstance().getSharedPreferences().edit().putLong(RapidFtrApplication.LAST_CHILD_SYNC, time).commit(); getFakeHttpLayer().addHttpResponseRule("http: new ChildSyncService(mockContext(), childHttpDao, repository).getIdsToDownload(); }