List of usage examples for com.liferay.portal.kernel.service GroupLocalServiceUtil addUserGroupGroup
public static void addUserGroupGroup(long userGroupId, long groupId)
From source file:com.liferay.site.service.persistence.test.GroupFinderTest.java
License:Open Source License
@Test public void testFindByC_C_PG_N_D() throws Exception { _userGroup = UserGroupTestUtil.addUserGroup(); _userGroupUser = UserTestUtil.addUser(); UserGroupLocalServiceUtil.addUserUserGroup(_userGroupUser.getUserId(), _userGroup); Group group = _organization.getGroup(); GroupLocalServiceUtil.addUserGroupGroup(_userGroup.getUserGroupId(), group.getGroupId()); LinkedHashMap<String, Object> params = new LinkedHashMap<>(); params.put("inherit", true); params.put("usersGroups", _userGroupUser.getUserId()); List<Group> groups = GroupFinderUtil.findByC_C_PG_N_D(_organization.getCompanyId(), null, GroupConstants.DEFAULT_PARENT_GROUP_ID, null, null, params, true, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);//from w w w .j a v a 2s. co m Assert.assertTrue(groups.toString(), groups.contains(group)); }
From source file:com.liferay.site.service.persistence.test.GroupFinderTest.java
License:Open Source License
@Test public void testFindByCompanyIdByUserGroupGroup() throws Exception { _userGroup = UserGroupTestUtil.addUserGroup(); _userGroupGroup = GroupTestUtil.addGroup(); _userGroupUser = UserTestUtil.addUser(); GroupLocalServiceUtil.addUserGroupGroup(_userGroup.getUserGroupId(), _userGroupGroup.getGroupId()); UserGroupLocalServiceUtil.addUserUserGroup(_userGroupUser.getUserId(), _userGroup); LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>(); groupParams.put("inherit", Boolean.TRUE); groupParams.put("site", Boolean.TRUE); groupParams.put("usersGroups", _userGroupUser.getUserId()); List<Group> groups = GroupFinderUtil.findByCompanyId(TestPropsValues.getCompanyId(), groupParams, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new GroupNameComparator(true)); boolean exists = false; for (Group group : groups) { if (group.getGroupId() == _userGroupGroup.getGroupId()) { exists = true;/*w w w . j av a2s. c o m*/ break; } } Assert.assertTrue( "The method findByCompanyId should have returned the group " + _userGroupGroup.getGroupId(), exists); }