use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormGeneratorTest method testGenerateFormForClassNameWithFilters.
@Test
public void testGenerateFormForClassNameWithFilters() {
FormDefinition form = generator.generateFormForClassName(Person.class.getName(), getFilters());
checkFormGeneratedWithFilters(form);
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormBuildingServiceImplTest method testGenerateFormForClass.
@Test
public void testGenerateFormForClass() {
FormDefinition form = formBuildingService.generateFormForClass(Person.class);
testGeneratedForm(form, Person.class.getName());
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormBuildingServiceImplTest method testGenerateFormForModel.
@Test
public void testGenerateFormForModel() {
FormDefinition form = formBuildingService.generateFormForModel(model);
testGeneratedForm(form, Person.class.getName());
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class DynamicFormModelGenerator method addNestedForm.
private void addNestedForm(String className, StaticModelFormRenderingContext context, Collection<FormElementFilter> nestedFormFilters) {
if (!context.getAvailableForms().containsKey(className)) {
FormDefinition nested = formBuildingService.generateFormForClassName(className, nestedFormFilters.stream().toArray(FormElementFilter[]::new));
context.getAvailableForms().put(className, nested);
initNestedFormSettings(nested, null, context, nestedFormFilters);
}
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class DynamicFormModelGeneratorTest method testGenerateContextForModelWithFilters.
@Test
public void testGenerateContextForModelWithFilters() {
FormElementFilter nameFilter = new FormElementFilter("name", o -> true);
FormElementFilter lastNameFilter = new FormElementFilter("lastName", o -> false);
FormElementFilter addressStreetFilter = new FormElementFilter("address.street", o -> true);
FormElementFilter addressNumFilter = new FormElementFilter("address.number", o -> false);
StaticModelFormRenderingContext context = dynamicFormModelGenerator.getContextForModel(model, nameFilter, lastNameFilter, addressStreetFilter, addressNumFilter);
assertEquals(3, context.getAvailableForms().size());
FormDefinition rootForm = context.getRootForm();
assertNotNull(rootForm);
assertEquals(rootForm.getFields().size(), rootForm.getLayoutTemplate().getRows().size());
assertNotNull(rootForm.getFieldByBinding("name"));
assertNull(rootForm.getFieldByBinding("lastName"));
FormDefinition addressForm = context.getAvailableForms().get(Address.class.getName());
assertNotNull(addressForm);
assertEquals(addressForm.getFields().size(), addressForm.getLayoutTemplate().getRows().size());
assertNotNull(addressForm.getFieldByBinding("street"));
assertNull(addressForm.getFieldByBinding("number"));
}
Aggregations