@Test
public void onPurchaseSuccessSucceedsForLateLogin() {

    // Configure
    final PublishSubject<Boolean> loggedInStream = PublishSubject.create();
    loggedInStream.onNext(false);
    when(identityManager.isLoggedInStream()).thenReturn(loggedInStream);
    when(defaultInAppPurchaseConsumer.consumePurchase(managedProduct, PurchaseFamily.Ocr)).thenReturn(Completable.complete());
    when(mobileAppPurchasesService.addPurchase(any(PurchaseRequest.class))).thenReturn(Observable.just(purchaseResponse));
    // Test
    ocrPurchaseTracker.onPurchaseSuccess(InAppPurchase.OcrScans50, PurchaseSource.Unknown);
    loggedInStream.onNext(true);
    // Verify
    verify(defaultInAppPurchaseConsumer).consumePurchase(managedProduct, PurchaseFamily.Ocr);
    verify(localOcrScansTracker).setRemainingScans(REMAINING_SCANS);
}