EnquirySyncService implements SyncService<Enquiry> { @Override public Enquiry getRecord(String url) throws IOException, JSONException, HttpException { Enquiry enquiry = enquiryHttpDao.get(url); enquiry.setSynced(true); enquiry.setLastUpdatedAt(RapidFtrDateTime.now().defaultFormat()); enquiry.remove(Enquiry.FIELD_ATTACHMENTS); return enquiry; } @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 getRecordShouldRetrieveARecordOverHttp() throws Exception { String resourceUrl = "http: String response = "{\"_id\" : \"couch_id\", \"child_name\":\"subhas\",\"unique_identifier\":\"78223s4h1e468f5200edc\"}"; getFakeHttpLayer().addHttpResponseRule("http: EnquirySyncService enquirySyncService = new EnquirySyncService(mockContext(), enquiryHttpDao, enquiryRepository); Enquiry expectedEnquiry = new Enquiry(response, "createdBy"); final Enquiry downloadedEnquiry = enquirySyncService.getRecord(resourceUrl); assertThat(downloadedEnquiry.getUniqueId(), is(expectedEnquiry.getUniqueId())); }