ActionProfileSwitch extends Action { @Override public String toJSON() { JSONObject o = new JSONObject(); try { o.put("type", ActionProfileSwitch.class.getName()); JSONObject data = new JSONObject(); data.put("profileToSwitchTo", inputProfileName.getValue()); o.put("data", data); } catch (JSONException e) { log.error("Unhandled exception", e); } return o.toString(); } ActionProfileSwitch(); @Override int friendlyName(); @Override String shortDescription(); @Override void doAction(Callback callback); @Override void generateDialog(LinearLayout root); @Override boolean hasDialog(); @Override String toJSON(); @Override Action fromJSON(String data); @Override Optional<Integer> icon();  }
@Test public void toJSONTest() { actionProfileSwitch = new ActionProfileSwitch(); actionProfileSwitch.inputProfileName.setValue("Test"); Assert.assertEquals(stringJson, actionProfileSwitch.toJSON()); }