TriggerRecurringTime extends Trigger { @Override Trigger fromJSON(String data) { JSONObject o; try { o = new JSONObject(data); lastRun = JsonHelper.safeGetLong(o, "lastRun"); for (int i = 0; i < weekdays.length; ++i) { weekdays[i] = JsonHelper.safeGetBoolean(o, DayOfWeek.values()[i].name()); } hour = JsonHelper.safeGetInt(o, "hour"); minute = JsonHelper.safeGetInt(o, "minute"); validTo = JsonHelper.safeGetLong(o, "validTo"); } catch (JSONException e) { log.error("Unhandled exception", e); } return this; } TriggerRecurringTime(); private  TriggerRecurringTime(TriggerRecurringTime triggerTime); void setAll(boolean value); TriggerRecurringTime set(DayOfWeek day, boolean value); @Override boolean shouldRun(); @Override 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 fromJSONTest() throws JSONException { TriggerRecurringTime t = new TriggerRecurringTime().lastRun(now - T.mins(1).msecs()); TriggerRecurringTime t2 = (TriggerRecurringTime) Trigger.instantiate(new JSONObject(t.toJSON())); Assert.assertEquals(now - T.mins(1).msecs(), t2.lastRun); }