ActionStopTempTarget extends Action { @Override public String toJSON() { JSONObject o = new JSONObject(); try { o.put("type", ActionStopTempTarget.class.getName()); JSONObject data = new JSONObject(); data.put("reason", reason); o.put("data", data); } catch (JSONException e) { log.error("Unhandled exception", e); } return o.toString(); } ActionStopTempTarget(); @Override int friendlyName(); @Override String shortDescription(); @Override void doAction(Callback callback); @Override boolean hasDialog(); @Override String toJSON(); @Override Action fromJSON(String data); @Override Optional<Integer> icon();  }
@Test public void toJSONTest() { actionStopTempTarget = new ActionStopTempTarget(); actionStopTempTarget.reason = "Test"; Assert.assertEquals("{\"data\":{\"reason\":\"Test\"},\"type\":\"info.nightscout.androidaps.plugins.general.automation.actions.ActionStopTempTarget\"}", actionStopTempTarget.toJSON()); }