/** * 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.type.numeric.internal; import com.liferay.dynamic.data.mapping.model.DDMForm; import com.liferay.dynamic.data.mapping.model.DDMFormField; import com.liferay.dynamic.data.mapping.model.LocalizedValue; import com.liferay.dynamic.data.mapping.type.BaseDDMFormFieldTypeSettingsTestCase; import com.liferay.dynamic.data.mapping.util.DDMFormFactory; import com.liferay.portal.kernel.util.PortalClassLoaderUtil; import com.liferay.portal.kernel.util.ResourceBundleUtil; import java.util.Map; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; /** * @author Leonardo Barros */ @PrepareForTest({PortalClassLoaderUtil.class, ResourceBundleUtil.class}) @RunWith(PowerMockRunner.class) public class NumericDDMFormFieldTypeSettingsTest extends BaseDDMFormFieldTypeSettingsTestCase { @Test public void testCreateNumericDDMFormFieldTypeSettingsDDMForm() { DDMForm ddmForm = DDMFormFactory.create( NumericDDMFormFieldTypeSettings.class); Map<String, DDMFormField> ddmFormFieldsMap = ddmForm.getDDMFormFieldsMap(false); DDMFormField dataTypeDDMFormField = ddmFormFieldsMap.get("dataType"); Assert.assertNotNull(dataTypeDDMFormField); Assert.assertNotNull(dataTypeDDMFormField.getLabel()); Assert.assertEquals("radio", dataTypeDDMFormField.getType()); LocalizedValue predefinedValue = dataTypeDDMFormField.getPredefinedValue(); Assert.assertEquals( "integer", predefinedValue.getString(predefinedValue.getDefaultLocale())); DDMFormField placeholderDDMFormField = ddmFormFieldsMap.get( "placeholder"); Assert.assertNotNull(placeholderDDMFormField); Assert.assertEquals("string", placeholderDDMFormField.getDataType()); Assert.assertEquals("text", placeholderDDMFormField.getType()); DDMFormField tooltipDDMFormField = ddmFormFieldsMap.get("tooltip"); Assert.assertNotNull(tooltipDDMFormField); DDMFormField validationDDMFormField = ddmFormFieldsMap.get( "validation"); Assert.assertNotNull(validationDDMFormField); Assert.assertEquals("number", validationDDMFormField.getDataType()); } }