@Test public void consumePurchaseForSubscription() { defaultInAppPurchaseConsumer.consumePurchase(subscription, PurchaseFamily.Ocr); verify(subscriptionInAppPurchaseConsumer).consumePurchase(subscription, PurchaseFamily.Ocr); verifyZeroInteractions(consumableInAppPurchaseConsumer); }
@Override public Completable consumePurchase(@NonNull ManagedProduct managedProduct, @NonNull PurchaseFamily purchaseFamily) { if (managedProduct instanceof ConsumablePurchase) { return consumableInAppPurchaseConsumer.consumePurchase((ConsumablePurchase)managedProduct, purchaseFamily); } else if (managedProduct instanceof Subscription) { return subscriptionInAppPurchaseConsumer.consumePurchase((Subscription)managedProduct, purchaseFamily); } else { throw new IllegalArgumentException("Unsupported managed product type: " + managedProduct); } }
DefaultInAppPurchaseConsumer implements InAppPurchaseConsumer<ManagedProduct> { @Override public Completable consumePurchase(@NonNull ManagedProduct managedProduct, @NonNull PurchaseFamily purchaseFamily) { if (managedProduct instanceof ConsumablePurchase) { return consumableInAppPurchaseConsumer.consumePurchase((ConsumablePurchase)managedProduct, purchaseFamily); } else if (managedProduct instanceof Subscription) { return subscriptionInAppPurchaseConsumer.consumePurchase((Subscription)managedProduct, purchaseFamily); } else { throw new IllegalArgumentException("Unsupported managed product type: " + managedProduct); } } }
DefaultInAppPurchaseConsumer implements InAppPurchaseConsumer<ManagedProduct> { @Override public Completable consumePurchase(@NonNull ManagedProduct managedProduct, @NonNull PurchaseFamily purchaseFamily) { if (managedProduct instanceof ConsumablePurchase) { return consumableInAppPurchaseConsumer.consumePurchase((ConsumablePurchase)managedProduct, purchaseFamily); } else if (managedProduct instanceof Subscription) { return subscriptionInAppPurchaseConsumer.consumePurchase((Subscription)managedProduct, purchaseFamily); } else { throw new IllegalArgumentException("Unsupported managed product type: " + managedProduct); } } @Inject  DefaultInAppPurchaseConsumer(@NonNull ConsumableInAppPurchaseConsumer consumableInAppPurchaseConsumer,
                                        @NonNull SubscriptionInAppPurchaseConsumer subscriptionInAppPurchaseConsumer); }
DefaultInAppPurchaseConsumer implements InAppPurchaseConsumer<ManagedProduct> { @Override public Completable consumePurchase(@NonNull ManagedProduct managedProduct, @NonNull PurchaseFamily purchaseFamily) { if (managedProduct instanceof ConsumablePurchase) { return consumableInAppPurchaseConsumer.consumePurchase((ConsumablePurchase)managedProduct, purchaseFamily); } else if (managedProduct instanceof Subscription) { return subscriptionInAppPurchaseConsumer.consumePurchase((Subscription)managedProduct, purchaseFamily); } else { throw new IllegalArgumentException("Unsupported managed product type: " + managedProduct); } } @Inject  DefaultInAppPurchaseConsumer(@NonNull ConsumableInAppPurchaseConsumer consumableInAppPurchaseConsumer,
                                        @NonNull SubscriptionInAppPurchaseConsumer subscriptionInAppPurchaseConsumer); @Override boolean isConsumed(@NonNull ManagedProduct managedProduct, @NonNull PurchaseFamily purchaseFamily); @Override Completable consumePurchase(@NonNull ManagedProduct managedProduct, @NonNull PurchaseFamily purchaseFamily); }
DefaultInAppPurchaseConsumer implements InAppPurchaseConsumer<ManagedProduct> { @Override public Completable consumePurchase(@NonNull ManagedProduct managedProduct, @NonNull PurchaseFamily purchaseFamily) { if (managedProduct instanceof ConsumablePurchase) { return consumableInAppPurchaseConsumer.consumePurchase((ConsumablePurchase)managedProduct, purchaseFamily); } else if (managedProduct instanceof Subscription) { return subscriptionInAppPurchaseConsumer.consumePurchase((Subscription)managedProduct, purchaseFamily); } else { throw new IllegalArgumentException("Unsupported managed product type: " + managedProduct); } } @Inject  DefaultInAppPurchaseConsumer(@NonNull ConsumableInAppPurchaseConsumer consumableInAppPurchaseConsumer,
                                        @NonNull SubscriptionInAppPurchaseConsumer subscriptionInAppPurchaseConsumer); @Override boolean isConsumed(@NonNull ManagedProduct managedProduct, @NonNull PurchaseFamily purchaseFamily); @Override Completable consumePurchase(@NonNull ManagedProduct managedProduct, @NonNull PurchaseFamily purchaseFamily);  }