public void beginSection() { beginSection(new HtmlFormSection()); }
@Before public void before() throws Exception { section = new HtmlFormSection(); formEntryContext = mock(FormEntryContext.class); when(formEntryContext.getActiveSection()).thenReturn(section); formEntrySession = mock(FormEntrySession.class); when(formEntrySession.getContext()).thenReturn(formEntryContext); out = new CapturingPrintWriter(); handler = new SectionTagHandler(); }
@Test public void shouldBuildSchemaWithSections() { HtmlFormSchema schema = new HtmlFormSchema(); HtmlFormSection section1 = new HtmlFormSection(); section1.setName("Section 1"); schema.getSections().add(section1); HtmlFormSection section2 = new HtmlFormSection(); section2.setName("Section 2"); schema.getSections().add(section2); JsonNode schemaAsJson = new HtmlFormEncounterController().buildSchemaAsJsonNode(schema, new ObjectMapper()); assertThat(schemaAsJson.get("sections").get(0).get("name").getValueAsText(), is("Section 1")); assertThat(schemaAsJson.get("sections").get(1).get("name").getValueAsText(), is("Section 2")); }
@Test public void shouldBuildSchemaWithSectionsNestedSections() { HtmlFormSchema schema = new HtmlFormSchema(); HtmlFormSection section1 = new HtmlFormSection(); section1.setName("Section 1"); HtmlFormSection section1a = new HtmlFormSection(); section1a.setName("Section 1a"); section1.addChildSection(section1a); HtmlFormSection section1b = new HtmlFormSection(); section1b.setName("Section 1b"); section1.addChildSection(section1b); schema.getSections().add(section1); HtmlFormSection section2 = new HtmlFormSection(); section2.setName("Section 2"); schema.getSections().add(section2); JsonNode schemaAsJson = new HtmlFormEncounterController().buildSchemaAsJsonNode(schema, new ObjectMapper()); assertThat(schemaAsJson.get("sections").get(0).get("name").getValueAsText(), is("Section 1")); assertThat(schemaAsJson.get("sections").get(0).get("sections").get(0).get("name").getValueAsText(), is("Section 1a")); assertThat(schemaAsJson.get("sections").get(0).get("sections").get(1).get("name").getValueAsText(), is("Section 1b")); assertThat(schemaAsJson.get("sections").get(1).get("name").getValueAsText(), is("Section 2")); }
@Test public void shouldBuildSchemaWithSectionAndSeparateField() { HtmlFormSchema schema = new HtmlFormSchema(); HtmlFormSection section1 = new HtmlFormSection(); section1.setName("Section 1"); schema.getSections().add(section1); ObsField field1 = new ObsField(); field1.setName("Field 1"); schema.getFields().add(field1); JsonNode schemaAsJson = new HtmlFormEncounterController().buildSchemaAsJsonNode(schema, new ObjectMapper()); assertThat(schemaAsJson.get("sections").get(0).get("name").getValueAsText(), is("Section 1")); assertThat(schemaAsJson.get("fields").get(0).get("name").getValueAsText(), is("Field 1")); }
HtmlFormSection section1 = new HtmlFormSection(); section1.setName("Section 1"); schema.getSections().add(section1);
HtmlFormSection section1 = new HtmlFormSection(); section1.setName("Section 1"); schema.getSections().add(section1); section1.addField(field2); HtmlFormSection section2 = new HtmlFormSection(); section2.setName("Section 2"); schema.getSections().add(section2);
HtmlFormSection section1 = new HtmlFormSection(); section1.setName("Section 1"); schema.getSections().add(section1);
HtmlFormSection section1 = new HtmlFormSection(); section1.setName("Section 1"); schema.getSections().add(section1); field7.setExistingObs(obs7); section1.addField(field7); HtmlFormSection section2 = new HtmlFormSection(); section2.setName("Section 2"); schema.getSections().add(section2);