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);
});
}
Aggregations