TrendController { @RequestMapping(value = "/vpr/trend/**", method = RequestMethod.GET, params = "format=extjs") @ResponseBody public String renderExtJs(@RequestParam("format") String format, HttpServletRequest request) { Link link = createLink(request); if (link.getHref().lastIndexOf('?') > 0) { link.setHref(link.getHref() + "&format=" + StringEscapeUtils.escapeHtml(format)); } else { link.setHref(link.getHref() + "?format=" + StringEscapeUtils.escapeHtml(format)); } return "{ \"xtype\": \"trendpanel\", \"url\": \"" + link.getHref() + "\" }"; }  @Autowired void setLinkService(ILinkService linkService); @Autowired void setGenericPatientObjectDao(IGenericPatientObjectDAO genericPatientObjectDao); @RequestMapping(value = "/vpr/trend/**", method = RequestMethod.GET, params = "format=xml") String renderXml(HttpServletRequest request); @RequestMapping(value = "/vpr/trend/**", method = RequestMethod.GET, params = "format=json") ModelAndView renderJson(HttpServletRequest request); @RequestMapping(value = "/vpr/trend/**", method = RequestMethod.GET, params = "format=extjs") @ResponseBody String renderExtJs(@RequestParam("format") String format, HttpServletRequest request); static final String LAB_INDEX; static final String VITAL_INDEX; }
@Test public void testRenderExtjs() throws Exception { mockRequest.setRequestURI("/vpr/trend/urn:va:lab:F484:8:CH;6879469.819787;690"); Result result = new Result(); result.setData("pid", "23"); result.setData("typeName", "GLUCOSE"); when(genericPatientObjectDaoMock.findByUID(Result.class, "urn:va:lab:F484:8:CH;6879469.819787;690")).thenReturn(result); Link link = new Link(); link.setRel(LinkRelation.TREND.toString()); link.setHref("/vpr/trend/urn:va:lab:F484:8:CH;6879469.819787;690"); when(linkServiceMock.getLinks(result)).thenReturn(Arrays.asList(link)); String responseBody = tc.renderExtJs("extjs", mockRequest); JsonAssert.assertJsonEquals("{\"xtype\":\"trendpanel\",\"url\":\"/vpr/trend/urn:va:lab:F484:8:CH;6879469.819787;690?format=extjs\"}", responseBody); }