Search in sources :

Example 11 with LayoutRow

use of org.uberfire.ext.layout.editor.api.editor.LayoutRow in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorForBPMNWithComplexVariableTest method checkInvoiceFormDefinition.

protected void checkInvoiceFormDefinition(FormDefinition invoiceForm, Form originalForm) {
    assertNotNull(invoiceForm);
    Assertions.assertThat(invoiceForm.getModel()).isNotNull().isInstanceOf(DataObjectFormModel.class).hasFieldOrPropertyWithValue("className", INVOICE_MODEL);
    Assertions.assertThat(invoiceForm.getFields()).isNotEmpty().hasSize(3);
    IntStream indexStream = IntStream.range(0, invoiceForm.getFields().size());
    LayoutTemplate formLayout = invoiceForm.getLayoutTemplate();
    assertNotNull(formLayout);
    Assertions.assertThat(formLayout.getRows()).isNotEmpty().hasSize(3);
    indexStream.forEach(index -> {
        FieldDefinition fieldDefinition = invoiceForm.getFields().get(index);
        switch(index) {
            case 0:
                checkFieldDefinition(fieldDefinition, "invoice_user", "User Data:", "user", SubFormFieldDefinition.class, invoiceForm, originalForm.getField(fieldDefinition.getName()));
                break;
            case 1:
                checkFieldDefinition(fieldDefinition, "lines", "Invoice Lines", "lines", MultipleSubFormFieldDefinition.class, invoiceForm, originalForm.getField(fieldDefinition.getName()));
                break;
            case 2:
                checkFieldDefinition(fieldDefinition, "invoice_total", "Invoice Total:", "total", DecimalBoxFieldDefinition.class, invoiceForm, originalForm.getField(fieldDefinition.getName()));
                break;
        }
        LayoutRow fieldRow = formLayout.getRows().get(index);
        assertNotNull(fieldRow);
        Assertions.assertThat(fieldRow.getLayoutColumns()).isNotEmpty().hasSize(1);
        LayoutColumn fieldColumn = fieldRow.getLayoutColumns().get(0);
        assertNotNull(fieldColumn);
        assertEquals("12", fieldColumn.getSpan());
        Assertions.assertThat(fieldColumn.getLayoutComponents()).isNotEmpty().hasSize(1);
        checkLayoutFormField(fieldColumn.getLayoutComponents().get(0), fieldDefinition, invoiceForm);
    });
}
Also used : LayoutTemplate(org.uberfire.ext.layout.editor.api.editor.LayoutTemplate) LayoutRow(org.uberfire.ext.layout.editor.api.editor.LayoutRow) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) DecimalBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) LayoutColumn(org.uberfire.ext.layout.editor.api.editor.LayoutColumn) IntStream(java.util.stream.IntStream) DataObjectFormModel(org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel)

Aggregations

LayoutRow (org.uberfire.ext.layout.editor.api.editor.LayoutRow)11 LayoutColumn (org.uberfire.ext.layout.editor.api.editor.LayoutColumn)10 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)9 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)7 DecimalBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)6 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)6 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)6 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)6 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)6 IntStream (java.util.stream.IntStream)5 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)5 LayoutComponent (org.uberfire.ext.layout.editor.api.editor.LayoutComponent)5 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)4 Field (org.kie.workbench.common.forms.migration.legacy.model.Field)3 FormMigrationSummary (org.kie.workbench.common.forms.migration.tool.FormMigrationSummary)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Test (org.junit.Test)2 FormLayoutComponent (org.kie.workbench.common.forms.model.FormLayoutComponent)2 Matchers.anyString (org.mockito.Matchers.anyString)2