@Test public void getInfo() throws Exception { mockHttpSession.setAttribute("acm_ip_address", "ipAddress"); List<Map<String, String>> info = new ArrayList<>(); Map<String, String> appConfigName = new HashMap<>(); appConfigName.put("name", "appConfigName"); appConfigName.put("description", "appConfigDescription"); info.add(appConfigName); Map<String, String> propertyConfigName = new HashMap<>(); propertyConfigName.put("name", "propertyConfigName"); propertyConfigName.put("description", "propertyConfigDescription"); info.add(propertyConfigName); Map<String, String> jsonConfigName = new HashMap<>(); jsonConfigName.put("name", "jsonConfigName"); jsonConfigName.put("description", "jsonConfigDescription"); info.add(jsonConfigName); expect(mockConfigService.getInfo()).andReturn(info); expect(mockAuthentication.getName()).andReturn("userName").atLeastOnce(); replayAll(); MvcResult result = mockMvc.perform(get("/api/v1/service/config").accept(MediaType.parseMediaType("application/json;charset=UTF-8")) .session(mockHttpSession).principal(mockAuthentication)).andReturn(); verifyAll(); assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus()); assertTrue(result.getResponse().getContentType().startsWith(MediaType.APPLICATION_JSON_VALUE)); String returned = result.getResponse().getContentAsString(); assertNotNull(returned); ObjectMapper om = new ObjectMapper(); List<Map<String, String>> resultList = om.readValue(returned, new TypeReference<List<Map<String, String>>>() { }); assertNotNull(resultList); assertEquals("appConfigName", resultList.get(0).get("name")); assertEquals("appConfigDescription", resultList.get(0).get("description")); assertEquals("propertyConfigName", resultList.get(1).get("name")); assertEquals("propertyConfigDescription", resultList.get(1).get("description")); assertEquals("jsonConfigName", resultList.get(2).get("name")); assertEquals("jsonConfigDescription", resultList.get(2).get("description")); }
@RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }) @ResponseBody public List<Map<String, String>> getInfo() { return configService.getInfo(); }
ConfigApiController { @RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }) @ResponseBody public List<Map<String, String>> getInfo() { return configService.getInfo(); } }
ConfigApiController { @RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }) @ResponseBody public List<Map<String, String>> getInfo() { return configService.getInfo(); }  }
ConfigApiController { @RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }) @ResponseBody public List<Map<String, String>> getInfo() { return configService.getInfo(); }  @RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }) @ResponseBody List<Map<String, String>> getInfo(); @RequestMapping(value = "/{name}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE, MediaType.TEXT_PLAIN_VALUE }) @ResponseBody Object getConfig(@PathVariable("name") String name); ConfigService getConfigService(); void setConfigService(ConfigService configService); }
ConfigApiController { @RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }) @ResponseBody public List<Map<String, String>> getInfo() { return configService.getInfo(); }  @RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }) @ResponseBody List<Map<String, String>> getInfo(); @RequestMapping(value = "/{name}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE, MediaType.TEXT_PLAIN_VALUE }) @ResponseBody Object getConfig(@PathVariable("name") String name); ConfigService getConfigService(); void setConfigService(ConfigService configService);  }