use of org.kie.workbench.common.forms.adf.service.definitions.elements.FieldElement in project kie-wb-common by kiegroup.
the class AbstractFormGenerationTest method testGeneratedForm.
protected void testGeneratedForm(FormDefinition form, String modelName) {
assertNotNull(form);
FormDefinitionSettings settings = resourcesProvider.getDefinitionSettings().get(modelName);
assertEquals(settings.getModelType(), form.getId());
assertEquals(settings.getModelType(), form.getName());
assertEquals(settings.getFormElements().size(), form.getFields().size());
settings.getFormElements().forEach(element -> {
FieldElement fieldElement = (FieldElement) element;
FieldDefinition field = form.getFieldByBinding(fieldElement.getBinding());
assertNotNull(field);
assertEquals(fieldElement.getName(), field.getName());
if (!fieldElement.getPreferredType().equals(FieldType.class)) {
assertEquals(fieldElement.getPreferredType(), field.getFieldType().getClass());
}
assertEquals(fieldElement.getTypeInfo().getClassName(), field.getStandaloneClassName());
assertEquals(fieldElement.isReadOnly(), field.getReadOnly());
assertEquals(fieldElement.isRequired(), field.getRequired());
assertEquals(fieldElement.getBinding(), field.getBinding());
verify(i18nHelper, atLeast(1)).getTranslation(field.getName() + ".label");
});
assertNotNull(form.getLayoutTemplate());
assertEquals(settings.getFormElements().size(), form.getLayoutTemplate().getRows().size());
form.getLayoutTemplate().getRows().forEach(row -> {
assertNotNull(row);
assertEquals(1, row.getLayoutColumns().size());
LayoutColumn column = row.getLayoutColumns().get(0);
assertNotNull(column);
assertEquals("12", column.getSpan());
assertEquals(1, column.getLayoutComponents().size());
LayoutComponent layoutComponent = column.getLayoutComponents().get(0);
String formId = layoutComponent.getProperties().get(FormLayoutComponent.FORM_ID);
assertNotNull(formId);
assertEquals(form.getId(), formId);
String fieldId = layoutComponent.getProperties().get(FormLayoutComponent.FIELD_ID);
assertNotNull(fieldId);
FieldDefinition field = form.getFieldById(fieldId);
assertNotNull(field);
});
}
Aggregations