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

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

Introduction

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

Prototype

public static int searchCount(long companyId, String keywords, java.util.LinkedHashMap<String, Object> params) 

Source Link

Document

Returns the number of 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 ww  w .  java 2 s .com
            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);
}