Search in sources :

Example 1 with CharacterBoxFieldDefinition

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.CharacterBoxFieldDefinition in project kie-wb-common by kiegroup.

the class DataObjectFormModelHandlerTest method checkCommonProperties.

private FieldDefinition checkCommonProperties(String dataFieldName) {
    ObjectProperty dataField = dataObject.getProperty(dataFieldName);
    FieldDefinition formField = fieldManager.getDefinitionByModelProperty(formModel.getProperty(dataFieldName));
    String dataFieldClassName = dataField.getClassName();
    TypeInfo fieldTypeInfo = formField.getFieldTypeInfo();
    // test common properties
    assertEquals(dataFieldClassName, fieldTypeInfo.getClassName());
    assertNotEquals(TypeKind.ENUM, fieldTypeInfo.getType());
    assertEquals(dataField.isMultiple(), fieldTypeInfo.isMultiple());
    assertEquals(dataField.getName().toLowerCase(), formField.getLabel().toLowerCase());
    assertEquals(dataField.getName(), formField.getBinding());
    assertEquals(dataFieldClassName, formField.getStandaloneClassName());
    assertFalse(formField.getReadOnly());
    assertFalse(formField.getRequired());
    assertTrue(formField.getValidateOnChange());
    // test interface specific properties
    if (formField instanceof HasPlaceHolder) {
        assertEquals(dataField.getName().toLowerCase(), ((HasPlaceHolder) formField).getPlaceHolder().toLowerCase());
    }
    if (formField instanceof HasMaxLength) {
        long maxLength = ((HasMaxLength) formField).getMaxLength();
        assertTrue(formField instanceof CharacterBoxFieldDefinition ? maxLength == 1 : maxLength == 100);
    }
    return formField;
}
Also used : ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) HasMaxLength(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.HasMaxLength) CharacterBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.CharacterBoxFieldDefinition) HasPlaceHolder(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.HasPlaceHolder) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) CharacterBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.CharacterBoxFieldDefinition) DecimalBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) TypeInfo(org.kie.workbench.common.forms.model.TypeInfo)

Aggregations

HasMaxLength (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.HasMaxLength)1 HasPlaceHolder (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.HasPlaceHolder)1 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)1 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)1 DecimalBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)1 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)1 CharacterBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.CharacterBoxFieldDefinition)1 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)1 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)1 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)1 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)1 TypeInfo (org.kie.workbench.common.forms.model.TypeInfo)1 ObjectProperty (org.kie.workbench.common.services.datamodeller.core.ObjectProperty)1