Search in sources :

Example 11 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FormEditorPresenterTest method testOnRemoveComponent.

public void testOnRemoveComponent(boolean noContext) {
    loadContent();
    loadAvailableFields();
    addAllFields();
    VerificationMode count = times(1);
    if (noContext) {
        when(editorHelper.getContent()).thenReturn(null);
        count = never();
    }
    FormEditorPresenter presenterSpy = spy(presenter);
    String formId = presenterSpy.getFormDefinition().getId();
    FieldDefinition field = editorHelper.getFormDefinition().getFields().get(0);
    ComponentRemovedEvent event = new ComponentRemovedEvent(createLayoutComponent(presenter.getFormDefinition(), field), false);
    presenterSpy.onRemoveComponent(event);
    verify(presenterSpy, count).onSyncPalette(formId);
    verify(editorHelper, count).removeField(anyString(), anyBoolean());
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) ComponentRemovedEvent(org.uberfire.ext.layout.editor.client.api.ComponentRemovedEvent) Mockito.anyString(org.mockito.Mockito.anyString) VerificationMode(org.mockito.verification.VerificationMode)

Example 12 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FieldPropertiesRendererTest method testResetFieldCopy.

@Test
public void testResetFieldCopy() {
    FieldDefinition originalField = lastNameField;
    loadContent();
    FieldDefinition fieldCopy = renderer.resetFieldCopy(originalField);
    assertEquals(originalField.getId(), fieldCopy.getId());
    assertEquals(originalField.getName(), fieldCopy.getName());
    assertEquals(originalField.getLabel(), fieldCopy.getLabel());
    assertEquals(originalField.getStandaloneClassName(), fieldCopy.getStandaloneClassName());
    assertEquals(originalField.getRequired(), fieldCopy.getRequired());
    assertEquals(originalField.getReadOnly(), fieldCopy.getReadOnly());
    assertEquals(originalField.getValidateOnChange(), fieldCopy.getValidateOnChange());
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) Test(org.junit.Test)

Example 13 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class EditorFieldLayoutComponentTest method setupFormEditorHelper.

protected FieldDefinition setupFormEditorHelper() {
    FieldDefinition newField = mock(FieldDefinition.class);
    when(newField.getId()).thenReturn(EditorFieldLayoutComponent.FIELD_ID);
    doReturn(newField).when(fieldManager).getFieldFromProvider(anyString(), any(TypeInfo.class));
    FieldDefinition fieldCopy = propertiesRendererHelper.onFieldTypeChange(fieldDefinition, RadioGroupFieldType.NAME);
    editorFieldLayoutComponent.setSettingValue(EditorFieldLayoutComponent.FORM_ID, EditorFieldLayoutComponent.FORM_ID);
    editorFieldLayoutComponent.setSettingValue(EditorFieldLayoutComponent.FIELD_ID, EditorFieldLayoutComponent.FIELD_ID);
    editorFieldLayoutComponent.generateContent(ctx);
    return fieldCopy;
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) TypeInfo(org.kie.workbench.common.forms.model.TypeInfo)

Example 14 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class EditorFieldLayoutComponentTest method testOnPressOk.

protected void testOnPressOk(boolean bound, boolean withConfigContext) {
    FieldDefinition fieldCopy = setupFormEditorHelper();
    ModalConfigurationContext ctx = mock(ModalConfigurationContext.class);
    if (bound) {
        when(fieldCopy.getBinding()).thenReturn(BINDING_FIRSTNAME);
    }
    if (withConfigContext) {
        when(ctx.getComponentProperties()).thenReturn(mock(Map.class));
        editorFieldLayoutComponent.getConfigurationModal(ctx);
    }
    editorFieldLayoutComponent.onPressOk(fieldCopy);
    assertSame(fieldCopy, editorFieldLayoutComponent.getField());
    verify(syncPaletteEvent).fire(any());
    verify(formEditorHelper, bound ? times(1) : times(0)).removeAvailableField(any());
    verify(ctx, withConfigContext ? times(1) : times(0)).configurationFinished();
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) ModalConfigurationContext(org.uberfire.ext.layout.editor.client.api.ModalConfigurationContext) Map(java.util.Map)

Example 15 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class EditorFieldLayoutComponentTest method testOnFieldTypeChange.

@Test
public void testOnFieldTypeChange() {
    FieldDefinition result = propertiesRendererHelper.onFieldTypeChange(fieldDefinition, RadioGroupFieldType.NAME);
    verify(fieldManager).getFieldFromProvider(RadioGroupFieldType.NAME, fieldDefinition.getFieldTypeInfo());
    assertEquals(fieldDefinition.getId(), result.getId());
    assertEquals(fieldDefinition.getName(), result.getName());
    assertEquals(fieldDefinition.getBinding(), result.getBinding());
    assertNotEquals(fieldDefinition.getClass(), result.getClass());
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) Test(org.junit.Test)

Aggregations

FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)85 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)42 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)29 Test (org.junit.Test)27 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)24 TextAreaFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition)22 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)21 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)20 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)18 DecimalBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)17 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)14 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)13 ArrayList (java.util.ArrayList)11 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)9 LayoutComponent (org.uberfire.ext.layout.editor.api.editor.LayoutComponent)8 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)7 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)7 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)7 LayoutColumn (org.uberfire.ext.layout.editor.api.editor.LayoutColumn)7 LayoutRow (org.uberfire.ext.layout.editor.api.editor.LayoutRow)7