MediaSyncHelper { protected InputStream getReSizedPhoto(BaseModel baseModel, String fileName) throws IOException { String apiModel = baseModel.getClass().getSimpleName().toLowerCase(); String photoUrl = String.format("/%s/%s/photo/%s/resized/%sx%s", apiModel, baseModel.optString("_id"), fileName, PhotoCaptureHelper.PHOTO_WIDTH, PhotoCaptureHelper.PHOTO_HEIGHT); return entityHttpDao.getResourceStream(photoUrl); } MediaSyncHelper(EntityHttpDao<? extends BaseModel> entityHttpDao, RapidFtrApplication context); void addMultiMediaFilesToTheRequestParameters(BaseModel baseModel, Map<String, String> requestParameters); void setPhoto(BaseModel baseModel); void getPhotoFromServer(BaseModel baseModel, PhotoCaptureHelper photoCaptureHelper, String fileName); void setAudio(BaseModel baseModel); InputStream getAudio(BaseModel baseModel);  }
@Test public void shouldBuildPhotoUrlFromChildModel() throws IOException { EntityHttpDao<Child> spyDao = spy(new EntityHttpDao<Child>(application)); MediaSyncHelper helper = new MediaSyncHelper(spyDao, application); Child child = new Child(); child.put("_id", "1234"); doReturn(null).when(spyDao).getResourceStream(any(String.class)); helper.getReSizedPhoto(child, "image"); verify(spyDao).getResourceStream("/child/1234/photo/image/resized/475x635"); }
@Test public void shouldBuildPhotoUrlFromEnquiryModel() throws IOException, JSONException { EntityHttpDao<Child> spyDao = spy(new EntityHttpDao<Child>(application)); MediaSyncHelper helper = new MediaSyncHelper(spyDao, application); Enquiry enquiry = new Enquiry("{}"); enquiry.put("_id", "1234"); doReturn(null).when(spyDao).getResourceStream(any(String.class)); helper.getReSizedPhoto(enquiry, "image"); verify(spyDao).getResourceStream("/enquiry/1234/photo/image/resized/475x635"); }