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.dynamicdatalists.util.test;
016    
017    import com.liferay.portal.kernel.util.LocaleUtil;
018    import com.liferay.portal.model.Group;
019    import com.liferay.portal.service.ServiceContext;
020    import com.liferay.portal.util.test.RandomTestUtil;
021    import com.liferay.portal.util.test.ServiceContextTestUtil;
022    import com.liferay.portal.util.test.TestPropsValues;
023    import com.liferay.portlet.dynamicdatalists.model.DDLRecordSet;
024    import com.liferay.portlet.dynamicdatalists.model.DDLRecordSetConstants;
025    import com.liferay.portlet.dynamicdatalists.service.DDLRecordSetLocalServiceUtil;
026    import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
027    
028    import java.util.HashMap;
029    import java.util.Locale;
030    import java.util.Map;
031    
032    /**
033     * @author Marcellus Tavares
034     * @author Andr?? de Oliveira
035     */
036    public class DDLRecordSetTestHelper {
037    
038            public DDLRecordSetTestHelper(Group group) throws Exception {
039                    _group = group;
040            }
041    
042            public DDLRecordSet addRecordSet(DDMStructure ddmStructure)
043                    throws Exception {
044    
045                    Map<Locale, String> nameMap = new HashMap<Locale, String>();
046    
047                    nameMap.put(LocaleUtil.US, RandomTestUtil.randomString());
048    
049                    ServiceContext serviceContext =
050                            ServiceContextTestUtil.getServiceContext(_group.getGroupId());
051    
052                    return DDLRecordSetLocalServiceUtil.addRecordSet(
053                            TestPropsValues.getUserId(), _group.getGroupId(),
054                            ddmStructure.getStructureId(), null, nameMap, null,
055                            DDLRecordSetConstants.MIN_DISPLAY_ROWS_DEFAULT,
056                            DDLRecordSetConstants.SCOPE_DYNAMIC_DATA_LISTS, serviceContext);
057            }
058    
059            private final Group _group;
060    
061    }