### Question:
SaveApplicationRolesToGroupsAPIController { @RequestMapping(value = "/rolestogroups", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public boolean saveApplicationRolesToGroups(@RequestBody Map<String, List<String>> applicationRolesToGroups, Authentication auth) { LOG.debug("Saving application roles to groups ..."); boolean retval = getFunctionalAccessService().saveApplicationRolesToGroups(applicationRolesToGroups, auth); LOG.debug("Successfuly save ? " + retval); return retval; }  @RequestMapping(value = "/rolestogroups", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody boolean saveApplicationRolesToGroups(@RequestBody Map<String, List<String>> applicationRolesToGroups, Authentication auth); @RequestMapping(value = "/{roleName:.+}/groups", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody boolean addGroupsToApplicationRole(@PathVariable(value = "roleName") String roleName, @RequestBody List<String> groups,
            Authentication auth); @RequestMapping(value = "/{roleName:.+}/groups", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody boolean deleteGroupsFromApplicationRole(@PathVariable(value = "roleName") String roleName, @RequestBody List<String> groups,
            Authentication auth); FunctionalAccessService getFunctionalAccessService(); void setFunctionalAccessService(FunctionalAccessService functionalAccessService);  }### Answer:
@Test public void saveApplicationRolesToGroupsTest() throws Exception { ObjectMapper objectMapper = new ObjectMapper(); Map<String, String> rolesToGroups = new HashMap<>(); Map<String, List<String>> input = prepareRoleToGroupsForRetrieving(rolesToGroups); String content = objectMapper.writeValueAsString(input); Capture<Map<String, List<String>>> found = EasyMock.newCapture(); Capture<Authentication> auth = EasyMock.newCapture(); expect(mockFunctionalAccessServiceTest.saveApplicationRolesToGroups(capture(found), capture(auth))).andReturn(true); expect(getMockAuthentication().getName()).andReturn("user"); replayAll(); MvcResult result = getMockMvc().perform( post("/api/v1/functionalaccess/rolestogroups") .accept(MediaType.parseMediaType("application/json;charset=UTF-8")) .contentType(MediaType.APPLICATION_JSON) .principal(getMockAuthentication()) .content(content)) .andReturn(); LOG.info("Results: " + result.getResponse().getContentAsString()); assertEquals("true", result.getResponse().getContentAsString()); assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus()); }