@Test public void ensureAddedPurchaseIsPersistedAndPlusRemains() { plusPurchaseWallet.addLocalInAppPurchaseToWallet(managedProduct); final PurchaseWallet newWallet = new PlusPurchaseWallet(sharedPreferencesLazy); assertTrue(newWallet.hasActivePurchase(InAppPurchase.SmartReceiptsPlus)); assertNull(newWallet.getLocalInAppManagedProduct(InAppPurchase.SmartReceiptsPlus)); assertTrue(plusPurchaseWallet.hasActivePurchase(InAppPurchase.SmartReceiptsPlus)); assertNull(plusPurchaseWallet.getLocalInAppManagedProduct(InAppPurchase.SmartReceiptsPlus)); assertTrue(newWallet.hasActivePurchase(InAppPurchase.OcrScans50)); assertEquals(managedProduct, newWallet.getLocalInAppManagedProduct(InAppPurchase.OcrScans50)); assertEquals(newWallet.getActiveLocalInAppPurchases(), Collections.singleton(managedProduct)); assertTrue(plusPurchaseWallet.hasActivePurchase(InAppPurchase.OcrScans50)); assertEquals(managedProduct, plusPurchaseWallet.getLocalInAppManagedProduct(InAppPurchase.OcrScans50)); assertEquals(plusPurchaseWallet.getActiveLocalInAppPurchases(), Collections.singleton(managedProduct)); assertEquals(preferences.getStringSet("key_sku_set", Collections.<String>emptySet()), Collections.singleton(InAppPurchase.OcrScans50.getSku())); assertEquals(preferences.getString("ocr_purchase_1_purchaseData", null), this.purchaseData); assertEquals(preferences.getString("ocr_purchase_1_inAppDataSignature", null), IN_APP_DATA_SIGNATURE); }
@Override public synchronized boolean hasActivePurchase(@NonNull InAppPurchase inAppPurchase) { if (inAppPurchase == InAppPurchase.SmartReceiptsPlus) { return true; } else { return super.hasActivePurchase(inAppPurchase); } }
PlusPurchaseWallet extends DefaultPurchaseWallet { @Override public synchronized boolean hasActivePurchase(@NonNull InAppPurchase inAppPurchase) { if (inAppPurchase == InAppPurchase.SmartReceiptsPlus) { return true; } else { return super.hasActivePurchase(inAppPurchase); } } }
PlusPurchaseWallet extends DefaultPurchaseWallet { @Override public synchronized boolean hasActivePurchase(@NonNull InAppPurchase inAppPurchase) { if (inAppPurchase == InAppPurchase.SmartReceiptsPlus) { return true; } else { return super.hasActivePurchase(inAppPurchase); } } @Inject  PlusPurchaseWallet(@NonNull Lazy<SharedPreferences> preferences); }
PlusPurchaseWallet extends DefaultPurchaseWallet { @Override public synchronized boolean hasActivePurchase(@NonNull InAppPurchase inAppPurchase) { if (inAppPurchase == InAppPurchase.SmartReceiptsPlus) { return true; } else { return super.hasActivePurchase(inAppPurchase); } } @Inject  PlusPurchaseWallet(@NonNull Lazy<SharedPreferences> preferences); @Override synchronized boolean hasActivePurchase(@NonNull InAppPurchase inAppPurchase); }
PlusPurchaseWallet extends DefaultPurchaseWallet { @Override public synchronized boolean hasActivePurchase(@NonNull InAppPurchase inAppPurchase) { if (inAppPurchase == InAppPurchase.SmartReceiptsPlus) { return true; } else { return super.hasActivePurchase(inAppPurchase); } } @Inject  PlusPurchaseWallet(@NonNull Lazy<SharedPreferences> preferences); @Override synchronized boolean hasActivePurchase(@NonNull InAppPurchase inAppPurchase);  }