LocalOcrScansTracker { public void decrementRemainingScans() { if (getRemainingScans() > 0) { sharedPreferences.get().edit().putInt(KEY_AVAILABLE_SCANS, getRemainingScans() - 1).apply(); remainingScansSubject.onNext(getRemainingScans()); } } @Inject  LocalOcrScansTracker(@NonNull Lazy<SharedPreferences> sharedPreferences); @VisibleForTesting  LocalOcrScansTracker(@NonNull Lazy<SharedPreferences> sharedPreferences,
                         @NonNull Scheduler firstLocalScanReadScheduler); @NonNull Observable<Integer> getRemainingScansStream(); int getRemainingScans(); void setRemainingScans(int remainingScans); void decrementRemainingScans();  }
@Test public void decrementRemainingScans() { TestObserver<Integer> testObserver = localOcrScansTracker.getRemainingScansStream().test(); localOcrScansTracker.setRemainingScans(50); localOcrScansTracker.decrementRemainingScans(); assertEquals(49, localOcrScansTracker.getRemainingScans()); testObserver.assertValues(0, 50, 49); testObserver.assertNotComplete(); testObserver.assertNoErrors(); }