DDMFormContextToDDMForm implements DDMFormContextDeserializer<DDMForm> { protected Object getValueFromValueAccessor( String type, String serializedValue, Locale defaultLocale) { DDMFormFieldValueAccessor<?> ddmFormFieldValueAccessor = ddmFormFieldTypeServicesTracker.getDDMFormFieldValueAccessor(type); DDMFormFieldValue ddmFormFieldValue = new DDMFormFieldValue(); ddmFormFieldValue.setValue(new UnlocalizedValue(serializedValue)); if (ddmFormFieldValueAccessor != null) { Object value = ddmFormFieldValueAccessor.getValue( ddmFormFieldValue, defaultLocale); if (!(value instanceof BigDecimal)) { return value; } } return serializedValue; }  @Override DDMForm deserialize(
			DDMFormContextDeserializerRequest ddmFormContextDeserializerRequest);  }
@Test public void testGetValueFromValueAccessor() throws IOException { Mockito.when( _ddmFormFieldTypeServicesTracker.getDDMFormFieldValueAccessor( Matchers.anyString()) ).thenReturn( _ddmFormFieldValueAccessor ); Mockito.when( _ddmFormFieldValueAccessor.getValue(Matchers.any(), Matchers.any()) ).thenReturn( false ); _ddmFormContextToDDMForm.ddmFormFieldTypeServicesTracker = _ddmFormFieldTypeServicesTracker; Object result = _ddmFormContextToDDMForm.getValueFromValueAccessor( "checkbox", "false", LocaleUtil.US); Assert.assertEquals(false, result); }
@Test public void testGetValueWithoutValueAccessor() throws IOException { Mockito.when( _ddmFormFieldTypeServicesTracker.getDDMFormFieldValueAccessor( Matchers.anyString()) ).thenReturn( null ); _ddmFormContextToDDMForm.ddmFormFieldTypeServicesTracker = _ddmFormFieldTypeServicesTracker; Object result = _ddmFormContextToDDMForm.getValueFromValueAccessor( "checkbox", "false", LocaleUtil.US); Assert.assertEquals("false", result); }