/** * 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.dynamic.data.mapping.test.util; import com.liferay.dynamic.data.mapping.model.DDMFormLayout; import com.liferay.dynamic.data.mapping.model.DDMFormLayoutColumn; import com.liferay.dynamic.data.mapping.model.DDMFormLayoutRow; import com.liferay.dynamic.data.mapping.model.DDMStructureLayout; import com.liferay.dynamic.data.mapping.service.DDMStructureLayoutLocalServiceUtil; import com.liferay.portal.kernel.model.Group; import com.liferay.portal.kernel.service.ServiceContext; import com.liferay.portal.kernel.test.util.ServiceContextTestUtil; import com.liferay.portal.kernel.test.util.TestPropsValues; import java.util.ArrayList; import java.util.List; /** * @author Marcellus Tavares */ public class DDMStructureLayoutTestHelper { public DDMStructureLayoutTestHelper(Group group) throws Exception { _group = group; } public DDMStructureLayout addStructureLayout( long structureId, DDMFormLayout ddmFormLayout) throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); return DDMStructureLayoutLocalServiceUtil.addStructureLayout( TestPropsValues.getUserId(), _group.getGroupId(), structureId, ddmFormLayout, serviceContext); } public List<DDMFormLayoutColumn> createDDMFormLayoutColumns( String... ddmFormFieldNames) { List<DDMFormLayoutColumn> ddmFormLayoutColumns = new ArrayList<>(); int size = 12 / ddmFormFieldNames.length; for (String ddmFormFieldName : ddmFormFieldNames) { ddmFormLayoutColumns.add( new DDMFormLayoutColumn(size, ddmFormFieldName)); } return ddmFormLayoutColumns; } public DDMFormLayoutRow createDDMFormLayoutRow( List<DDMFormLayoutColumn> ddmFormLayoutColumns) { DDMFormLayoutRow ddmFormLayoutRow = new DDMFormLayoutRow(); ddmFormLayoutRow.setDDMFormLayoutColumns(ddmFormLayoutColumns); return ddmFormLayoutRow; } private final Group _group; }