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

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

Introduction

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

Prototype

public static java.util.List<com.liferay.portal.kernel.model.Group> getRoleGroups(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,//  ww  w  .  j av  a2 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);
}