@Test public void getApplicationRolesTest() throws Exception { expect(getMockAuthentication().getName()).andReturn("user"); List<String> roles = Arrays.asList("role1", "role2"); expect(mockFunctionalAccessService.getApplicationRoles()).andReturn(roles); replayAll(); MvcResult result = getMockMvc().perform( get("/api/v1/functionalaccess/roles") .accept(MediaType.parseMediaType("application/json;charset=UTF-8")) .contentType(MediaType.APPLICATION_JSON) .principal(getMockAuthentication())) .andReturn(); LOG.info("Results: " + result.getResponse().getContentAsString()); List<String> resultTestData = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); try { resultTestData = mapper.readValue(result.getResponse().getContentAsString(), new TypeReference<ArrayList<String>>() { }); } catch (Exception e) { LOG.error("Cannot create list from source: " + result.getResponse().getContentAsString()); } assertEquals(roles.size(), resultTestData.size()); assertEquals(roles.get(1), resultTestData.get(1)); assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus()); }
@RequestMapping(value = "/roles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<String> getApplicationRoles(Authentication auth) { LOG.debug("Taking application roles ..."); List<String> retval = getFunctionalAccessService().getApplicationRoles(); LOG.debug("Application roles: " + retval.toString()); return retval; }
GetApplicationRolesAPIController { @RequestMapping(value = "/roles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<String> getApplicationRoles(Authentication auth) { LOG.debug("Taking application roles ..."); List<String> retval = getFunctionalAccessService().getApplicationRoles(); LOG.debug("Application roles: " + retval.toString()); return retval; } }
GetApplicationRolesAPIController { @RequestMapping(value = "/roles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<String> getApplicationRoles(Authentication auth) { LOG.debug("Taking application roles ..."); List<String> retval = getFunctionalAccessService().getApplicationRoles(); LOG.debug("Application roles: " + retval.toString()); return retval; }  }
GetApplicationRolesAPIController { @RequestMapping(value = "/roles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<String> getApplicationRoles(Authentication auth) { LOG.debug("Taking application roles ..."); List<String> retval = getFunctionalAccessService().getApplicationRoles(); LOG.debug("Application roles: " + retval.toString()); return retval; }  @RequestMapping(value = "/roles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<String> getApplicationRoles(Authentication auth); @RequestMapping(value = "/appRoles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<String> getApplicationRolesPaged(
            @RequestParam(value = "start", required = false, defaultValue = "0") int startRow,
            @RequestParam(value = "n", required = false, defaultValue = "10000") int maxRows,
            @RequestParam(value = "s", required = false, defaultValue = "name_lcs") String sortBy,
            @RequestParam(value = "dir", required = false, defaultValue = "ASC") String sortDirection, Authentication auth); @RequestMapping(value = "/appRoles", params = { "fn" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<String> getApplicationRolesByName(
            @RequestParam(value = "fn") String filterName,
            @RequestParam(value = "start", required = false, defaultValue = "0") int startRow,
            @RequestParam(value = "n", required = false, defaultValue = "10000") int maxRows,
            @RequestParam(value = "s", required = false, defaultValue = "name_lcs") String sortBy,
            @RequestParam(value = "dir", required = false, defaultValue = "ASC") String sortDirection, Authentication auth); FunctionalAccessService getFunctionalAccessService(); void setFunctionalAccessService(FunctionalAccessService functionalAccessService); }
GetApplicationRolesAPIController { @RequestMapping(value = "/roles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<String> getApplicationRoles(Authentication auth) { LOG.debug("Taking application roles ..."); List<String> retval = getFunctionalAccessService().getApplicationRoles(); LOG.debug("Application roles: " + retval.toString()); return retval; }  @RequestMapping(value = "/roles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<String> getApplicationRoles(Authentication auth); @RequestMapping(value = "/appRoles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<String> getApplicationRolesPaged(
            @RequestParam(value = "start", required = false, defaultValue = "0") int startRow,
            @RequestParam(value = "n", required = false, defaultValue = "10000") int maxRows,
            @RequestParam(value = "s", required = false, defaultValue = "name_lcs") String sortBy,
            @RequestParam(value = "dir", required = false, defaultValue = "ASC") String sortDirection, Authentication auth); @RequestMapping(value = "/appRoles", params = { "fn" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<String> getApplicationRolesByName(
            @RequestParam(value = "fn") String filterName,
            @RequestParam(value = "start", required = false, defaultValue = "0") int startRow,
            @RequestParam(value = "n", required = false, defaultValue = "10000") int maxRows,
            @RequestParam(value = "s", required = false, defaultValue = "name_lcs") String sortBy,
            @RequestParam(value = "dir", required = false, defaultValue = "ASC") String sortDirection, Authentication auth); FunctionalAccessService getFunctionalAccessService(); void setFunctionalAccessService(FunctionalAccessService functionalAccessService);  }