}
@Test
public void testJson() throws Exception {
JsonDataLoader jsonDataLoader = new JsonDataLoader();
BandData rootBand = new BandData("band1", null, BandOrientation.HORIZONTAL);
rootBand.setData(Collections.<String, Object>emptyMap());
ReportQueryImpl reportQuery = new ReportQueryImpl("", "parameter=param1 $.store.book[*]", "json", null, null);
String json = "{ \"store\": {\n" +
" \"book\": [ \n" +
" { \"category\": \"reference\",\n" +
" \"author\": \"Nigel Rees\",\n" +
" \"title\": \"Sayings of the Century\",\n" +
" \"price\": 8.95\n" +
" },\n" +
" { \"category\": \"fiction\",\n" +
" \"author\": \"Evelyn Waugh\",\n" +
" \"title\": \"Sword of Honour\",\n" +
" \"price\": 12.99,\n" +
" \"isbn\": \"0-553-21311-3\"\n" +
" }\n" +
" ],\n" +
" \"bicycle\": {\n" +
" \"color\": \"red\",\n" +
" \"price\": 19.95\n" +
" }\n" +
" }\n" +
"}";
Map<String, Object> params = new HashMap<String, Object>();
params.put("param1", json);
List<Map<String, Object>> maps = jsonDataLoader.loadData(reportQuery, rootBand, params);
Assert.assertEquals(2, maps.size());
Map<String, Object> book1 = maps.get(0);
Assert.assertEquals("Sayings of the Century", book1.get("title"));
reportQuery = new ReportQueryImpl("", "parameter=param1 $", "json", null, null);
maps = jsonDataLoader.loadData(reportQuery, rootBand, params);
Map<String, Object> map = maps.get(0);
Assert.assertEquals("red", map.get("store.bicycle.color"));
reportQuery = new ReportQueryImpl("", "parameter=param1 $some.not.existing", "json", null, null);
maps = jsonDataLoader.loadData(reportQuery, rootBand, params);
Assert.assertEquals(0, maps.size());
}