@Test public void removeMembersFromAdHocGroupTest() throws Exception { AcmGroup group = new AcmGroup(); group.setName("A"); group.setType(AcmGroupType.ADHOC_GROUP); group.setStatus(AcmGroupStatus.ACTIVE); AcmUser user1 = new AcmUser(); user1.setUserId("ann-acm"); AcmUser user2 = new AcmUser(); user2.setUserId("sally-acm"); group.addUserMember(user2); expect(mockAuthentication.getName()).andReturn("ann-acm"); expect(groupService.removeUserMembersFromGroup(Arrays.asList(user1.getUserId()), "A")) .andReturn(group); replayAll(); MvcResult result = mockMvc.perform( post("/api/latest/users/group/{groupId}/members/remove/", Base64.getUrlEncoder().encodeToString(group.getName().getBytes())) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON) .principal(mockAuthentication) .content(new JSONArray(Arrays.asList("ann-acm")).toString())) .andReturn(); verifyAll(); log.info("Results: {}", result.getResponse().getContentAsString()); ObjectMapper om = new ObjectMapper(); AcmGroup acmGroup = om.readValue(result.getResponse().getContentAsString(), AcmGroup.class); assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus()); String[] members = { "sally-acm" }; assertArrayEquals(acmGroup.getUserMemberIds().toArray(), members); }
@RequestMapping(value = "/group/{groupId}/members/remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public AcmGroup removeMembersFromAdHocGroup(@RequestBody List<String> members, @PathVariable("groupId") String groupId) throws AcmAppErrorJsonMsg { LOG.info("Remove user members from group: [{}]", groupId); try { groupId = new String(Base64.getUrlDecoder().decode(groupId.getBytes())); return groupService.removeUserMembersFromGroup(members, groupId); } catch (AcmObjectNotFoundException e) { throw new AcmAppErrorJsonMsg("Failed to remove user members to Ad Hoc Group", "ADHOC_GROUP", e); } }
AdHocGroupMembersAPIController { @RequestMapping(value = "/group/{groupId}/members/remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public AcmGroup removeMembersFromAdHocGroup(@RequestBody List<String> members, @PathVariable("groupId") String groupId) throws AcmAppErrorJsonMsg { LOG.info("Remove user members from group: [{}]", groupId); try { groupId = new String(Base64.getUrlDecoder().decode(groupId.getBytes())); return groupService.removeUserMembersFromGroup(members, groupId); } catch (AcmObjectNotFoundException e) { throw new AcmAppErrorJsonMsg("Failed to remove user members to Ad Hoc Group", "ADHOC_GROUP", e); } } }
AdHocGroupMembersAPIController { @RequestMapping(value = "/group/{groupId}/members/remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public AcmGroup removeMembersFromAdHocGroup(@RequestBody List<String> members, @PathVariable("groupId") String groupId) throws AcmAppErrorJsonMsg { LOG.info("Remove user members from group: [{}]", groupId); try { groupId = new String(Base64.getUrlDecoder().decode(groupId.getBytes())); return groupService.removeUserMembersFromGroup(members, groupId); } catch (AcmObjectNotFoundException e) { throw new AcmAppErrorJsonMsg("Failed to remove user members to Ad Hoc Group", "ADHOC_GROUP", e); } }  }
AdHocGroupMembersAPIController { @RequestMapping(value = "/group/{groupId}/members/remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public AcmGroup removeMembersFromAdHocGroup(@RequestBody List<String> members, @PathVariable("groupId") String groupId) throws AcmAppErrorJsonMsg { LOG.info("Remove user members from group: [{}]", groupId); try { groupId = new String(Base64.getUrlDecoder().decode(groupId.getBytes())); return groupService.removeUserMembersFromGroup(members, groupId); } catch (AcmObjectNotFoundException e) { throw new AcmAppErrorJsonMsg("Failed to remove user members to Ad Hoc Group", "ADHOC_GROUP", e); } }  @RequestMapping(value = "/group/{groupId}/members/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody AcmGroup saveMembersToAdHocGroup(@RequestBody List<String> members,
            @PathVariable("groupId") String groupId); @RequestMapping(value = "/group/{groupId}/members/remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody AcmGroup removeMembersFromAdHocGroup(@RequestBody List<String> members,
            @PathVariable("groupId") String groupId); void setGroupService(GroupService groupService); }
AdHocGroupMembersAPIController { @RequestMapping(value = "/group/{groupId}/members/remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public AcmGroup removeMembersFromAdHocGroup(@RequestBody List<String> members, @PathVariable("groupId") String groupId) throws AcmAppErrorJsonMsg { LOG.info("Remove user members from group: [{}]", groupId); try { groupId = new String(Base64.getUrlDecoder().decode(groupId.getBytes())); return groupService.removeUserMembersFromGroup(members, groupId); } catch (AcmObjectNotFoundException e) { throw new AcmAppErrorJsonMsg("Failed to remove user members to Ad Hoc Group", "ADHOC_GROUP", e); } }  @RequestMapping(value = "/group/{groupId}/members/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody AcmGroup saveMembersToAdHocGroup(@RequestBody List<String> members,
            @PathVariable("groupId") String groupId); @RequestMapping(value = "/group/{groupId}/members/remove", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody AcmGroup removeMembersFromAdHocGroup(@RequestBody List<String> members,
            @PathVariable("groupId") String groupId); void setGroupService(GroupService groupService);  }