NumericDDMFormFieldTemplateContextContributor implements DDMFormFieldTemplateContextContributor { protected String getDataType( DDMFormField ddmFormField, DDMFormFieldRenderingContext ddmFormFieldRenderingContext) { Map<String, Object> changedProperties = (Map<String, Object>)ddmFormFieldRenderingContext.getProperty( "changedProperties"); if (MapUtil.isNotEmpty(changedProperties)) { String dataType = (String)changedProperties.get("dataType"); if (dataType != null) { return dataType; } } return ddmFormField.getDataType(); }  @Override Map<String, Object> getParameters(
		DDMFormField ddmFormField,
		DDMFormFieldRenderingContext ddmFormFieldRenderingContext);  }
@Test public void testGetDataType1() { String fieldName = "field"; DDMFormField ddmFormField = new DDMFormField(fieldName, "numeric"); ddmFormField.setProperty("dataType", "double"); DDMFormFieldRenderingContext ddmFormFieldRenderingContext = new DDMFormFieldRenderingContext(); ddmFormFieldRenderingContext.setProperty("changedProperties", null); Assert.assertEquals( "double", _numericDDMFormFieldTemplateContextContributor.getDataType( ddmFormField, ddmFormFieldRenderingContext)); }
@Test public void testGetDataType2() { DDMFormField ddmFormField = new DDMFormField("field", "numeric"); ddmFormField.setProperty("dataType", "integer"); DDMFormFieldRenderingContext ddmFormFieldRenderingContext = new DDMFormFieldRenderingContext(); ddmFormFieldRenderingContext.setProperty( "changedProperties", new HashMap<String, Object>()); Assert.assertEquals( "integer", _numericDDMFormFieldTemplateContextContributor.getDataType( ddmFormField, ddmFormFieldRenderingContext)); }
@Test public void testGetDataType3() { DDMFormField ddmFormField = new DDMFormField("field", "numeric"); ddmFormField.setProperty("dataType", "integer"); DDMFormFieldRenderingContext ddmFormFieldRenderingContext = new DDMFormFieldRenderingContext(); ddmFormFieldRenderingContext.setProperty( "changedProperties", HashMapBuilder.<String, Object>put( "dataType", "double" ).build()); Assert.assertEquals( "double", _numericDDMFormFieldTemplateContextContributor.getDataType( ddmFormField, ddmFormFieldRenderingContext)); }