@Test public void getShowOcrTooltipWhenOcrIsNotEnabled() { when(stateTracker.shouldShowOcrInfo()).thenReturn(Single.just(true)); when(configurationManager.isEnabled(ConfigurableResourceFeature.Ocr)).thenReturn(false); TestObserver<OcrTooltipMessageType> testObserver = interactor.getShowOcrTooltip().test(); testObserver.awaitTerminalEvent(); testObserver.assertNoValues(); testObserver.assertComplete(); testObserver.assertNoErrors(); verify(stateTracker, never()).setShouldShowOcrInfo(anyBoolean()); }
@NonNull public Observable<OcrTooltipMessageType> getShowOcrTooltip() { return stateTracker.shouldShowOcrInfo() .subscribeOn(Schedulers.computation()) .flatMapObservable(shouldShowTooltip -> { if (shouldShowTooltip) { if (!configurationManager.isEnabled(ConfigurableResourceFeature.Ocr)) { Logger.info(OcrInformationalTooltipInteractor.this, "OCR is not configured. Disabling the tooltip"); return Observable.empty(); } if (ocrPurchaseTracker.getRemainingScans() > 0 && ocrPurchaseTracker.getRemainingScans() <= SCANS_LEFT_TO_INFORM) { return Observable.just(OcrTooltipMessageType.LimitedScansRemaining); } if (identityManager.isLoggedIn()) { if (ocrPurchaseTracker.hasAvailableScans()) { return Observable.empty(); } else { return Observable.just(OcrTooltipMessageType.NoScansRemaining); } } else { return Observable.just(OcrTooltipMessageType.NotConfigured); } } else { return Observable.empty(); } }) .doOnNext(ocrTooltipMessageType -> { Logger.info(OcrInformationalTooltipInteractor.this, "Displaying OCR Tooltip: {}", ocrTooltipMessageType); analytics.record(new DefaultDataPointEvent(Events.Ocr.OcrInfoTooltipShown).addDataPoint(new DataPoint("type", ocrTooltipMessageType))); }); }
OcrInformationalTooltipInteractor { @NonNull public Observable<OcrTooltipMessageType> getShowOcrTooltip() { return stateTracker.shouldShowOcrInfo() .subscribeOn(Schedulers.computation()) .flatMapObservable(shouldShowTooltip -> { if (shouldShowTooltip) { if (!configurationManager.isEnabled(ConfigurableResourceFeature.Ocr)) { Logger.info(OcrInformationalTooltipInteractor.this, "OCR is not configured. Disabling the tooltip"); return Observable.empty(); } if (ocrPurchaseTracker.getRemainingScans() > 0 && ocrPurchaseTracker.getRemainingScans() <= SCANS_LEFT_TO_INFORM) { return Observable.just(OcrTooltipMessageType.LimitedScansRemaining); } if (identityManager.isLoggedIn()) { if (ocrPurchaseTracker.hasAvailableScans()) { return Observable.empty(); } else { return Observable.just(OcrTooltipMessageType.NoScansRemaining); } } else { return Observable.just(OcrTooltipMessageType.NotConfigured); } } else { return Observable.empty(); } }) .doOnNext(ocrTooltipMessageType -> { Logger.info(OcrInformationalTooltipInteractor.this, "Displaying OCR Tooltip: {}", ocrTooltipMessageType); analytics.record(new DefaultDataPointEvent(Events.Ocr.OcrInfoTooltipShown).addDataPoint(new DataPoint("type", ocrTooltipMessageType))); }); } }
OcrInformationalTooltipInteractor { @NonNull public Observable<OcrTooltipMessageType> getShowOcrTooltip() { return stateTracker.shouldShowOcrInfo() .subscribeOn(Schedulers.computation()) .flatMapObservable(shouldShowTooltip -> { if (shouldShowTooltip) { if (!configurationManager.isEnabled(ConfigurableResourceFeature.Ocr)) { Logger.info(OcrInformationalTooltipInteractor.this, "OCR is not configured. Disabling the tooltip"); return Observable.empty(); } if (ocrPurchaseTracker.getRemainingScans() > 0 && ocrPurchaseTracker.getRemainingScans() <= SCANS_LEFT_TO_INFORM) { return Observable.just(OcrTooltipMessageType.LimitedScansRemaining); } if (identityManager.isLoggedIn()) { if (ocrPurchaseTracker.hasAvailableScans()) { return Observable.empty(); } else { return Observable.just(OcrTooltipMessageType.NoScansRemaining); } } else { return Observable.just(OcrTooltipMessageType.NotConfigured); } } else { return Observable.empty(); } }) .doOnNext(ocrTooltipMessageType -> { Logger.info(OcrInformationalTooltipInteractor.this, "Displaying OCR Tooltip: {}", ocrTooltipMessageType); analytics.record(new DefaultDataPointEvent(Events.Ocr.OcrInfoTooltipShown).addDataPoint(new DataPoint("type", ocrTooltipMessageType))); }); } @Inject  OcrInformationalTooltipInteractor(@NonNull Analytics analytics,
                                             @NonNull OcrInformationalTooltipStateTracker stateTracker,
                                             @NonNull OcrPurchaseTracker ocrPurchaseTracker,
                                             @NonNull IdentityManager identityManager,
                                             @NonNull ConfigurationManager configurationManager); @VisibleForTesting  OcrInformationalTooltipInteractor(@NonNull Analytics analytics,
                                      @NonNull OcrInformationalTooltipStateTracker stateTracker,
                                      @NonNull OcrPurchaseTracker ocrPurchaseTracker,
                                      @NonNull IdentityManager identityManager,
                                      @NonNull ConfigurationManager configurationManager,
                                      @NonNull Scheduler scheduler); }
