@Test public void testReadBasicFormWithModel() { FormReader reader = new FormReader(); FormInstance form = reader.readFromStream(this.getClass().getResourceAsStream("/property-form.json")); assertThat(form).isNotNull(); assertThat(form.getId()).isEqualTo("2aeaf281-71e1-45a5-9ab3-0abd855d924e"); assertThat(form.getName()).isEqualTo("Property"); assertThat(form.getModel()).isNotNull(); assertThat(form.getModel().getClassName()).isEqualTo("com.myspace.mortgage_app.Property"); assertThat(form.getModel().getName()).isEqualTo("property"); assertThat(form.getFields()).hasSize(4); FormField field = form.getFields().get(0); assertField(field, "field_815717729253767E11", "age", "IntegerBox", "Age of property", 100, "age", "Age of property", "java.lang.Integer", false, false); field = form.getFields().get(1); assertField(field, "field_236289653097941E11", "address", "TextBox", "Address of property", 100, "address", "Address of property", "java.lang.String", false, false); field = form.getFields().get(2); assertField(field, "field_9471909295199063E11", "locale", "TextBox", "Locale", 100, "locale", "Locale", "java.lang.String", false, false); field = form.getFields().get(3); assertField(field, "field_4113393327260706E12", "saleprice", "IntegerBox", "Sale Price", 100, "saleprice", "Sale Price", "java.lang.Integer", false, false); FormLayout layout = form.getLayout(); assertThat(layout).isNotNull(); assertThat(layout.getRows()).hasSize(4); LayoutRow row = layout.getRows().get(0); assertThat(row.getColumns()).hasSize(1); LayoutColumn column = row.getColumns().get(0); assertColumn(column, "12", 1, "2aeaf281-71e1-45a5-9ab3-0abd855d924e", "field_815717729253767E11"); row = layout.getRows().get(1); assertThat(row.getColumns()).hasSize(1); column = row.getColumns().get(0); assertColumn(column, "12", 1, "2aeaf281-71e1-45a5-9ab3-0abd855d924e", "field_236289653097941E11"); row = layout.getRows().get(2); assertThat(row.getColumns()).hasSize(1); column = row.getColumns().get(0); assertColumn(column, "12", 1, "2aeaf281-71e1-45a5-9ab3-0abd855d924e", "field_9471909295199063E11"); row = layout.getRows().get(3); assertThat(row.getColumns()).hasSize(1); column = row.getColumns().get(0); assertColumn(column, "12", 1, "2aeaf281-71e1-45a5-9ab3-0abd855d924e", "field_4113393327260706E12"); }
public FormInstance readFromStream(InputStream formStructure) { try { FormInstance formInstance = this.mapper.readValue(formStructure, FormInstance.class); return flatColumnData(formInstance); } catch (IOException e) { throw new RuntimeException(e); } }
FormReader { public FormInstance readFromStream(InputStream formStructure) { try { FormInstance formInstance = this.mapper.readValue(formStructure, FormInstance.class); return flatColumnData(formInstance); } catch (IOException e) { throw new RuntimeException(e); } } }
FormReader { public FormInstance readFromStream(InputStream formStructure) { try { FormInstance formInstance = this.mapper.readValue(formStructure, FormInstance.class); return flatColumnData(formInstance); } catch (IOException e) { throw new RuntimeException(e); } } FormReader(); }
FormReader { public FormInstance readFromStream(InputStream formStructure) { try { FormInstance formInstance = this.mapper.readValue(formStructure, FormInstance.class); return flatColumnData(formInstance); } catch (IOException e) { throw new RuntimeException(e); } } FormReader(); FormInstance readFromString(String formStructure); FormInstance readFromStream(InputStream formStructure); Map<String, Object> extractValues(Object data); String toJson(Object data); }
FormReader { public FormInstance readFromStream(InputStream formStructure) { try { FormInstance formInstance = this.mapper.readValue(formStructure, FormInstance.class); return flatColumnData(formInstance); } catch (IOException e) { throw new RuntimeException(e); } } FormReader(); FormInstance readFromString(String formStructure); FormInstance readFromStream(InputStream formStructure); Map<String, Object> extractValues(Object data); String toJson(Object data);  }