JsonUtils { public static ModelAndView toJson(Object object) { return toJson(object, null); } private  JsonUtils(); static ModelAndView toJson(Object object); static ModelAndView toJson(String json, String callback); static ModelAndView toJsonLd(String json, String callback); static ModelAndView toJson(Object object, String callback);  }
@Test public void testToJson() throws Exception { UserResults<Search> response = new UserResults<>("api2demo"); response.items = new ArrayList<>(); response.username = "test"; response.itemsCount = (long) 1; Search search = new Search(); search.id = 1l; search.query = "*:*"; search.queryString = "http: search.dateSaved = Date.from(Instant.now()); response.items.add(search); try { ModelAndView modelAndView = JsonUtils.toJson(response, null); assertNotNull(modelAndView); } catch (Exception e) { fail(e.getMessage()); } }