Example usage for com.liferay.portal.kernel.test.util RoleTestUtil addGroupRole

List of usage examples for com.liferay.portal.kernel.test.util RoleTestUtil addGroupRole

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.test.util RoleTestUtil addGroupRole.

Prototype

public static long addGroupRole(long groupId) throws Exception 

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 ava  2s.c o  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);
}