001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.test.util;
016    
017    import com.liferay.counter.service.CounterLocalServiceUtil;
018    import com.liferay.portal.model.ResourceTypePermission;
019    import com.liferay.portal.service.ResourceTypePermissionLocalServiceUtil;
020    
021    /**
022     * @author Alberto Chaparro
023     */
024    public class ResourceTypePermissionTestUtil {
025    
026            public static ResourceTypePermission addResourceTypePermission(
027                            long actionIds, long groupId, String name)
028                    throws Exception {
029    
030                    return addResourceTypePermission(
031                            actionIds, groupId, name, RandomTestUtil.nextLong());
032            }
033    
034            public static ResourceTypePermission addResourceTypePermission(
035                            long actionIds, long groupId, String name, long roleId)
036                    throws Exception {
037    
038                    long resourceTypePermissionId = CounterLocalServiceUtil.increment(
039                            ResourceTypePermission.class.getName());
040    
041                    ResourceTypePermission resourceTypePermission =
042                            ResourceTypePermissionLocalServiceUtil.createResourceTypePermission(
043                                    resourceTypePermissionId);
044    
045                    resourceTypePermission.setCompanyId(TestPropsValues.getCompanyId());
046                    resourceTypePermission.setGroupId(groupId);
047                    resourceTypePermission.setName(name);
048                    resourceTypePermission.setRoleId(roleId);
049                    resourceTypePermission.setActionIds(actionIds);
050    
051                    return ResourceTypePermissionLocalServiceUtil.addResourceTypePermission(
052                            resourceTypePermission);
053            }
054    
055    }