OcrInformationalTooltipInteractor { @NonNull public Observable<OcrTooltipMessageType> getShowOcrTooltip() { return stateTracker.shouldShowOcrInfo() .subscribeOn(Schedulers.computation()) .flatMapObservable(shouldShowTooltip -> { if (shouldShowTooltip) { if (!configurationManager.isEnabled(ConfigurableResourceFeature.Ocr)) { Logger.info(OcrInformationalTooltipInteractor.this, "OCR is not configured. Disabling the tooltip"); return Observable.empty(); } if (ocrPurchaseTracker.getRemainingScans() > 0 && ocrPurchaseTracker.getRemainingScans() <= SCANS_LEFT_TO_INFORM) { return Observable.just(OcrTooltipMessageType.LimitedScansRemaining); } if (identityManager.isLoggedIn()) { if (ocrPurchaseTracker.hasAvailableScans()) { return Observable.empty(); } else { return Observable.just(OcrTooltipMessageType.NoScansRemaining); } } else { return Observable.just(OcrTooltipMessageType.NotConfigured); } } else { return Observable.empty(); } }) .doOnNext(ocrTooltipMessageType -> { Logger.info(OcrInformationalTooltipInteractor.this, "Displaying OCR Tooltip: {}", ocrTooltipMessageType); analytics.record(new DefaultDataPointEvent(Events.Ocr.OcrInfoTooltipShown).addDataPoint(new DataPoint("type", ocrTooltipMessageType))); }); } @Inject  OcrInformationalTooltipInteractor(@NonNull Analytics analytics,
                                             @NonNull OcrInformationalTooltipStateTracker stateTracker,
                                             @NonNull OcrPurchaseTracker ocrPurchaseTracker,
                                             @NonNull IdentityManager identityManager,
                                             @NonNull ConfigurationManager configurationManager); @VisibleForTesting  OcrInformationalTooltipInteractor(@NonNull Analytics analytics,
                                      @NonNull OcrInformationalTooltipStateTracker stateTracker,
                                      @NonNull OcrPurchaseTracker ocrPurchaseTracker,
                                      @NonNull IdentityManager identityManager,
                                      @NonNull ConfigurationManager configurationManager,
                                      @NonNull Scheduler scheduler); @SuppressLint("CheckResult") @SuppressWarnings("ResultOfMethodCallIgnored") void initialize(); @NonNull Observable<OcrTooltipMessageType> getShowOcrTooltip(); void markTooltipInteraction(); }
OcrInformationalTooltipInteractor { @NonNull public Observable<OcrTooltipMessageType> getShowOcrTooltip() { return stateTracker.shouldShowOcrInfo() .subscribeOn(Schedulers.computation()) .flatMapObservable(shouldShowTooltip -> { if (shouldShowTooltip) { if (!configurationManager.isEnabled(ConfigurableResourceFeature.Ocr)) { Logger.info(OcrInformationalTooltipInteractor.this, "OCR is not configured. Disabling the tooltip"); return Observable.empty(); } if (ocrPurchaseTracker.getRemainingScans() > 0 && ocrPurchaseTracker.getRemainingScans() <= SCANS_LEFT_TO_INFORM) { return Observable.just(OcrTooltipMessageType.LimitedScansRemaining); } if (identityManager.isLoggedIn()) { if (ocrPurchaseTracker.hasAvailableScans()) { return Observable.empty(); } else { return Observable.just(OcrTooltipMessageType.NoScansRemaining); } } else { return Observable.just(OcrTooltipMessageType.NotConfigured); } } else { return Observable.empty(); } }) .doOnNext(ocrTooltipMessageType -> { Logger.info(OcrInformationalTooltipInteractor.this, "Displaying OCR Tooltip: {}", ocrTooltipMessageType); analytics.record(new DefaultDataPointEvent(Events.Ocr.OcrInfoTooltipShown).addDataPoint(new DataPoint("type", ocrTooltipMessageType))); }); } @Inject  OcrInformationalTooltipInteractor(@NonNull Analytics analytics,
                                             @NonNull OcrInformationalTooltipStateTracker stateTracker,
                                             @NonNull OcrPurchaseTracker ocrPurchaseTracker,
                                             @NonNull IdentityManager identityManager,
                                             @NonNull ConfigurationManager configurationManager); @VisibleForTesting  OcrInformationalTooltipInteractor(@NonNull Analytics analytics,
                                      @NonNull OcrInformationalTooltipStateTracker stateTracker,
                                      @NonNull OcrPurchaseTracker ocrPurchaseTracker,
                                      @NonNull IdentityManager identityManager,
                                      @NonNull ConfigurationManager configurationManager,
                                      @NonNull Scheduler scheduler); @SuppressLint("CheckResult") @SuppressWarnings("ResultOfMethodCallIgnored") void initialize(); @NonNull Observable<OcrTooltipMessageType> getShowOcrTooltip(); void markTooltipInteraction();  }