ActionNotification extends Action { @Override public String toJSON() { JSONObject o = new JSONObject(); JSONObject data = new JSONObject(); try { data.put("text", text.getValue()); o.put("type", this.getClass().getName()); o.put("data", data); } catch (JSONException e) { log.error("Unhandled exception", e); } return o.toString(); }  @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 InputString text; }
@Test public void toJSONTest() { actionNotification = new ActionNotification(); actionNotification.text = new InputString().setValue("Asd"); Assert.assertEquals("{\"data\":{\"text\":\"Asd\"},\"type\":\"info.nightscout.androidaps.plugins.general.automation.actions.ActionNotification\"}", actionNotification.toJSON()); }