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.portlet.layoutsadmin.util.test;
016    
017    import com.liferay.portal.kernel.test.util.RandomTestUtil;
018    import com.liferay.portal.kernel.test.util.ServiceContextTestUtil;
019    import com.liferay.portal.kernel.test.util.TestPropsValues;
020    import com.liferay.portal.model.User;
021    import com.liferay.portal.service.ServiceContext;
022    import com.liferay.portal.service.UserLocalServiceUtil;
023    import com.liferay.portlet.exportimport.configuration.ExportImportConfigurationSettingsMapFactory;
024    import com.liferay.portlet.exportimport.model.ExportImportConfiguration;
025    import com.liferay.portlet.exportimport.service.ExportImportConfigurationLocalServiceUtil;
026    
027    import java.io.Serializable;
028    
029    import java.util.Map;
030    
031    /**
032     * @author Daniel Kocsis
033     */
034    public class ExportImportConfigurationTestUtil {
035    
036            public static ExportImportConfiguration addExportImportConfiguration(
037                            long groupId, int type)
038                    throws Exception {
039    
040                    Map<String, Serializable> settingsMap = getDefaultSettingsMap(
041                            TestPropsValues.getUserId(), groupId);
042    
043                    return addExportImportConfiguration(groupId, type, settingsMap);
044            }
045    
046            public static ExportImportConfiguration addExportImportConfiguration(
047                            long groupId, int type, Map<String, Serializable> settingsMap)
048                    throws Exception {
049    
050                    ServiceContext serviceContext =
051                            ServiceContextTestUtil.getServiceContext(groupId);
052    
053                    return ExportImportConfigurationLocalServiceUtil.
054                            addExportImportConfiguration(
055                                    TestPropsValues.getUserId(), groupId,
056                                    RandomTestUtil.randomString(), RandomTestUtil.randomString(),
057                                    type, settingsMap, serviceContext);
058            }
059    
060            public static Map<String, Serializable> getDefaultSettingsMap(
061                            long userId, long groupId)
062                    throws Exception {
063    
064                    User user = UserLocalServiceUtil.getUser(userId);
065    
066                    return ExportImportConfigurationSettingsMapFactory.
067                            buildPublishLayoutLocalSettingsMap(
068                                    user, groupId, groupId, false, null, null);
069            }
070    
071    }