@Test public void getComplaintPriorities() throws Exception { String[] priorityList = { "1", "2", "3", "4" }; expect(mockAuthentication.getName()).andReturn("user"); expect((StandardLookup) mockLookupDao.getLookupByName("priorities")).andReturn(complaintPrioritiesLookup); replayAll(); MvcResult result = mockMvc.perform(get("/api/latest/plugin/complaint/priorities") .accept(MediaType.parseMediaType("application/json;charset=UTF-8")).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(); log.info("results: " + returned); ObjectMapper objectMapper = new ObjectMapper(); String priorities[] = objectMapper.readValue(returned, String[].class); assertEquals(4, priorities.length); assertArrayEquals(priorityList, priorities); }
@RequestMapping(value = "priorities", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) public @ResponseBody List<String> getComplaintPriorities() { List<StandardLookupEntry> lookupEntries = (List<StandardLookupEntry>) getLookupDao().getLookupByName("priorities").getEntries(); return lookupEntries.stream().map(StandardLookupEntry::getKey).collect(Collectors.toList()); }
GetComplaintListOfValuesAPIController { @RequestMapping(value = "priorities", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) public @ResponseBody List<String> getComplaintPriorities() { List<StandardLookupEntry> lookupEntries = (List<StandardLookupEntry>) getLookupDao().getLookupByName("priorities").getEntries(); return lookupEntries.stream().map(StandardLookupEntry::getKey).collect(Collectors.toList()); } }
GetComplaintListOfValuesAPIController { @RequestMapping(value = "priorities", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) public @ResponseBody List<String> getComplaintPriorities() { List<StandardLookupEntry> lookupEntries = (List<StandardLookupEntry>) getLookupDao().getLookupByName("priorities").getEntries(); return lookupEntries.stream().map(StandardLookupEntry::getKey).collect(Collectors.toList()); }  }
GetComplaintListOfValuesAPIController { @RequestMapping(value = "priorities", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) public @ResponseBody List<String> getComplaintPriorities() { List<StandardLookupEntry> lookupEntries = (List<StandardLookupEntry>) getLookupDao().getLookupByName("priorities").getEntries(); return lookupEntries.stream().map(StandardLookupEntry::getKey).collect(Collectors.toList()); }  @RequestMapping(value = "priorities", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) @ResponseBody List<String> getComplaintPriorities(); @RequestMapping(value = "types", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<String> getComplaintTypes(); LookupDao getLookupDao(); void setLookupDao(LookupDao lookupDao); }
GetComplaintListOfValuesAPIController { @RequestMapping(value = "priorities", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) public @ResponseBody List<String> getComplaintPriorities() { List<StandardLookupEntry> lookupEntries = (List<StandardLookupEntry>) getLookupDao().getLookupByName("priorities").getEntries(); return lookupEntries.stream().map(StandardLookupEntry::getKey).collect(Collectors.toList()); }  @RequestMapping(value = "priorities", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) @ResponseBody List<String> getComplaintPriorities(); @RequestMapping(value = "types", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<String> getComplaintTypes(); LookupDao getLookupDao(); void setLookupDao(LookupDao lookupDao);  }