use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormEditorPresenterTest method testFieldProperties.
protected void testFieldProperties(String fieldId, boolean bound) {
FormDefinition form = editorHelper.getFormDefinition();
addField(editorHelper.getAvailableFields().values().stream().filter(fieldDefinition -> fieldDefinition.getBinding().equals(fieldId)).findFirst().get());
checkExpectedFields(editorHelper.getAvailableFields().size(), 1, bound);
FieldDefinition field = editorHelper.getFormDefinition().getFields().get(0);
checkFieldType(field, TextBoxFieldDefinition.class);
Collection<String> compatibleTypes = editorHelper.getCompatibleFieldTypes(field);
assertNotNull("No compatibles types found!", compatibleTypes);
assertTrue("There should exist more than one compatible types for TextBoxFieldDefinition!", compatibleTypes.size() > 1);
assertTrue("Missing TextAreaFieldDefinition as a compatible type for TextBoxFieldDefinition", compatibleTypes.contains(TextAreaFieldDefinition.FIELD_TYPE.getTypeName()));
field = editorHelper.switchToFieldType(field, TextAreaFieldDefinition.FIELD_TYPE.getTypeName());
checkFieldType(field, TextAreaFieldDefinition.class);
List<String> compatibleFields = editorHelper.getCompatibleModelFields(field);
assertNotNull("No compatibles fields found!", compatibleFields);
assertEquals("There should exist 1 compatible fields for " + field.getName() + "!", 1, compatibleFields.size());
String expectedBindingExpression = "lastName";
field = editorHelper.switchToField(field, expectedBindingExpression);
assertEquals("Wrong binding expression after switch field!", field.getBinding(), expectedBindingExpression);
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FieldPropertiesRendererTest method loadContent.
protected void loadContent() {
fieldManager = spy(new TestFieldManager());
renderer = spy(new FieldPropertiesRenderer(view, dynamicFormModelGenerator, staticDataBindingEditor, dynamicDataBindingEditor, fieldManager));
renderer.init();
when(helper.getCurrentField()).thenReturn(lastNameField);
when(helper.getCurrentRenderingContext()).thenReturn(context);
FormDefinition form = new FormDefinition(null);
when(context.getRootForm()).thenReturn(form);
when(dynamicFormModelGenerator.getContextForModel(any())).thenReturn(context);
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormGenerationIntegrationTest method inputTaskFormIsCorrectlyGenerated.
@Test
public void inputTaskFormIsCorrectlyGenerated() {
when(module.getRootPath()).thenReturn(rootPathWithNestedForms);
final FormGenerationResult formGenerationResult = generateForm("FormGenerationTest_TaskOnlyWithInputs-taskform.frm", taskFormModels.get(2));
final List<String> expectedInputTaskFormFields = Arrays.asList("_boolean", CHECKBOX_FIELDTYPE, "_dataObject", SUBFORM_FIELDTYPE, "_document", DOCUMENT_FIELDTYPE, "_float", DECIMALBOX_FIELDTYPE, "_integer", INTEGERBOX_FIELDTYPE, "_object", TEXTAREA_FIELDTYPE, "_string", TEXTBOX_FIELDTYPE);
final FormDefinition rootForm = formGenerationResult.getRootForm();
testFormDefinition(rootForm, expectedInputTaskFormFields);
testNestedFormsHaveCorrectId(rootForm, "_dataObject", DATAOBJECT_FORM_ID);
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormGenerationIntegrationTest method twinTaskFormIsCorrectlyGenerated.
@Test
public void twinTaskFormIsCorrectlyGenerated() {
when(module.getRootPath()).thenReturn(rootPathWithNestedForms);
final FormGenerationResult formGenerationResult = generateForm("FormGenerationTest_TwinTasks-taskform.frm", taskFormModels.get(4));
final List<String> expectedProcessFormFields = Arrays.asList("_boolean", CHECKBOX_FIELDTYPE, "_dataObject1", SUBFORM_FIELDTYPE, "_dataObject2", SUBFORM_FIELDTYPE, "_string", TEXTBOX_FIELDTYPE, "_boolean_", CHECKBOX_FIELDTYPE, "_string_", TEXTBOX_FIELDTYPE, "dataObject_", SUBFORM_FIELDTYPE, "integer_", INTEGERBOX_FIELDTYPE);
final FormDefinition rootForm = formGenerationResult.getRootForm();
testFormDefinition(rootForm, expectedProcessFormFields);
testNestedFormsHaveCorrectId(rootForm, "_dataObject1", DATAOBJECT_FORM_ID);
testNestedFormsHaveCorrectId(rootForm, "_dataObject2", DATAOBJECT_FORM_ID);
testNestedFormsHaveCorrectId(rootForm, "dataObject_", DATAOBJECT_FORM_ID);
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormGenerationIntegrationTest method testNestedFormsGeneration.
@Test
public void testNestedFormsGeneration() {
when(module.getRootPath()).thenReturn(rootPathWithoutNestedForms);
ModelDriver modelDriver = new JavaRoasterModelDriver(ioService, Paths.convert(rootPathWithoutNestedForms), moduleClassLoader, filterHolder);
try {
ModelDriverResult result = modelDriver.loadModel();
dataModel = result.getDataModel();
} catch (ModelDriverException e) {
throw new ServiceException("It was not possible to load model for URI: " + rootPathWithoutNestedForms.toURI(), e);
}
when(dataModelerService.loadModel(module)).thenReturn(dataModel);
when(commentedOptionFactory.makeCommentedOption(any())).thenReturn(commentedOption);
final FormGenerationResult formGenerationResult = generateForm("FormGenerationTest_TwinTasks-taskform.frm", taskFormModels.get(4));
final List<String> expectedDataObjectFormFields = Arrays.asList("nestedObjectForSubform", SUBFORM_FIELDTYPE, "nestedObjectListForMultipleSubform", MULTIPLESUBFORM_FIELDTYPE, "bigDecimalDecimalBox", DECIMALBOX_FIELDTYPE, "bigIntegerIntegerBox", INTEGERBOX_FIELDTYPE, "booleanCheckBox", CHECKBOX_FIELDTYPE, "byteIntegerBox", INTEGERBOX_FIELDTYPE, "charTextBox", TEXTBOX_FIELDTYPE, "dateDatePicker", DATEPICKER_FIELDTYPE, "doubleDecimalBox", DECIMALBOX_FIELDTYPE, "floatDecimalBox", DECIMALBOX_FIELDTYPE, "longIntegerBox", INTEGERBOX_FIELDTYPE, "stringListBox", TEXTBOX_FIELDTYPE, "intIntegerBox", INTEGERBOX_FIELDTYPE, "shortIntegerBox", INTEGERBOX_FIELDTYPE, "bigDecimalRadioGroup", DECIMALBOX_FIELDTYPE, "bigIntegerRadioGroup", INTEGERBOX_FIELDTYPE, "byteRadioGroup", INTEGERBOX_FIELDTYPE, "charRadioGroup", TEXTBOX_FIELDTYPE, "doubleSlider", DECIMALBOX_FIELDTYPE, "doubleRadioGroup", DECIMALBOX_FIELDTYPE, "floatRadioGroup", DECIMALBOX_FIELDTYPE, "intRadioGroup", INTEGERBOX_FIELDTYPE, "intSlider", INTEGERBOX_FIELDTYPE, "longRadioGroup", INTEGERBOX_FIELDTYPE, "stringPicture", TEXTBOX_FIELDTYPE, "stringRadioGroup", TEXTBOX_FIELDTYPE, "stringTextArea", TEXTBOX_FIELDTYPE, "stringTextBox", TEXTBOX_FIELDTYPE, "shortRadioGroup", INTEGERBOX_FIELDTYPE);
final List<String> expectedNestedDataObjectFormFields = Arrays.asList("stringListBox", TEXBOX_FIELDTYPE, "doubleDecimalBox", DECIMALBOX_FIELDTYPE, "booleanCheckBox", CHECKBOX_FIELDTYPE, "dateDatePicker", DATEPICKER_FIELDTYPE, "charRadioGroup", TEXTBOX_FIELDTYPE, "doubleSlider", DECIMALBOX_FIELDTYPE, "intIntegerBox", INTEGERBOX_FIELDTYPE, "stringPicture", TEXBOX_FIELDTYPE, "stringTextArea", TEXTBOX_FIELDTYPE, "stringTextBox", TEXTBOX_FIELDTYPE);
final FormDefinition rootForm = formGenerationResult.getRootForm();
final List<FormDefinition> nestedForms = formGenerationResult.getNestedForms();
final FormDefinition dataObjectForm = nestedForms.get(0);
final FormDefinition nestedDataObjectForm = nestedForms.get(1);
final String dataObjectFormID = dataObjectForm.getId();
testNestedFormsHaveCorrectId(rootForm, "_dataObject1", dataObjectFormID);
testNestedFormsHaveCorrectId(rootForm, "_dataObject2", dataObjectFormID);
testNestedFormsHaveCorrectId(rootForm, "dataObject_", dataObjectFormID);
final String nestedDataObjectFormID = nestedDataObjectForm.getId();
testFormDefinition(dataObjectForm, expectedDataObjectFormFields);
testNestedFormsHaveCorrectId(dataObjectForm, "nestedObjectForSubform", nestedDataObjectFormID);
testFormDefinition(nestedDataObjectForm, expectedNestedDataObjectFormFields);
}
Aggregations