ActionLoopSuspend extends Action { @Override public void doAction(Callback callback) { if (!LoopPlugin.getPlugin().isSuspended()) { LoopPlugin.getPlugin().suspendLoop(minutes.getMinutes()); RxBus.INSTANCE.send(new EventRefreshOverview("ActionLoopSuspend")); if (callback != null) callback.result(new PumpEnactResult().success(true).comment(R.string.ok)).run(); } else { if (callback != null) callback.result(new PumpEnactResult().success(true).comment(R.string.alreadysuspended)).run(); } }  @Override int friendlyName(); @Override String shortDescription(); @Override void doAction(Callback callback); @Override Optional<Integer> icon(); @Override String toJSON(); @Override Action fromJSON(String data); @Override boolean hasDialog(); @Override void generateDialog(LinearLayout root); public InputDuration minutes; }
@Test public void doActionTest() { actionLoopSuspend.minutes = new InputDuration(30, InputDuration.TimeUnit.MINUTES); LoopPlugin.getPlugin().suspendTo(0); actionLoopSuspend.doAction(new Callback() { @Override public void run() { } }); Assert.assertEquals(true, LoopPlugin.getPlugin().isSuspended()); actionLoopSuspend.doAction(new Callback() { @Override public void run() { } }); Assert.assertEquals(true, LoopPlugin.getPlugin().isSuspended()); }