DefaultPurchaseWallet implements PurchaseWallet { @Override public synchronized void updateRemotePurchases(@NonNull Set<RemoteSubscription> remoteSubscriptions) { final Set<InAppPurchase> remotePurchases = new HashSet<>(); for (final RemoteSubscription remoteSubscription : remoteSubscriptions) { remotePurchases.add(remoteSubscription.getInAppPurchase()); } if (!getRemotelyOwnedPurchases().equals(remotePurchases)) { this.remotelyOwnedPurchases = remotePurchases; persistWallet(); } } @Inject  DefaultPurchaseWallet(@NonNull Lazy<SharedPreferences> preferences); @Override synchronized boolean hasActivePurchase(@NonNull InAppPurchase inAppPurchase); @NonNull @Override Set<ManagedProduct> getActiveLocalInAppPurchases(); @Nullable @Override synchronized ManagedProduct getLocalInAppManagedProduct(@NonNull InAppPurchase inAppPurchase); @Override synchronized void updateLocalInAppPurchasesInWallet(@NonNull Set<ManagedProduct> managedProducts); @Override synchronized void updateRemotePurchases(@NonNull Set<RemoteSubscription> remoteSubscriptions); @Override synchronized void addLocalInAppPurchaseToWallet(@NonNull ManagedProduct managedProduct);  }
@Test public void updateRemotePurchases() { assertFalse(defaultPurchaseWallet.hasActivePurchase(InAppPurchase.SmartReceiptsPlus)); final RemoteSubscription remoteSubscription = new RemoteSubscription(1, InAppPurchase.SmartReceiptsPlus, new Date()); defaultPurchaseWallet.updateRemotePurchases(Collections.singleton(remoteSubscription)); assertTrue(defaultPurchaseWallet.hasActivePurchase(InAppPurchase.SmartReceiptsPlus)); final PurchaseWallet newWallet = new DefaultPurchaseWallet(sharedPreferencesLazy); assertTrue(newWallet.hasActivePurchase(InAppPurchase.SmartReceiptsPlus)); }