InAppBillingV3Vendor implements Vendor { @Override public void consume(Context context, Purchase purchase, ConsumeListener listener) { if (context == null || purchase == null || listener == null) { throw new IllegalArgumentException("Context, product, or listener is null"); } throwIfUninitialized(); final Product product = purchase.product(); if (product.isSubscription()) { throw new IllegalArgumentException("Cannot consume a subscription!"); } try { log("Consuming " + product.sku() + " " + purchase.token()); final int response = api.consumePurchase(purchase.token()); if (response == BILLING_RESPONSE_RESULT_OK) { log("Successfully consumed purchase!"); listener.success(purchase); } else { log("Couldn't consume purchase! " + response); listener.failure(purchase, consumeError(response)); } } catch (RemoteException e) { log("Couldn't consume purchase! " + Log.getStackTraceString(e)); listener.failure(purchase, consumeError(BILLING_RESPONSE_RESULT_ERROR)); } } InAppBillingV3Vendor();  InAppBillingV3Vendor(String publicKey64);  InAppBillingV3Vendor(AbstractInAppBillingV3API api);  InAppBillingV3Vendor(AbstractInAppBillingV3API api, @Nullable String publicKey64); @Override String id(); @Override void initialize(Context context, InitializationListener listener); @Override void dispose(Context context); @Override boolean available(); @Override boolean canPurchase(Product product); @Override void purchase(Activity activity, Product product, String developerPayload,
                       PurchaseListener listener); @Override void consume(Context context, Purchase purchase, ConsumeListener listener); @Override void getInventory(Context context, Collection<String> inappSkus, Collection<String> subSkus,
                           InventoryListener listener); @Override void getProductDetails(Context context, String sku, boolean isSubscription,
                                ProductDetailsListener listener); @Override void setLogger(@Nullable Logger logger); @Override boolean onActivityResult(int requestCode, int resultCode, Intent data); @Override Product getProductFrom(JSONObject json); @Override Purchase getPurchaseFrom(JSONObject json);  }
@Test(expected = IllegalStateException.class) public void consumeRequiresInitialization() throws RemoteException { InAppBillingV3Vendor vendor = new InAppBillingV3Vendor(api, null); vendor.consume(mock(Context.class), mock(Purchase.class), mock(ConsumeListener.class)); }