Discount implements Serializable { public static Discount fromJSON(JSONObject o) throws JSONException, ParseException { String id = o.getString("id"); String label = o.getString("label"); double rate = o.getDouble("rate"); String startDate = o.getString("startDate"); String endDate = o.getString("endDate"); String barcode = o.getString("barcode"); int barcodeType = o.getInt("barcodeType"); return new Discount(id, label, rate, startDate, endDate, barcode, barcodeType); } Discount(String id, String label, double rate, String start, String end, String barcode, int barcodeType);  Discount(String id, double rate, String start, String end, String barcode, int barcodeType); String getId(); double getRate(); Date getStartDate(); Date getEndDate(); Barcode getBarcode(); void setId(String id); void setRate(double rate); void setStartDate(String startDate); void setStartDate(Date startDate); void setEndDate(String endDate); void setEndDate(Date endDate); void setBarcode(String barcode); void setBarcodeType(int barcodeType); static Date convertDateFromString(String dateInString); static String convertDateToString(Date date); static Discount fromJSON(JSONObject o); JSONObject toJSON(); @Override boolean equals(Object o); String getTitle(Context ctx); String getDate(Context ctx); boolean isValid(); final static int DEFAULT_DISCOUNT_RATE; }
@Test public void fromJSONTest() throws JSONException, ParseException { Discount discount = Discount.fromJSON(this.discount_json_model); this.compare(discount, this.discount_model); }