Example usage for com.liferay.portal.kernel.service GroupLocalServiceUtil search

List of usage examples for com.liferay.portal.kernel.service GroupLocalServiceUtil search

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service GroupLocalServiceUtil search.

Prototype

public static java.util.List<com.liferay.portal.kernel.model.Group> search(long companyId, String keywords,
        java.util.LinkedHashMap<String, Object> params, int start, int end) 

Source Link

Document

Returns an ordered range of all the groups that match the keywords, optionally including the user's inherited organization groups and user groups.

Usage

From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java

License:Open Source License

@Test
public void testFindGroupByRole() throws Exception {
    Group group = GroupTestUtil.addGroup(GroupConstants.DEFAULT_PARENT_GROUP_ID);

    long roleId = RoleTestUtil.addGroupRole(group.getGroupId());

    LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>();

    groupParams.put("groupsRoles", Long.valueOf(roleId));
    groupParams.put("site", Boolean.TRUE);

    Assert.assertEquals(1,//from  w ww  .  j  ava2 s .c  om
            GroupLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(), null, groupParams));

    List<Group> groups = GroupLocalServiceUtil.search(TestPropsValues.getCompanyId(), null, groupParams,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS);

    Assert.assertEquals(groups.toString(), 1, groups.size());
    Assert.assertEquals(group, groups.get(0));

    Assert.assertEquals(1, GroupLocalServiceUtil.getRoleGroupsCount(roleId));

    groups = GroupLocalServiceUtil.getRoleGroups(roleId);

    Assert.assertEquals(groups.toString(), 1, groups.size());
    Assert.assertEquals(group, groups.get(0));

    GroupLocalServiceUtil.deleteGroup(group);
}