ImportInfoTooltipManager implements TooltipManager { public Observable<Boolean> needToShowImportInfo() { return intentImportProcessor.getLastResult() .map(intentImportResultOptional -> { if (intentImportResultOptional.isPresent()) { final FileType fileType = intentImportResultOptional.get().getFileType(); return fileType == FileType.Image || fileType == FileType.Pdf; } else { return false; } }); } @Inject  ImportInfoTooltipManager(@NonNull IntentImportProcessor intentImportProcessor, @NonNull IntentImportProvider intentImportProvider); Observable<Boolean> needToShowImportInfo(); @Override void tooltipWasDismissed();  }
@Test public void notShowImportInfo() { when(intentImportProcessor.getLastResult()).thenReturn(Observable.just(Optional.absent())); manager.needToShowImportInfo() .test() .assertComplete() .assertNoErrors() .assertValueCount(1) .assertValue(false); }
@Test public void showImportInfoForImage() { when(intentImportProcessor.getLastResult()).thenReturn(Observable.just(Optional.of(new IntentImportResult(fakeUri, FileType.Image)))); manager.needToShowImportInfo() .test() .assertComplete() .assertNoErrors() .assertValueCount(1) .assertValue(true); }
@Test public void showImportInfoForPdf() { when(intentImportProcessor.getLastResult()).thenReturn(Observable.just(Optional.of(new IntentImportResult(fakeUri, FileType.Pdf)))); manager.needToShowImportInfo() .test() .assertComplete() .assertNoErrors() .assertValueCount(1) .assertValue(true); }
@Test public void notShowImportInfoForBackup() { when(intentImportProcessor.getLastResult()).thenReturn(Observable.just(Optional.of(new IntentImportResult(fakeUri, FileType.Smr)))); manager.needToShowImportInfo() .test() .assertComplete() .assertNoErrors() .assertValueCount(1) .assertValue(false); }