use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorHelperTest method testGetFormField.
@Test
public void testGetFormField() {
when(formDefinition.getFieldById(anyString())).thenReturn(nameField);
content.setDefinition(formDefinition);
FieldDefinition formField = formEditorHelper.getFormField(nameField.getId());
assertEquals(formField, nameField);
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorHelperTest method testUnboundField.
void testUnboundField(Pair<EditorFieldLayoutComponent, FieldDefinition> pair) {
FieldDefinition expectedField = pair.getK2();
Assertions.assertThat(expectedField).isNotNull();
FieldDefinition resultField = formEditorHelper.getFormField(expectedField.getId());
formEditorHelper.saveFormField(expectedField, resultField);
Assertions.assertThat(resultField).isNotNull().isEqualTo(expectedField);
Assertions.assertThat(resultField.getFieldType().getTypeName()).isEqualTo(resultField.getLabel());
Assertions.assertThat(content.getDefinition().getFieldById(resultField.getId())).isNotNull();
Assertions.assertThat(formEditorHelper.getUnbindedFields().get(resultField.getId())).isNull();
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorHelperTest method testSwitchToNullBinding.
@Test
public void testSwitchToNullBinding() {
FieldDefinition result = formEditorHelper.switchToField(nameField, null);
Assertions.assertThat(result.getId()).isNotEqualTo(nameField.getId());
Assertions.assertThat(result.getName()).isNotEqualTo(nameField.getName());
Assertions.assertThat(result.getBinding()).isNullOrEmpty();
Assertions.assertThat(result.getBinding()).isNotEqualTo(nameField.getBinding());
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 FormEditorPresenterTest method testRemoveFields.
protected void testRemoveFields(boolean checkAvailable) {
int formFields = editorHelper.getFormDefinition().getFields().size();
assertTrue("Form should have fields.", formFields > 0);
assertEquals("Form should contain '" + employeeFields.size() + "' fields.", formFields, employeeFields.size());
int availableFields = editorHelper.getAvailableFields().size();
assertTrue("There should not exist available fields.", availableFields == 0);
List<FieldDefinition> formFieldsList = new ArrayList<>(editorHelper.getFormDefinition().getFields());
for (FieldDefinition field : formFieldsList) {
presenter.onRemoveComponent(createComponentRemovedEvent(editorHelper.getFormDefinition(), field));
availableFields++;
formFields--;
checkExpectedFields(availableFields, formFields, checkAvailable);
}
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorPresenterTest method testRemoveEventWhenMovingFieldOnLayout.
@Test
public void testRemoveEventWhenMovingFieldOnLayout() {
loadContent();
loadAvailableFields();
addAllFields();
FormEditorPresenter presenterSpy = spy(presenter);
FieldDefinition field = editorHelper.getFormDefinition().getFields().get(0);
ComponentRemovedEvent event = new ComponentRemovedEvent(createLayoutComponent(presenter.getFormDefinition(), field), true);
presenterSpy.onRemoveComponent(event);
assertNotNull(editorHelper.getFormDefinition().getFieldById(field.getId()));
verify(presenterSpy, never()).onSyncPalette(anyString());
verify(editorHelper, never()).removeField(anyString(), anyBoolean());
}
Aggregations