@Test public void getPersonTypes() throws Exception { expect(mockAuthentication.getName()).andReturn("user"); replayAll(); MvcResult result = mockMvc.perform( get("/api/latest/plugin/person/types") .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[] types = objectMapper.readValue(returned, String[].class); assertEquals(5, types.length); }
@RequestMapping(value = "types", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List<String> getPersonTypes() throws AcmListObjectsFailedException { List<String> personTypes = personConfig.getTypes(); if (personConfig.getTypes().isEmpty()) { throw new AcmListObjectsFailedException("PersonTypes", "person property with key [person.types] is not set or is empty", null); } return personTypes; }
GetPersonTypesAPIController { @RequestMapping(value = "types", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List<String> getPersonTypes() throws AcmListObjectsFailedException { List<String> personTypes = personConfig.getTypes(); if (personConfig.getTypes().isEmpty()) { throw new AcmListObjectsFailedException("PersonTypes", "person property with key [person.types] is not set or is empty", null); } return personTypes; } }
GetPersonTypesAPIController { @RequestMapping(value = "types", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List<String> getPersonTypes() throws AcmListObjectsFailedException { List<String> personTypes = personConfig.getTypes(); if (personConfig.getTypes().isEmpty()) { throw new AcmListObjectsFailedException("PersonTypes", "person property with key [person.types] is not set or is empty", null); } return personTypes; }  }
GetPersonTypesAPIController { @RequestMapping(value = "types", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List<String> getPersonTypes() throws AcmListObjectsFailedException { List<String> personTypes = personConfig.getTypes(); if (personConfig.getTypes().isEmpty()) { throw new AcmListObjectsFailedException("PersonTypes", "person property with key [person.types] is not set or is empty", null); } return personTypes; }  @RequestMapping(value = "types", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<String> getPersonTypes(); PersonConfig getPersonConfig(); void setPersonConfig(PersonConfig personConfig); }
GetPersonTypesAPIController { @RequestMapping(value = "types", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List<String> getPersonTypes() throws AcmListObjectsFailedException { List<String> personTypes = personConfig.getTypes(); if (personConfig.getTypes().isEmpty()) { throw new AcmListObjectsFailedException("PersonTypes", "person property with key [person.types] is not set or is empty", null); } return personTypes; }  @RequestMapping(value = "types", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<String> getPersonTypes(); PersonConfig getPersonConfig(); void setPersonConfig(PersonConfig personConfig);  }