@Test(expected = MembershipPolicyException.class) public void testUnassignUsersFromRequiredGroup() throws Exception { long[] requiredGroupIds = addRequiredGroups(); User user = MembershipPolicyTestUtil.addUser(null, null, requiredGroupIds, null); UserServiceUtil.unsetGroupUsers( requiredGroupIds[0], new long[] {user.getUserId()}, ServiceContextTestUtil.getServiceContext()); }
@Test public void testUnassignUsersFromGroup() throws Exception { long[] standardGroupIds = addStandardGroups(); User user = MembershipPolicyTestUtil.addUser(null, null, standardGroupIds, null); int initialUserGroupCount = UserLocalServiceUtil.getGroupUsersCount(standardGroupIds[0]); UserServiceUtil.unsetGroupUsers( standardGroupIds[0], new long[] {user.getUserId()}, ServiceContextTestUtil.getServiceContext()); Assert.assertEquals( initialUserGroupCount - 1, UserLocalServiceUtil.getGroupUsersCount(standardGroupIds[0])); Assert.assertTrue(isPropagateMembership()); }