OcrPurchaseTracker implements PurchaseEventsListener { public boolean hasAvailableScans() { return localOcrScansTracker.getRemainingScans() > 0; } @Inject  OcrPurchaseTracker(@NonNull IdentityManager identityManager,
                              @NonNull WebServiceManager webServiceManager,
                              @NonNull PurchaseManager purchaseManager,
                              @NonNull PurchaseWallet purchaseWallet,
                              @NonNull DefaultInAppPurchaseConsumer defaultInAppPurchaseConsumer,
                              @NonNull LocalOcrScansTracker localOcrScansTracker); @VisibleForTesting  OcrPurchaseTracker(@NonNull IdentityManager identityManager,
                       @NonNull WebServiceManager webServiceManager,
                       @NonNull PurchaseManager purchaseManager,
                       @NonNull PurchaseWallet purchaseWallet,
                       @NonNull DefaultInAppPurchaseConsumer defaultInAppPurchaseConsumer,
                       @NonNull LocalOcrScansTracker localOcrScansTracker,
                       @NonNull Scheduler subscribeOnScheduler); @SuppressLint("CheckResult") void initialize(); @Override void onPurchaseSuccess(@NonNull InAppPurchase inAppPurchase, @NonNull PurchaseSource purchaseSource); @Override void onPurchaseFailed(@NonNull PurchaseSource purchaseSource); int getRemainingScans(); Observable<Integer> getRemainingScansStream(); boolean hasAvailableScans(); void decrementRemainingScans();  }
@Test public void hasAvailableScans() { when(localOcrScansTracker.getRemainingScans()).thenReturn(50); assertTrue(ocrPurchaseTracker.hasAvailableScans()); when(localOcrScansTracker.getRemainingScans()).thenReturn(0); assertFalse(ocrPurchaseTracker.hasAvailableScans()); }