Product implements Parcelable { public static Product create(String json) throws JSONException { return create(new JSONObject(json)); }  abstract String vendorId(); abstract String sku(); abstract String price(); abstract String currency(); abstract String name(); abstract String description(); abstract boolean isSubscription(); abstract long microsPrice(); static Product create(String json); static Product create(JSONObject json); static Product create(String vendorId,
                               String sku,
                               String price,
                               String currency,
                               String name,
                               String description,
                               boolean isSubscription,
                               long microsPrice); JSONObject toJson(); String toJsonString(); static final String KEY_VENDOR_ID; static final String KEY_SKU; static final String KEY_PRICE; static final String KEY_CURRENCY; static final String KEY_NAME; static final String KEY_DESCRIPTION; static final String KEY_IS_SUB; static final String KEY_MICRO_PRICE; }
@Test public void acceptsValidJson() throws JSONException { Product.create( "{\"micros-price\":1," + "\"vendor-id\":\"1\"," + "\"price\":\"1\"," + "\"name\":\"1\"," + "\"description\":\"1\"," + "\"currency\":\"1\"," + "\"subscription\":false," + "\"sku\":\"1\"}" ); }
@Test(expected = JSONException.class) public void rejectsInvalidJson() throws JSONException { Product.create("bad json"); }