/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.journal.test.util; import com.liferay.journal.model.JournalArticle; import com.liferay.journal.model.JournalFolderConstants; import com.liferay.journal.service.JournalArticleLocalServiceUtil; import com.liferay.portal.kernel.service.ServiceContext; import com.liferay.portal.kernel.test.util.ServiceContextTestUtil; import java.util.Locale; import java.util.Map; /** * @author André de Oliveira */ public class JournalArticleBuilder { public JournalArticle addArticle() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_groupId); long userId = serviceContext.getUserId(); long folderId = JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID; Map<Locale, String> titleMap = _journalArticleTitle.getValues(); Map<Locale, String> descriptionMap = null; String contentString = _journalArticleContent.getContentString(); String ddmStructureKey = "BASIC-WEB-CONTENT"; String ddmTemplateKey = "BASIC-WEB-CONTENT"; return JournalArticleLocalServiceUtil.addArticle( userId, _groupId, folderId, titleMap, descriptionMap, contentString, ddmStructureKey, ddmTemplateKey, serviceContext); } public void setContent(JournalArticleContent content) { _journalArticleContent = content; } public void setGroupId(long groupId) { _groupId = groupId; } public void setTitle(JournalArticleTitle title) { _journalArticleTitle = title; } private Long _groupId; private JournalArticleContent _journalArticleContent; private JournalArticleTitle _journalArticleTitle; }