@Test public void getAvailableConsumablePurchasesThrowsRemoteException() throws Exception { final Bundle getSkuDetailsResponse = new Bundle(); getSkuDetailsResponse.putInt("RESPONSE_CODE", RESULT_ERROR); when(inAppBillingService.getSkuDetails(eq(3), eq(packageName), eq("inapp"), bundleCaptor.capture())).thenThrow(new RemoteException()); purchaseManager.getAvailableConsumablePurchases().test() .assertNoValues() .assertNotComplete() .assertError(RemoteException.class); verifyZeroInteractions(purchaseWallet); assertEquals(bundleCaptor.getValue().getStringArrayList("ITEM_ID_LIST"), InAppPurchase.getConsumablePurchaseSkus()); }
@NonNull @VisibleForTesting Observable<Set<AvailablePurchase>> getAvailableConsumablePurchases() { return getAvailablePurchases(InAppPurchase.getConsumablePurchaseSkus(), ConsumablePurchase.GOOGLE_PRODUCT_TYPE); }
PurchaseManager { @NonNull @VisibleForTesting Observable<Set<AvailablePurchase>> getAvailableConsumablePurchases() { return getAvailablePurchases(InAppPurchase.getConsumablePurchaseSkus(), ConsumablePurchase.GOOGLE_PRODUCT_TYPE); } }
PurchaseManager { @NonNull @VisibleForTesting Observable<Set<AvailablePurchase>> getAvailableConsumablePurchases() { return getAvailablePurchases(InAppPurchase.getConsumablePurchaseSkus(), ConsumablePurchase.GOOGLE_PRODUCT_TYPE); } @Inject  PurchaseManager(@NonNull Context context,
                           @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                           @NonNull PurchaseWallet purchaseWallet,
                           @NonNull Analytics analytics); @VisibleForTesting  PurchaseManager(@NonNull Context context,
                    @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                    @NonNull PurchaseWallet purchaseWallet,
                    @NonNull Analytics analytics,
                    @NonNull Scheduler subscribeOnScheduler,
                    @NonNull Scheduler observeOnScheduler); }
PurchaseManager { @NonNull @VisibleForTesting Observable<Set<AvailablePurchase>> getAvailableConsumablePurchases() { return getAvailablePurchases(InAppPurchase.getConsumablePurchaseSkus(), ConsumablePurchase.GOOGLE_PRODUCT_TYPE); } @Inject  PurchaseManager(@NonNull Context context,
                           @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                           @NonNull PurchaseWallet purchaseWallet,
                           @NonNull Analytics analytics); @VisibleForTesting  PurchaseManager(@NonNull Context context,
                    @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                    @NonNull PurchaseWallet purchaseWallet,
                    @NonNull Analytics analytics,
                    @NonNull Scheduler subscribeOnScheduler,
                    @NonNull Scheduler observeOnScheduler); void addEventListener(@NonNull PurchaseEventsListener listener); void removeEventListener(@NonNull PurchaseEventsListener listener); @SuppressLint("CheckResult") @SuppressWarnings("ResultOfMethodCallIgnored") void initialize(@NonNull Application application); void onActivityResumed(@NonNull Activity activity); void onActivityPaused(); void initiatePurchase(@NonNull final InAppPurchase inAppPurchase, @NonNull final PurchaseSource purchaseSource); @VisibleForTesting void sendMockPurchaseRequest(@NonNull InAppPurchase inAppPurchase); boolean onActivityResult(int requestCode, int resultCode, @Nullable Intent data); @NonNull Observable<Set<ManagedProduct>> getAllOwnedPurchases(); @NonNull Observable<Set<AvailablePurchase>> getAllAvailablePurchases(); @NonNull Observable<Set<InAppPurchase>> getAllAvailablePurchaseSkus(); @NonNull Completable consumePurchase(@NonNull final ConsumablePurchase consumablePurchase); }
PurchaseManager { @NonNull @VisibleForTesting Observable<Set<AvailablePurchase>> getAvailableConsumablePurchases() { return getAvailablePurchases(InAppPurchase.getConsumablePurchaseSkus(), ConsumablePurchase.GOOGLE_PRODUCT_TYPE); } @Inject  PurchaseManager(@NonNull Context context,
                           @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                           @NonNull PurchaseWallet purchaseWallet,
                           @NonNull Analytics analytics); @VisibleForTesting  PurchaseManager(@NonNull Context context,
                    @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                    @NonNull PurchaseWallet purchaseWallet,
                    @NonNull Analytics analytics,
                    @NonNull Scheduler subscribeOnScheduler,
                    @NonNull Scheduler observeOnScheduler); void addEventListener(@NonNull PurchaseEventsListener listener); void removeEventListener(@NonNull PurchaseEventsListener listener); @SuppressLint("CheckResult") @SuppressWarnings("ResultOfMethodCallIgnored") void initialize(@NonNull Application application); void onActivityResumed(@NonNull Activity activity); void onActivityPaused(); void initiatePurchase(@NonNull final InAppPurchase inAppPurchase, @NonNull final PurchaseSource purchaseSource); @VisibleForTesting void sendMockPurchaseRequest(@NonNull InAppPurchase inAppPurchase); boolean onActivityResult(int requestCode, int resultCode, @Nullable Intent data); @NonNull Observable<Set<ManagedProduct>> getAllOwnedPurchases(); @NonNull Observable<Set<AvailablePurchase>> getAllAvailablePurchases(); @NonNull Observable<Set<InAppPurchase>> getAllAvailablePurchaseSkus(); @NonNull Completable consumePurchase(@NonNull final ConsumablePurchase consumablePurchase); static final int REQUEST_CODE; }