Action { public String toJSON() { JSONObject o = new JSONObject(); try { o.put("type", this.getClass().getName()); } catch (JSONException e) { log.error("Unhandled exception", e); } return o.toString(); }  abstract int friendlyName(); abstract String shortDescription(); abstract void doAction(Callback callback); void generateDialog(LinearLayout root); boolean hasDialog(); String toJSON(); abstract Optional<Integer> icon(); Action fromJSON(String data); @Nullable static Action instantiate(JSONObject object); void apply(Action a); public Trigger precondition; }
@Test public void toJSONTest() { Assert.assertEquals("{\"type\":\"info.nightscout.androidaps.plugins.general.automation.actions.ActionTest\"}", toJSON()); }