TriggerTime extends Trigger { @Override public boolean shouldRun() { long now = DateUtil.now(); if (now >= runAt && now - runAt < T.mins(5).msecs()) if (lastRun < runAt) { if (L.isEnabled(L.AUTOMATION)) log.debug("Ready for execution: " + friendlyDescription()); return true; } return false; } TriggerTime(); private  TriggerTime(TriggerTime triggerTime); @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 shouldRunTest() { TriggerTime t = new TriggerTime().runAt(now - T.mins(1).msecs()); Assert.assertTrue(t.shouldRun()); t = new TriggerTime().runAt(now + T.mins(1).msecs()); Assert.assertFalse(t.shouldRun()); t = new TriggerTime().runAt(now - T.mins(1).msecs()).lastRun(now - 1); Assert.assertFalse(t.shouldRun()); }