InAppBillingProduct { public static Product create(String skuDetailJson, boolean isSubscription) throws JSONException { final JSONObject json = new JSONObject(skuDetailJson); return create(json.getString(SKU), json.getString(PRICE), json.getString(CURRENCY), json.getString(NAME), json.getString(DESCRIPTION), isSubscription, Long.parseLong(json.getString(PRICE_MICRO))); } private  InAppBillingProduct(); static Product create(String skuDetailJson, boolean isSubscription); static Product create(String sku,
                               String price,
                               String currency,
                               String name,
                               String description,
                               boolean isSubscription,
                               long microsPrice);  }
@Test(expected = JSONException.class) public void rejectsInvalidJson() throws JSONException { InAppBillingProduct.create("bad json", false); }
@Test public void parsesJsonCorrectly() throws JSONException { Product product = InAppBillingProduct.create(IN_APP_BILLING_PRODUCT_VALID_PRODUCT_JSON, false); checkProduct(product); }
@Test public void allFieldsAreAssigned() { Product product = InAppBillingProduct.create( VALID_PRODUCT_JSON_SKU, VALID_PRODUCT_JSON_PRICE, VALID_PRODUCT_JSON_CURRENCY, VALID_PRODUCT_JSON_NAME, VALID_PRODUCT_JSON_DESCRIPTION, false, VALID_PRODUCT_JSON_MICROS_PRICE ); checkProduct(product); }