protected void assertEquals(DDMForm expectedDDMForm, DDMForm actualDDMForm) {

    Map<String, DDMFormField> expectedDDMFormFieldsMap = expectedDDMForm.getDDMFormFieldsMap(true);

    Map<String, DDMFormField> actualDDMFormFieldsMap = actualDDMForm.getDDMFormFieldsMap(true);

    for (Map.Entry<String, DDMFormField> expectedEntry : expectedDDMFormFieldsMap.entrySet()) {

      DDMFormField actualDDMFormField = actualDDMFormFieldsMap.get(expectedEntry.getKey());

      assertEquals(expectedEntry.getValue(), actualDDMFormField);
    }
  }
  @Test
  public void testCreateDDMFormFieldTypeSettingsDDMForm() {
    DDMForm ddmForm = DDMFormFactory.create(DDMFormFieldTypeSettings.class);

    Assert.assertNotNull(ddmForm);

    assertRequiredDDMFormFieldTypeSettings(ddmForm.getDDMFormFieldsMap(false));
  }
  protected DDMFormField getDDMFormField(HttpServletRequest request) throws PortalException {

    String definition = ParamUtil.getString(request, "definition");
    String fieldName = ParamUtil.getString(request, "fieldName");

    DDMForm ddmForm = _ddmFormJSONDeserializer.deserialize(definition);

    Map<String, DDMFormField> ddmFormFieldsMap = ddmForm.getDDMFormFieldsMap(true);

    return ddmFormFieldsMap.get(fieldName);
  }
  protected Map<String, DDMFormFieldValue> createDDMFormFieldValuesMap(
      HttpServletRequest httpServletRequest, DDMForm ddmForm) {

    Map<String, DDMFormFieldValue> ddmFormFieldValuesMap = new HashMap<>();

    Set<String> ddmFormFieldParameterNames =
        getDDMFormFieldParameterNames(httpServletRequest, ddmForm);

    Map<String, DDMFormField> ddmFormFieldsMap = ddmForm.getDDMFormFieldsMap(true);

    for (String ddmFormFieldParameterName : ddmFormFieldParameterNames) {
      DDMFormFieldValue ddmFormFieldValue =
          createDDMFormFieldValue(httpServletRequest, ddmFormFieldParameterName, ddmFormFieldsMap);

      ddmFormFieldValuesMap.put(ddmFormFieldParameterName, ddmFormFieldValue);
    }

    return ddmFormFieldValuesMap;
  }
  @Test
  public void testCreateDefaultDDMFormFieldTypeSettingsDDMForm() {
    DDMForm ddmForm = DDMFormFactory.create(DefaultDDMFormFieldTypeSettings.class);

    Assert.assertNotNull(ddmForm);

    Map<String, DDMFormField> ddmFormFieldsMap = ddmForm.getDDMFormFieldsMap(false);

    assertRequiredDDMFormFieldTypeSettings(ddmFormFieldsMap);

    DDMFormField indexTypeDDMFormField = ddmFormFieldsMap.get("indexType");

    Assert.assertNotNull(indexTypeDDMFormField);
    Assert.assertEquals("string", indexTypeDDMFormField.getDataType());
    Assert.assertEquals("text", indexTypeDDMFormField.getType());

    DDMFormField labelDDMFormField = ddmFormFieldsMap.get("label");

    Assert.assertNotNull(labelDDMFormField);
    Assert.assertEquals("string", labelDDMFormField.getDataType());
    Assert.assertEquals("text", labelDDMFormField.getType());
    Assert.assertEquals(true, labelDDMFormField.isLocalizable());

    DDMFormField localizableDDMFormField = ddmFormFieldsMap.get("localizable");

    Assert.assertNotNull(localizableDDMFormField);
    Assert.assertEquals("boolean", localizableDDMFormField.getDataType());
    Assert.assertEquals("checkbox", localizableDDMFormField.getType());

    DDMFormField predefinedValueDDMFormField = ddmFormFieldsMap.get("predefinedValue");

    Assert.assertNotNull(predefinedValueDDMFormField);
    Assert.assertEquals("string", predefinedValueDDMFormField.getDataType());
    Assert.assertEquals("text", predefinedValueDDMFormField.getType());
    Assert.assertEquals(true, predefinedValueDDMFormField.isLocalizable());

    DDMFormField readOnlyDDMFormField = ddmFormFieldsMap.get("readOnly");

    Assert.assertNotNull(readOnlyDDMFormField);
    Assert.assertEquals("boolean", readOnlyDDMFormField.getDataType());
    Assert.assertEquals("checkbox", readOnlyDDMFormField.getType());

    DDMFormField repeatableDDMFormField = ddmFormFieldsMap.get("repeatable");

    Assert.assertNotNull(repeatableDDMFormField);
    Assert.assertEquals("boolean", repeatableDDMFormField.getDataType());
    Assert.assertEquals("checkbox", repeatableDDMFormField.getType());

    DDMFormField requiredDDMFormField = ddmFormFieldsMap.get("readOnly");

    Assert.assertNotNull(requiredDDMFormField);
    Assert.assertEquals("boolean", requiredDDMFormField.getDataType());
    Assert.assertEquals("checkbox", requiredDDMFormField.getType());

    DDMFormField showLabelDDMFormField = ddmFormFieldsMap.get("showLabel");

    Assert.assertNotNull(showLabelDDMFormField);
    Assert.assertEquals("boolean", showLabelDDMFormField.getDataType());
    Assert.assertEquals("checkbox", showLabelDDMFormField.getType());

    DDMFormField tipDDMFormField = ddmFormFieldsMap.get("tip");

    Assert.assertNotNull(tipDDMFormField);
    Assert.assertEquals("string", tipDDMFormField.getDataType());
    Assert.assertEquals("text", tipDDMFormField.getType());
    Assert.assertEquals(true, tipDDMFormField.isLocalizable());
  }