### Question:
ContentEditorPresenter { public void uploadImageWithImgurAPI(File file) { if (file != null) { Upload upload = new Upload(); upload.image = file; imgurUpload.uploadImage(upload, clientId) .subscribeOn(scheduleOn) .observeOn(observeOn) .doOnSubscribe(() -> callback.showImageLoading(upload.image.getName())) .filter(ImageResponse::isSucces) .subscribe(o -> { String name = null; name = file.getName(); setImageUrl(name, o.data.link); callback.onImageUploaded(upload.image.getName(), o.data.link); }, throwable -> { callback.showImageUploadError(upload.image.getName()); }); } else { callback.showImageUploadError(null); } } ContentEditorPresenter(String clientId, ImgurUpload imgurUpload, Scheduler observeOn, Scheduler scheduleOn); void uploadImageWithImgurAPI(File file); void setImageUrl(String name, String link); void setCallback(Callback callback);  }### Answer:
@Test public void shouldCallShowImageLoading_WhenFileIsOk() throws Exception { Observable<ImageResponse> obs = Observable.just(validImageResponse); when(imgurUpload.uploadImage(any(Upload.class), anyString())).thenReturn(obs); contentEditorPresenter.uploadImageWithImgurAPI(file); verify(callback).showImageLoading(anyString()); }
@Test public void shouldCallHideImageLoading_WhenFileIsOk() throws Exception { Observable<ImageResponse> obs = Observable.just(validImageResponse); when(imgurUpload.uploadImage(any(Upload.class), anyString())).thenReturn(obs); contentEditorPresenter.uploadImageWithImgurAPI(file); verify(callback).onImageUploaded(anyString(), anyString()); }
@Test public void shouldCallAppendText_WhenFileIsOk() throws Exception { Observable<ImageResponse> obs = Observable.just(validImageResponse); when(imgurUpload.uploadImage(any(Upload.class), anyString())).thenReturn(obs); contentEditorPresenter.uploadImageWithImgurAPI(file); verify(callback).appendText(buildResult(file.getName())); }
@Test public void shouldCallShowImageUploadError_WhenReturnsException() throws Exception { Observable<ImageResponse> obs = Observable.error(new Exception()); when(imgurUpload.uploadImage(any(Upload.class), anyString())).thenReturn(obs); contentEditorPresenter.uploadImageWithImgurAPI(null); verify(callback).showImageUploadError(null); }