/** * 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.UnlocalizedValue; import com.liferay.dynamic.data.mapping.storage.DDMFormFieldValue; import com.liferay.dynamic.data.mapping.storage.DDMFormValues; import com.liferay.dynamic.data.mapping.test.util.DDMFormTestUtil; import com.liferay.dynamic.data.mapping.test.util.DDMFormValuesTestUtil; import com.liferay.portal.kernel.util.LocaleUtil; import org.junit.Assert; import org.junit.Test; /** * @author Marcellus Tavares */ public class NumericDDMFormFieldValueRendererTest { @Test public void testRender() throws Exception { DDMForm ddmForm = DDMFormTestUtil.createDDMForm(); DDMFormField ddmFormField = DDMFormTestUtil.createDDMFormField( "Numeric", "Numeric", "numeric", "double", false, false, false); ddmForm.addDDMFormField(ddmFormField); DDMFormValues ddmFormValues = DDMFormValuesTestUtil.createDDMFormValues( ddmForm); DDMFormFieldValue ddmFormFieldValue = DDMFormValuesTestUtil.createDDMFormFieldValue( "Numeric", new UnlocalizedValue("1.25")); ddmFormValues.addDDMFormFieldValue(ddmFormFieldValue); String enRenderedValue = _numericDDMFormFieldValueRenderer.render( ddmFormFieldValue, LocaleUtil.US); Assert.assertEquals("1.25", enRenderedValue); String ptRenderedValue = _numericDDMFormFieldValueRenderer.render( ddmFormFieldValue, LocaleUtil.BRAZIL); Assert.assertEquals("1,25", ptRenderedValue); } private final NumericDDMFormFieldValueRenderer _numericDDMFormFieldValueRenderer = new NumericDDMFormFieldValueRenderer(); }