@Test
  public void testGetDDMStructure() throws Exception {
    DDMForm ddmForm = DDMFormTestUtil.createDDMForm("Text1", "Text2", "Text3");

    DDMStructure ddmStructure =
        DDMStructureTestUtil.addStructure(
            _group.getGroupId(), DDLRecordSet.class.getName(), ddmForm);

    DDLRecordSet recordSet = _ddlRecordSetTestHelper.addRecordSet(ddmStructure);

    ddmForm = DDMFormTestUtil.createDDMForm("Text2", "Text3");

    DDMTemplate template =
        DDMTemplateTestUtil.addTemplate(
            _group.getGroupId(),
            ddmStructure.getStructureId(),
            PortalUtil.getClassNameId(DDLRecordSet.class),
            "json",
            DDMFormJSONSerializerUtil.serialize(ddmForm),
            LocaleUtil.US);

    Set<String> fieldNames = ddmStructure.getFieldNames();

    DDMStructure recordSetDDMStructure = recordSet.getDDMStructure(template.getTemplateId());

    if (fieldNames.equals(recordSetDDMStructure.getFieldNames())) {
      Assert.fail();
    }

    recordSetDDMStructure = recordSet.getDDMStructure();

    if (!fieldNames.equals(recordSetDDMStructure.getFieldNames())) {
      Assert.fail();
    }
  }
  public String getDDMFormHTML() throws PortalException {
    DDLRecordSet recordSet = getRecordSet();

    if (recordSet == null) {
      return StringPool.BLANK;
    }

    DDMStructure ddmStructure = recordSet.getDDMStructure();
    boolean requireCaptcha = isCaptchaRequired(recordSet);

    DDMForm ddmForm = getDDMForm(ddmStructure, requireCaptcha);

    DDMFormLayout ddmFormLayout = getDDMFormLayout(ddmStructure, requireCaptcha);

    DDMFormRenderingContext ddmFormRenderingContext = createDDMFormRenderingContext(ddmForm);

    boolean showSubmitButton = isShowSubmitButton();

    ddmFormRenderingContext.setShowSubmitButton(showSubmitButton);

    String submitLabel = getSubmitLabel(recordSet);

    ddmFormRenderingContext.setSubmitLabel(submitLabel);

    return _ddmFormRenderer.render(ddmForm, ddmFormLayout, ddmFormRenderingContext);
  }
  public String getEditFormDDMTemplateTitle() throws PortalException {
    DDLRecordSet recordSet = getRecordSet();

    if (recordSet == null) {
      return LanguageUtil.get(getLocale(), "add-list");
    }

    DDMDisplay ddmDisplay = getDDMDisplay();

    return ddmDisplay.getEditTemplateTitle(
        recordSet.getDDMStructure(), fetchFormDDMTemplate(), getLocale());
  }
  public String getEditDisplayDDMTemplateTitle() throws PortalException {
    DDLRecordSet recordSet = getRecordSet();

    if (recordSet == null) {
      return StringPool.BLANK;
    }

    DDMDisplay ddmDisplay = getDDMDisplay();

    return ddmDisplay.getEditTemplateTitle(
        recordSet.getDDMStructure(), fetchDisplayDDMTemplate(), getLocale());
  }
  public String getAddRecordLabel() throws PortalException {
    DDLRecordSet recordSet = getRecordSet();

    String structureName = StringPool.BLANK;

    if (recordSet != null) {
      DDMStructure ddmStructure = recordSet.getDDMStructure();

      structureName = ddmStructure.getName(_ddlRequestHelper.getLocale());
    }

    return LanguageUtil.format(
        _ddlRequestHelper.getRequest(), "add-x", HtmlUtil.escape(structureName), false);
  }