ActionProfileSwitch extends Action { @Override public Action fromJSON(String data) { try { JSONObject d = new JSONObject(data); profileName = JsonHelper.safeGetString(d, "profileToSwitchTo"); inputProfileName.setValue(profileName); } catch (JSONException e) { log.error("Unhandled exception", e); } return this; } 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 fromJSONTest() { String data = "{\"profileToSwitchTo\":\"Test\"}"; actionProfileSwitch = new ActionProfileSwitch(); actionProfileSwitch.fromJSON(data); Assert.assertEquals("Test", actionProfileSwitch.profileName); }