TriggerDelta extends Trigger { @Override public synchronized String toJSON() { JSONObject o = new JSONObject(); try { o.put("type", TriggerDelta.class.getName()); JSONObject data = new JSONObject(); data.put("value", getValue()); data.put("units", units); data.put("lastRun", lastRun); data.put("deltaType", getType()); data.put("comparator", comparator.getValue().toString()); o.put("data", data); } catch (JSONException e) { log.error("Unhandled exception", e); } return o.toString(); } TriggerDelta(); private  TriggerDelta(TriggerDelta triggerDelta); double getValue(); DeltaType getType(); String getUnits(); Comparator getComparator(); @Override synchronized boolean shouldRun(); @Override synchronized String toJSON(); @Override int friendlyName(); @Override String friendlyDescription(); @Override Optional<Integer> icon(); @Override Trigger duplicate(); @Override void generateDialog(LinearLayout root, FragmentManager fragmentManager);  }
@Test public void toJSONTest() { TriggerDelta t = new TriggerDelta().setUnits(Constants.MMOL).setValue(4.1d, DeltaType.DELTA).comparator(Comparator.Compare.IS_EQUAL); Assert.assertEquals(deltaJson, t.toJSON()); }