tableRow.addCell(7);
tableRow.addCell(false);
tableRow.addCell("Why?");
dataTable.addRow(tableRow);
JsonRenderer json = new JsonRenderer();
DataSourceRequest dataSourceRequest = new DataSourceRequest();
assertEquals(
"{\"version\":\"0.6\",\"status\":\"ok\",\"sig\":\"1548939605\","
+ "\"table\":{\"cols\":[{\"id\":\"col1\",\"label\":\"column1\","
+ "\"type\":\"number\",\"pattern\":\"\"},"
+ "{\"id\":\"col2\",\"label\":\"column2\",\"type\":\"boolean\",\"pattern\":\"\"},"
+ "{\"id\":\"col3\",\"label\":\"column3\",\"type\":\"string\",\"pattern\":\"\"}],"
+ "\"rows\":[{\"c\":[{\"v\":7.0},{\"v\":false},{\"v\":\"Why?\"}]}]}}",
json.render(dataSourceRequest, dataTable));
// With reqId:666;
dataSourceRequest = new DataSourceRequest(
new DataSourceParameters("reqId:666"));
assertEquals(
"{\"version\":\"0.6\",\"reqId\":\"666\",\"status\":\"ok\",\"sig\":\"1548939605\","
+ "\"table\":{\"cols\":[{\"id\":\"col1\",\"label\":\"column1\","
+ "\"type\":\"number\",\"pattern\":\"\"},"
+ "{\"id\":\"col2\",\"label\":\"column2\",\"type\":\"boolean\",\"pattern\":\"\"},"
+ "{\"id\":\"col3\",\"label\":\"column3\",\"type\":\"string\",\"pattern\":\"\"}],"
+ "\"rows\":[{\"c\":[{\"v\":7.0},{\"v\":false},{\"v\":\"Why?\"}]}]}}",
json.render(dataSourceRequest, dataTable));
// With out:json;
dataSourceRequest = new DataSourceRequest(
new DataSourceParameters("out:json"));
assertEquals(
"{\"version\":\"0.6\",\"status\":\"ok\",\"sig\":\"1548939605\","
+ "\"table\":{\"cols\":[{\"id\":\"col1\",\"label\":\"column1\","
+ "\"type\":\"number\",\"pattern\":\"\"},"
+ "{\"id\":\"col2\",\"label\":\"column2\",\"type\":\"boolean\",\"pattern\":\"\"},"
+ "{\"id\":\"col3\",\"label\":\"column3\",\"type\":\"string\",\"pattern\":\"\"}],"
+ "\"rows\":[{\"c\":[{\"v\":7.0},{\"v\":false},{\"v\":\"Why?\"}]}]}}",
json.render(dataSourceRequest, dataTable));
JsonRenderer jsonp = new JsonpRenderer();
// With out:jsonp;
dataSourceRequest = new DataSourceRequest(
new DataSourceParameters("out:jsonp"));
assertEquals(
"google.visualization.Query.setResponse("
+ "{\"version\":\"0.6\",\"status\":\"ok\",\"sig\":\"1548939605\","
+ "\"table\":{\"cols\":[{\"id\":\"col1\",\"label\":\"column1\","
+ "\"type\":\"number\",\"pattern\":\"\"},"
+ "{\"id\":\"col2\",\"label\":\"column2\",\"type\":\"boolean\",\"pattern\":\"\"},"
+ "{\"id\":\"col3\",\"label\":\"column3\",\"type\":\"string\",\"pattern\":\"\"}],"
+ "\"rows\":[{\"c\":[{\"v\":7.0},{\"v\":false},{\"v\":\"Why?\"}]}]}});",
jsonp.render(dataSourceRequest, dataTable));
TsvRenderer tsv = new TsvRenderer();
// Now with out:csv;
dataSourceRequest = new DataSourceRequest(
new DataSourceParameters("out:tsv-excel"));