### Question:
GetApplicationRolesToGroupsAPIController { @RequestMapping(value = "/rolestogroups", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public Map<String, List<String>> getApplicationRolesToGroups(Authentication auth) { LOG.debug("Taking application roles to groups ..."); Map<String, List<String>> retval = getFunctionalAccessService().getApplicationRolesToGroups(); LOG.debug("Application roles to groups: " + retval.toString()); return retval; }  @RequestMapping(value = "/rolestogroups", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody Map<String, List<String>> getApplicationRolesToGroups(Authentication auth); @RequestMapping(value = "/{roleName:.+}/groups", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<String> findGroupsByRole(Authentication auth,
            @PathVariable(value = "roleName") String roleName,
            @RequestParam(value = "authorized") Boolean authorized,
            @RequestParam(value = "dir", required = false, defaultValue = "name_lcs ASC") String sortDirection,
            @RequestParam(value = "start", required = false, defaultValue = "0") int startRow,
            @RequestParam(value = "n", required = false, defaultValue = "1000") int maxRows); @RequestMapping(value = "/{roleName:.+}/groups", params = { "fq" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<String> findGroupsByRoleByName(Authentication auth,
            @PathVariable(value = "roleName") String roleName,
            @RequestParam(value = "authorized") Boolean authorized,
            @RequestParam(value = "fq") String filterQuery,
            @RequestParam(value = "dir", required = false, defaultValue = "name_lcs ASC") String sortDirection,
            @RequestParam(value = "start", required = false, defaultValue = "0") int startRow,
            @RequestParam(value = "n", required = false, defaultValue = "1000") int maxRows); FunctionalAccessService getFunctionalAccessService(); void setFunctionalAccessService(FunctionalAccessService functionalAccessService);  }### Answer:
@Test public void getApplicationRolesToGroupsTest() throws Exception { expect(getMockAuthentication().getName()).andReturn("user"); Map<String, List<String>> rolesToGroups = new HashMap<>(); rolesToGroups.put("ROLE_INVESTIGATOR", Arrays.asList("acm_investigator_dev", "acm_administrator_dev")); expect(mockFunctionalAccessService.getApplicationRolesToGroups()).andReturn(rolesToGroups); replayAll(); MvcResult result = getMockMvc().perform( get("/api/v1/functionalaccess/rolestogroups") .accept(MediaType.parseMediaType("application/json;charset=UTF-8")) .contentType(MediaType.APPLICATION_JSON) .principal(getMockAuthentication())) .andReturn(); LOG.info("Results: " + result.getResponse().getContentAsString()); Map<String, List<String>> resultTestData = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); try { resultTestData = mapper.readValue(result.getResponse().getContentAsString(), new TypeReference<HashMap<String, List<String>>>() { }); } catch (Exception e) { LOG.error("Cannot create map from source: " + result.getResponse().getContentAsString()); } assertEquals(rolesToGroups.size(), resultTestData.size()); assertEquals(rolesToGroups.get("ROLE_INVESTIGATOR"), resultTestData.get("ROLE_INVESTIGATOR")); assertEquals("acm_investigator_dev,acm_administrator_dev", StringUtils.join(resultTestData.get("ROLE_INVESTIGATOR"), ",")); assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus()); }