@Test public void hasHeaderAndFooter() { String headerFooter = "header and footer"; data.setHeader(headerFooter); data.setFooter(headerFooter); assertThat(data.getGfJsonObject().getString("header")).isEqualTo(headerFooter); assertThat(data.getGfJsonObject().getString("footer")).isEqualTo(headerFooter); }
@Test public void emptyTabularResultData() { assertThat(data.getGfJsonObject().getString("content")).isEqualTo("{}"); assertThat(data.getType()).isEqualTo(ResultData.TYPE_TABULAR); }
public TabularResultData addTable(String keyToAccess) { TabularResultData tabularResultData = ResultBuilder.createTabularResultData(); GfJsonObject tableData = tabularResultData.getGfJsonObject(); try { sectionGfJsonObject.putAsJSONObject(generateTableKey(keyToAccess), tableData); } catch (GfJsonException e) { throw new ResultDataException(e.getMessage()); } tablesCount++; return tabularResultData; }
@Test public void canAccumulate() { data.accumulate("col1", "value1"); assertThat(data.getGfJsonObject().getJSONObject("content").getString("col1")) .isEqualTo("[\"value1\"]"); data.accumulate("col1", "value2"); assertThat(data.getGfJsonObject().getJSONObject("content").getString("col1")) .isEqualTo("[\"value1\",\"value2\"]"); data.accumulate("col2", "value3"); data.accumulate("col2", "value4"); assertThat(data.getGfJsonObject().getJSONObject("content").getString("col1")) .isEqualTo("[\"value1\",\"value2\"]"); assertThat(data.getGfJsonObject().getJSONObject("content").getString("col2")) .isEqualTo("[\"value3\",\"value4\"]"); }
@Test public void withNestedSectionContainingASingleTable() { CompositeResultData result = new CompositeResultData(); String outerHeader = "this outerHeader left blank"; String outerFooter = "this outerFooter left blank"; result.setHeader(outerHeader); result.setFooter(outerFooter); CompositeResultData.SectionResultData section = result.addSection(); String tableSurround = "this surround left blank"; section.addTable(); section.setHeader(tableSurround); section.setFooter(tableSurround); GfJsonObject json = result.getGfJsonObject(); assertThat(json.getJSONObject("content").getJSONObject("__sections__-0") .getJSONObject("__tables__-0").getString("content")).isEqualTo("{}"); assertThat(json.getString("footer")).isEqualTo(outerFooter); assertThat(json.getString("header")).isEqualTo(outerHeader); assertThat(json.getJSONObject("content").getJSONObject("__sections__-0").getString("header")) .isEqualTo(tableSurround); assertThat(json.getJSONObject("content").getJSONObject("__sections__-0").getString("footer")) .isEqualTo(tableSurround); CompositeResultData.SectionResultData resultSection = result.retrieveSectionByIndex(0); assertThat(resultSection.getSectionGfJsonObject().getString("header")).isEqualTo(tableSurround); assertThat(resultSection.getSectionGfJsonObject().getString("footer")).isEqualTo(tableSurround); assertThat(resultSection.retrieveTable("0").getGfJsonObject().getString("content")) .isEqualTo("{}"); }