Discount implements Serializable { public JSONObject toJSON() throws JSONException, ParseException { JSONObject o = new JSONObject(); o.put("id", this.id); o.put("label", this.label); o.put("rate", this.rate); o.put("startDate", convertDateToString(this.startDate)); o.put("endDate", convertDateToString(this.endDate)); o.put("barcode", this.barcode.getCode()); o.put("barcodeType", this.barcode.getType()); return o; } 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 toJSONTest() throws Exception { JSONObject obj = this.discount_model.toJSON(); org.skyscreamer.jsonassert.JSONAssert.assertEquals(obj, this.discount_json_model, false); }