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

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

Introduction

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

Prototype

public static int getRoleGroupsCount(long roleId) 

Source Link

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  w w  .j a va  2 s . co  m
            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);
}