Cashier { public static Product productFromVendor(String json) throws JSONException { return productFromVendor(new JSONObject(json)); } private  Cashier(Context context, Vendor vendor); static void putVendorFactory(String vendorId, VendorFactory factory); static VendorFactory getVendorFactory(String vendorId); static Builder forInstaller(Context context); static Builder forVendor(Context context, Vendor vendor); static Builder forPurchase(Context context, Purchase purchase); static Builder forProduct(Context context, Product product); static Product productFromVendor(String json); static Product productFromVendor(JSONObject json); static Purchase purchaseFromVendor(String json); static Purchase purchaseFromVendor(JSONObject json); void purchase(Activity activity, Product product, PurchaseListener listener); void purchase(final Activity activity,
                       final Product product,
                       @Nullable final String developerPayload,
                       final PurchaseListener purchaseListener); void consume(final Purchase purchase, final ConsumeListener listener); void getInventory(final InventoryListener listener); void getInventory(@Nullable final Collection<String> itemSkus,
                           @Nullable final Collection<String> subSkus,
                           final InventoryListener listener); void getProductDetails(final String sku, final boolean isSubscription, final ProductDetailsListener listener); String vendorId(); void dispose(); boolean onActivityResult(int requestCode, int resultCode, Intent data);  }
@Test public void getsProductFromVendor() throws JSONException { when(testVendor.getProductFrom(any(JSONObject.class))).thenAnswer(new Answer<Product>() { @Override public Product answer(InvocationOnMock invocation) throws Throwable { return Product.create((JSONObject) invocation.getArgument(0)); } }); final String productJson = "{\"micros-price\":1," + "\"vendor-id\":\"" + TEST_VENDOR_ID + "\"," + "\"price\":\"1\"," + "\"name\":\"1\"," + "\"description\":\"1\"," + "\"currency\":\"1\"," + "\"subscription\":false," + "\"sku\":\"1\"}"; final Product fromVendor = Cashier.productFromVendor(productJson); assertThat(fromVendor).isEqualTo(Product.create(productJson)); }