JsonHomeController { @RequestMapping(produces = {"application/json"}) @ResponseBody public Map<String, ?> getAsApplicationJson(final HttpServletResponse response) { LOG.info("Returning json-home in application/json format."); response.setHeader("Cache-Control", "max-age=" + maxAge); response.setHeader("Vary", "Accept"); return toRepresentation(jsonHomeSource.getJsonHome(), APPLICATION_JSON); }  @Autowired void setJsonHomeSource(final JsonHomeSource jsonHomeSource); @Value("${jsonhome.relationTypeBaseUri}") void setRelationTypeBaseUri(String relationTypeBaseUri); URI relationTypeBaseUri(); void setMaxAgeSeconds(int maxAge); @RequestMapping(produces = {"application/json-home"}) @ResponseBody Map<String, ?> getAsApplicationJsonHome(final HttpServletResponse response); @RequestMapping(produces = {"application/json"}) @ResponseBody Map<String, ?> getAsApplicationJson(final HttpServletResponse response);  }
@Test public void shouldFindInheritedAnnotations() throws Exception { final JsonHomeController controller = jsonHomeController( ControllerWithInheritance.class, "http: final MockHttpServletResponse response = new MockHttpServletResponse(); final Map<String, ?> resourcesMap = controller.getAsApplicationJson(response); @SuppressWarnings("unchecked") final Map<String, Map<String, ?>> resources = (Map<String, Map<String, ?>>) resourcesMap.get("resources"); final Map<String, ?> hints = asMap(resources.get("http: assertEquals(hints.get("description"), asList("controller value")); }
@Test public void applicationJsonShouldContainAdditionalInformation() throws Exception { final JsonHomeController controller = jsonHomeController( ControllerWithDocumentation.class, "http: final MockHttpServletResponse response = new MockHttpServletResponse(); final Map<String, ?> resourcesMap = controller.getAsApplicationJson(response); @SuppressWarnings("unchecked") final Map<String, Map<String, ?>> resources = (Map<String, Map<String, ?>>) resourcesMap.get("resources"); final Map<String, ?> hints = asMap(resources.get("http: assertEquals(hints.get("description"), asList("controller value")); }