TriggerTimeRange extends Trigger { @Override public String toJSON() { JSONObject object = new JSONObject(); JSONObject data = new JSONObject(); if (start > 1440) start = getMinSinceMidnight(start); if (end > 1440) end = getMinSinceMidnight(end); try { data.put("start", getMinSinceMidnight(start)); data.put("end", getMinSinceMidnight(end)); data.put("lastRun", lastRun); object.put("type", TriggerTimeRange.class.getName()); object.put("data", data); } catch (JSONException e) { log.error("Unhandled exception", e); } log.debug(object.toString()); return object.toString(); } TriggerTimeRange(); private  TriggerTimeRange(TriggerTimeRange triggerTimeRange); @Override boolean shouldRun(); @Override String toJSON(); @Override int friendlyName(); @Override String friendlyDescription(); @Override Optional<Integer> icon(); @Override Trigger duplicate(); int getMinSinceMidnight(long time); @Override void generateDialog(LinearLayout root, FragmentManager fragmentManager);  }
@Test public void toJSONTest() { TriggerTimeRange t = new TriggerTimeRange().period(now - 1 - timeZoneOffset , now + 30 - timeZoneOffset); Assert.assertEquals(timeJson, t.toJSON()); }