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

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

Introduction

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

Prototype

public static Role addRole(int roleType) throws Exception 

Source Link

Usage

From source file:com.liferay.asset.search.test.AssetSearcherStagingTest.java

License:Open Source License

protected Role addRole(int roleType) throws Exception {
    Role role = RoleTestUtil.addRole(roleType);

    _roles.add(role);

    return role;
}

From source file:com.liferay.bookmarks.service.permission.test.BookmarksEntryResourceBlockLocalServiceTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    ServiceTestUtil.setUser(TestPropsValues.getUser());

    _group = GroupTestUtil.addGroup();//  w ww. ja v a 2s . co  m

    _bookmarksEntry1 = BookmarksTestUtil.addEntry(_group.getGroupId(), true);
    _bookmarksEntry2 = BookmarksTestUtil.addEntry(_group.getGroupId(), true);

    _role1 = RoleTestUtil.addRole(RoleConstants.TYPE_REGULAR);

    ResourceBlockLocalServiceUtil.addIndividualScopePermission(_bookmarksEntry1.getCompanyId(),
            _bookmarksEntry1.getGroupId(), BookmarksEntry.class.getName(), _bookmarksEntry1, _role1.getRoleId(),
            ActionKeys.VIEW);

    ResourceBlockLocalServiceUtil.addIndividualScopePermission(_bookmarksEntry2.getCompanyId(),
            _bookmarksEntry2.getGroupId(), BookmarksEntry.class.getName(), _bookmarksEntry2, _role1.getRoleId(),
            ActionKeys.VIEW);

    _role2 = RoleTestUtil.addRole(RoleConstants.TYPE_REGULAR);

    ResourceBlockLocalServiceUtil.addIndividualScopePermission(_bookmarksEntry1.getCompanyId(),
            _bookmarksEntry1.getGroupId(), BookmarksEntry.class.getName(), _bookmarksEntry1, _role2.getRoleId(),
            ActionKeys.VIEW);
}

From source file:com.liferay.exportimport.test.LayoutSetPrototypePropagationTest.java

License:Open Source License

@Test
public void testResetPrototypeWithPermissions() throws Exception {
    Role role = RoleTestUtil.addRole(RoleConstants.TYPE_REGULAR);

    RoleLocalServiceUtil.addUserRole(_user1.getUserId(), role);

    ResourcePermissionLocalServiceUtil.addResourcePermission(_user1.getCompanyId(), Group.class.getName(),
            ResourceConstants.SCOPE_COMPANY, String.valueOf(_user1.getCompanyId()), role.getRoleId(),
            ActionKeys.UPDATE);//from   ww w. ja  va2s. c  o m

    PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(_user1);

    PermissionThreadLocal.setPermissionChecker(permissionChecker);

    Group userGroup = GroupLocalServiceUtil.getUserGroup(_user2.getCompanyId(), _user2.getUserId());

    LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(userGroup.getGroupId(), true);

    SitesUtil.resetPrototype(layoutSet);
}

From source file:com.liferay.roles.admin.internal.exportimport.data.handler.test.RoleStagedModelDataHandlerTest.java

License:Open Source License

@Override
protected StagedModel addStagedModel(Group group, Map<String, List<StagedModel>> dependentStagedModelsMap)
        throws Exception {

    return RoleTestUtil.addRole(RoleConstants.TYPE_REGULAR);
}

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

License:Open Source License

@Test
public void testDeleteOrganizationSiteOnlyRemovesSiteRoles() throws Exception {

    Organization organization = OrganizationLocalServiceUtil.addOrganization(TestPropsValues.getUserId(),
            OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID, RandomTestUtil.randomString(), true);

    Group organizationSite = GroupLocalServiceUtil.getOrganizationGroup(TestPropsValues.getCompanyId(),
            organization.getOrganizationId());

    organizationSite.setManualMembership(true);

    User user = UserTestUtil.addOrganizationOwnerUser(organization);

    UserLocalServiceUtil.addGroupUser(organizationSite.getGroupId(), user.getUserId());
    UserLocalServiceUtil.addOrganizationUsers(organization.getOrganizationId(),
            new long[] { user.getUserId() });

    Role siteRole = RoleTestUtil.addRole(RoleConstants.TYPE_SITE);

    UserGroupRoleLocalServiceUtil.addUserGroupRoles(user.getUserId(), organizationSite.getGroupId(),
            new long[] { siteRole.getRoleId() });

    GroupLocalServiceUtil.deleteGroup(organizationSite);

    Assert.assertEquals(1, UserGroupRoleLocalServiceUtil.getUserGroupRolesCount(user.getUserId(),
            organizationSite.getGroupId()));

    UserLocalServiceUtil.deleteUser(user);

    OrganizationLocalServiceUtil.deleteOrganization(organization);
}

From source file:com.liferay.user.groups.admin.service.test.UserGroupLocalServiceTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    _role = RoleTestUtil.addRole(RoleConstants.TYPE_REGULAR);

    _companyId = _role.getCompanyId();//from   w  ww.  ja  v a  2  s . co  m

    _count = UserGroupLocalServiceUtil.searchCount(_companyId, null, new LinkedHashMap<String, Object>());

    _userGroup1 = UserGroupTestUtil.addUserGroup();
    _userGroup2 = UserGroupTestUtil.addUserGroup();

    GroupLocalServiceUtil.addRoleGroup(_role.getRoleId(), _userGroup1.getGroupId());
}

From source file:com.liferay.user.groups.admin.web.internal.search.test.UserGroupIndexerTest.java

License:Open Source License

@Test
public void testSearchUserGroups() throws Exception {
    _role = RoleTestUtil.addRole(RoleConstants.TYPE_REGULAR);

    long companyId = _role.getCompanyId();

    int count = _userGroupLocalService.searchCount(companyId, null, new LinkedHashMap<String, Object>());

    UserGroup userGroup = addUserGroup();

    addUserGroup();/*from w ww  . j a va2 s . c  o  m*/

    GroupLocalServiceUtil.addRoleGroup(_role.getRoleId(), userGroup.getGroupId());

    Hits hits = search(companyId);

    Assert.assertEquals(hits.toString(), count + 2, hits.getLength());
}