List of usage examples for com.liferay.portal.kernel.util.comparator GroupNameComparator GroupNameComparator
public GroupNameComparator(boolean ascending)
From source file:com.liferay.site.service.persistence.test.GroupFinderTest.java
License:Open Source License
@Test public void testFindByCompanyId() throws Exception { LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>(); groupParams.put("inherit", Boolean.TRUE); groupParams.put("site", Boolean.TRUE); groupParams.put("usersGroups", TestPropsValues.getUserId()); List<Group> groups = GroupFinderUtil.findByCompanyId(TestPropsValues.getCompanyId(), groupParams, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new GroupNameComparator(true)); Assert.assertFalse(groups.toString(), groups.isEmpty()); }
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;//from ww w. ja v a 2 s . co m break; } } Assert.assertTrue( "The method findByCompanyId should have returned the group " + _userGroupGroup.getGroupId(), exists); }
From source file:com.liferay.site.service.persistence.test.GroupFinderTest.java
License:Open Source License
@Test public void testFindByLayouts2() throws Exception { int initialGroupCount = GroupFinderUtil.countByLayouts(TestPropsValues.getCompanyId(), GroupConstants.DEFAULT_PARENT_GROUP_ID, true, true); GroupTestUtil.addGroup();/*from w w w. j a v a 2 s . c o m*/ Group parentGroup = GroupTestUtil.addGroup(); LayoutTestUtil.addLayout(parentGroup, false); Group childGroup1 = GroupTestUtil.addGroup(parentGroup.getGroupId()); LayoutTestUtil.addLayout(childGroup1, false); Group childGroup2 = GroupTestUtil.addGroup(parentGroup.getGroupId()); LayoutTestUtil.addLayout(childGroup2, true); GroupLocalServiceUtil.updateGroup(parentGroup.getGroupId(), parentGroup.getParentGroupId(), parentGroup.getNameMap(), parentGroup.getDescriptionMap(), parentGroup.getType(), parentGroup.isManualMembership(), parentGroup.getMembershipRestriction(), parentGroup.getFriendlyURL(), parentGroup.isInheritContent(), false, ServiceContextTestUtil.getServiceContext()); List<Group> groups = GroupFinderUtil.findByLayouts(TestPropsValues.getCompanyId(), GroupConstants.DEFAULT_PARENT_GROUP_ID, true, true, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new GroupNameComparator(true)); Assert.assertEquals(groups.toString(), initialGroupCount, groups.size()); groups = GroupFinderUtil.findByLayouts(TestPropsValues.getCompanyId(), parentGroup.getGroupId(), true, true, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new GroupNameComparator(true)); Assert.assertEquals(groups.toString(), 2, groups.size()); }
From source file:com.liferay.site.service.persistence.test.GroupFinderTest.java
License:Open Source License
protected List<Group> findByLayouts(long parentGroupId) throws Exception { return GroupFinderUtil.findByLayouts(TestPropsValues.getCompanyId(), parentGroupId, true, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new GroupNameComparator(true)); }