@Test
  public void testTransformTextFormFieldValue() throws Exception {
    DDMForm ddmForm = createDDMForm();

    addTextDDMFormFields(ddmForm, "FirstName", "LastName");

    DDMFormField ddmFormField = new DDMFormField("Description", "textarea");

    ddmForm.addDDMFormField(ddmFormField);

    DDMFormValues ddmFormValues = createDDMFormValues(ddmForm);

    ddmFormValues.addDDMFormFieldValue(
        createDDMFormFieldValue("FirstName", new UnlocalizedValue("Joe")));
    ddmFormValues.addDDMFormFieldValue(
        createDDMFormFieldValue("LastName", new UnlocalizedValue("Smith")));
    ddmFormValues.addDDMFormFieldValue(
        createDDMFormFieldValue("Description", new UnlocalizedValue("Description Value")));

    DDMFormValuesTransformer ddmFormValuesTransformer = new DDMFormValuesTransformer(ddmFormValues);

    String prefix = StringPool.UNDERLINE;

    ddmFormValuesTransformer.addTransformer(new DDMFormFieldValuePrefixAppender(prefix));

    ddmFormValuesTransformer.transform();

    List<DDMFormFieldValue> ddmFormFieldValues = ddmFormValues.getDDMFormFieldValues();

    testDDMFormFieldValue(ddmFormFieldValues.get(0), prefix.concat("Joe"));
    testDDMFormFieldValue(ddmFormFieldValues.get(1), prefix.concat("Smith"));
    testDDMFormFieldValue(ddmFormFieldValues.get(2), "Description Value");
  }
  protected void setDDMFormFieldValues(
      HttpServletRequest httpServletRequest, DDMFormValues ddmFormValues) {

    List<DDMFormFieldValue> ddmFormFieldValues =
        getDDMFormFieldValues(httpServletRequest, ddmFormValues.getDDMForm());

    ddmFormValues.setDDMFormFieldValues(ddmFormFieldValues);
  }
  protected DDMFormValues createDDMFormValues(DDMForm ddmForm) {
    DDMFormValues ddmFormValues = new DDMFormValues();

    ddmFormValues.setAvailableLocales(createAvailableLocales(LocaleUtil.US));
    ddmFormValues.setDDMForm(ddmForm);
    ddmFormValues.setDefaultLocale(LocaleUtil.US);

    return ddmFormValues;
  }
  protected SkinnyDDLRecord getSkinnyDDLRecord(DDLRecord ddlRecord) throws Exception {

    SkinnyDDLRecord skinnyDDLRecord = new SkinnyDDLRecord();

    skinnyDDLRecord.addDynamicElement("uuid", ddlRecord.getUuid());

    DDMFormValues ddmFormValues = ddlRecord.getDDMFormValues();

    populateSkinnyDDLRecord(
        skinnyDDLRecord, ddmFormValues.getDDMFormFieldValues(), ddmFormValues.getDefaultLocale());

    return skinnyDDLRecord;
  }
  @Test
  public void testTransformNestedRepeatableTextFormFieldValue() throws Exception {

    DDMForm ddmForm = createDDMForm();

    DDMFormField nameDDMFormField = new DDMFormField("Name", "textarea");

    DDMFormField phoneDDMFormField = new DDMFormField("Phone", "text");

    phoneDDMFormField.setRepeatable(true);

    nameDDMFormField.addNestedDDMFormField(phoneDDMFormField);

    ddmForm.addDDMFormField(nameDDMFormField);

    DDMFormValues ddmFormValues = createDDMFormValues(ddmForm);

    DDMFormFieldValue nameDDMFormFieldValue =
        createDDMFormFieldValue("Name", new UnlocalizedValue("Joe Smith"));

    nameDDMFormFieldValue.addNestedDDMFormFieldValue(
        createDDMFormFieldValue("Phone", new UnlocalizedValue("123")));
    nameDDMFormFieldValue.addNestedDDMFormFieldValue(
        createDDMFormFieldValue("Phone", new UnlocalizedValue("456")));
    nameDDMFormFieldValue.addNestedDDMFormFieldValue(
        createDDMFormFieldValue("Phone", new UnlocalizedValue("789")));

    ddmFormValues.addDDMFormFieldValue(nameDDMFormFieldValue);

    DDMFormValuesTransformer ddmFormValuesTransformer = new DDMFormValuesTransformer(ddmFormValues);

    String prefix = "+1";

    ddmFormValuesTransformer.addTransformer(new DDMFormFieldValuePrefixAppender(prefix));

    ddmFormValuesTransformer.transform();

    List<DDMFormFieldValue> ddmFormFieldValues = ddmFormValues.getDDMFormFieldValues();

    nameDDMFormFieldValue = ddmFormFieldValues.get(0);

    testDDMFormFieldValue(ddmFormFieldValues.get(0), "Joe Smith");

    List<DDMFormFieldValue> phoneDDMFormFieldValues =
        nameDDMFormFieldValue.getNestedDDMFormFieldValues();

    testDDMFormFieldValue(phoneDDMFormFieldValues.get(0), prefix.concat("123"));
    testDDMFormFieldValue(phoneDDMFormFieldValues.get(1), prefix.concat("456"));
    testDDMFormFieldValue(phoneDDMFormFieldValues.get(2), prefix.concat("789"));
  }
  protected void setDDMFormValuesDefaultLocale(
      HttpServletRequest httpServletRequest, DDMFormValues ddmFormValues) {

    Locale defaultLocale = getDefaultLocale(httpServletRequest);

    ddmFormValues.setDefaultLocale(defaultLocale);
  }
  protected void setDDMFormValuesAvailableLocales(
      HttpServletRequest httpServletRequest, DDMFormValues ddmFormValues) {

    Set<Locale> availableLocales = getAvailableLocales(httpServletRequest);

    ddmFormValues.setAvailableLocales(availableLocales);
  }