assertEquals("", JsonRenderer.renderDataTable(dataTable, true, false, true));
assertEquals("", JsonRenderer.renderDataTable(dataTable, true, true, true));
}
public void testAppendCellJson() {
TableCell dateCell = new TableCell(new DateValue(2009, 1, 12));
TableCell timeofdayCell = new TableCell(new TimeOfDayValue(12, 13, 14, 15));
TableCell datetimeCell = new TableCell(new DateTimeValue(2009, 1, 12, 12, 13, 14, 15));
TableCell booleanCell = new TableCell(true);
TableCell numberCell = new TableCell(12.3);
TableCell textCell = new TableCell("aba");
assertEquals("{\"v\":new Date(2009,1,12)}",
JsonRenderer.appendCellJson(dateCell, new StringBuilder(),
true, false, true).toString());
assertEquals("{\"v\":\"Date(2009,1,12)\"}",
JsonRenderer.appendCellJson(dateCell, new StringBuilder(),
true, false, false).toString());
assertEquals("{\"v\":[12,13,14,15]}",
JsonRenderer.appendCellJson(timeofdayCell, new StringBuilder(),
true, false, true).toString());
assertEquals("{\"v\":new Date(2009,1,12,12,13,14)}", //no milliseconds passed
JsonRenderer.appendCellJson(datetimeCell, new StringBuilder(),
true, false, true).toString());
assertEquals("{\"v\":\"Date(2009,1,12,12,13,14)\"}", //no milliseconds passed
JsonRenderer.appendCellJson(datetimeCell, new StringBuilder(),
true, false, false).toString());
assertEquals("{\"v\":true}",
JsonRenderer.appendCellJson(booleanCell, new StringBuilder(),
true, false, true).toString());
assertEquals("{\"v\":12.3}",
JsonRenderer.appendCellJson(numberCell, new StringBuilder(),
true, false, true).toString());
assertEquals("{\"v\":\"aba\"}",
JsonRenderer.appendCellJson(textCell, new StringBuilder(),
true, false, true).toString());
// No formatting still stays the same when there is no formatted value
assertEquals("{\"v\":12.3}",
JsonRenderer.appendCellJson(numberCell, new StringBuilder(),
false, false, true).toString());
dateCell = new TableCell(new DateValue(2009, 1, 12), "2009-2-12");
// With formatting
assertEquals("{\"v\":new Date(2009,1,12),\"f\":\"2009-2-12\"}",
JsonRenderer.appendCellJson(dateCell, new StringBuilder(),
true, false, true).toString());