use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorHelperTest method testSwitchToField.
protected void testSwitchToField(FieldDefinition originalField, FieldDefinition expectedField) {
FieldDefinition result = formEditorHelper.switchToField(originalField, expectedField.getBinding());
Assertions.assertThat(result).isNotNull().isEqualToComparingOnlyGivenFields(expectedField, "name", "binding", "standaloneClassName");
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorHelperTest method testSwitchToFieldType.
@Test
public void testSwitchToFieldType() {
content.getDefinition().getFields().addAll(employeeFields);
formEditorHelper.getAvailableFields().clear();
FieldDefinition fieldDefinition = formEditorHelper.switchToFieldType(nameField, TextAreaFieldDefinition.FIELD_TYPE.getTypeName());
assertEquals(TextAreaFieldDefinition.class, fieldDefinition.getClass());
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorHelperTest method testSwitchToDynamicBinding.
@Test
public void testSwitchToDynamicBinding() {
FieldDefinition result = formEditorHelper.switchToField(nameField, DYNAMIC_BINDING);
Assertions.assertThat(result.getId()).isNotEqualTo(nameField.getId());
Assertions.assertThat(result.getName()).isEqualTo(DYNAMIC_BINDING);
Assertions.assertThat(result.getBinding()).isEqualTo(DYNAMIC_BINDING);
Assertions.assertThat(result.getStandaloneClassName()).isEqualTo(nameField.getStandaloneClassName());
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorHelperTest method testGetFormFieldAvailable.
@Test
public void testGetFormFieldAvailable() {
FieldDefinition resultField = formEditorHelper.getAvailableFields().values().stream().filter(fieldDefinition -> fieldDefinition.getBinding().equals(nameField.getBinding())).findFirst().get();
formEditorHelper.saveFormField(nameField, resultField);
Assertions.assertThat(resultField).isNotNull().isEqualToComparingOnlyGivenFields(nameField, "name", "binding", "standaloneClassName");
Assertions.assertThat(content.getDefinition().getFieldById(resultField.getId())).isNotNull();
Assertions.assertThat(content.getDefinition().getFields()).contains(resultField).doesNotContain(nameField);
Assertions.assertThat(formEditorHelper.getAvailableFields().size()).isEqualTo(employeeFields.size() - 1);
}
use of org.kie.workbench.common.forms.model.FieldDefinition 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);
}
Aggregations