GUI implements Serializable { public static GUI fromJson(String json) { GUI gui = gson.fromJson(json, GUI.class); gui.convertOldInput(); return gui; } GUI(); void setParams(Map<String, Object> values); Map<String, Object> getParams(); Map<String, Input> getForms(); void setForms(Map<String, Input> forms); @Deprecated Object input(String id); @Deprecated Object input(String id, Object defaultValue); Object textbox(String id, String defaultValue); Object textbox(String id); Object password(String id); Object select(String id, ParamOption[] options, Object defaultValue); List<Object> checkbox(String id,
                               ParamOption[] options,
                               Collection<Object> defaultChecked); void clear(); @Override boolean equals(Object o); @Override int hashCode(); String toJson(); void convertOldInput(); static GUI fromJson(String json);  }
@Test public void testOldGson_3() throws IOException { String oldJson = "{\n" + " \"params\": {\n" + " \"maxAge\": \"35\"\n" + " },\n" + " \"forms\": {\n" + " \"maxAge\": {\n" + " \"name\": \"maxAge\",\n" + " \"defaultValue\": \"30\",\n" + " \"hidden\": false\n" + " }\n" + " }\n" + " }"; GUI gui = GUI.fromJson(oldJson); assertEquals(1, gui.forms.size()); assertTrue(gui.forms.get("maxAge") instanceof TextBox); assertEquals("30", gui.forms.get("maxAge").getDefaultValue()); oldJson = "{\n" + " \"params\": {\n" + " \"marital\": \"single\"\n" + " },\n" + " \"forms\": {\n" + " \"marital\": {\n" + " \"name\": \"marital\",\n" + " \"defaultValue\": \"single\",\n" + " \"options\": [\n" + " {\n" + " \"value\": \"single\"\n" + " },\n" + " {\n" + " \"value\": \"divorced\"\n" + " },\n" + " {\n" + " \"value\": \"married\"\n" + " }\n" + " ],\n" + " \"hidden\": false\n" + " }\n" + " }\n" + " }"; gui = GUI.fromJson(oldJson); assertEquals(1, gui.forms.size()); assertTrue(gui.forms.get("marital") instanceof Select); assertEquals("single", gui.forms.get("marital").getDefaultValue()); }