use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorHelperTest method testRemoveUnboundField.
protected void testRemoveUnboundField(boolean addToAvailables) {
content.getDefinition().getFields().addAll(employeeFields);
formEditorHelper.getAvailableFields().clear();
TextBoxFieldDefinition textBoxFieldDefinition = new TextBoxFieldDefinition();
formDefinition.getFields().add(textBoxFieldDefinition);
formEditorHelper.removeField(textBoxFieldDefinition.getId(), true);
Assertions.assertThat(formEditorHelper.getAvailableFields()).isNotNull().isEmpty();
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition in project kie-wb-common by kiegroup.
the class EditorFieldLayoutComponentTest method init.
@Before
public void init() {
fieldManager = spy(new TestFieldManager());
when(editorFieldLayoutComponents.get()).thenAnswer(invocationOnMock -> {
final EditorFieldLayoutComponent mocked = mock(EditorFieldLayoutComponent.class);
return mocked;
});
formEditorHelper = spy(new FormEditorHelper(new TestFieldManager(), editorFieldLayoutComponents, mock(SyncBeanManager.class)));
fieldDefinition = new TextBoxFieldDefinition();
fieldDefinition.setId(EditorFieldLayoutComponent.FIELD_ID);
fieldDefinition.setName(EditorFieldLayoutComponent.FIELD_ID);
fieldDefinition.setBinding(EditorFieldLayoutComponent.FIELD_ID);
when(formDefinition.getId()).thenReturn(EditorFieldLayoutComponent.FORM_ID);
when(formDefinition.getFieldById(anyString())).thenReturn(fieldDefinition);
when(formDefinition.getModel()).thenReturn(formModel);
when(context.getRootForm()).thenReturn(formDefinition);
content = new FormModelerContent();
content.setDefinition(formDefinition);
content.setOverview(mock(Overview.class));
formEditorHelper.initHelper(content);
when(formEditorHelper.getRenderingContext()).thenReturn(context);
when(formEditorHelper.getFormField(any())).thenReturn(fieldDefinition);
layoutComponent.addProperty(EditorFieldLayoutComponent.FIELD_ID, EditorFieldLayoutComponent.FIELD_ID);
layoutComponent.addProperty(EditorFieldLayoutComponent.FORM_ID, EditorFieldLayoutComponent.FORM_ID);
ctx = new RenderingContext(layoutComponent, widget);
when(fieldRendererManager.getRendererForField(any())).thenReturn(fieldRenderer);
when(fieldRenderer.renderWidget()).thenReturn(widget);
when(propertiesRenderer.getView()).thenReturn(fieldPropertiesRendererView);
FormEditorContext.setActiveEditorHelper(formEditorHelper);
editorFieldLayoutComponent = spy(new EditorFieldLayoutComponent(fieldRendererManager, translationService, propertiesRenderer, fieldManager, syncPaletteEvent));
editorFieldLayoutComponent.initPropertiesConfig();
propertiesRendererHelper = spy(editorFieldLayoutComponent.getPropertiesRendererHelper());
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition in project kie-wb-common by kiegroup.
the class FormGeneratorDriverTest method init.
@Before
public void init() {
when(beanManager.lookupBeans(Mockito.<String>any())).thenAnswer(invocationOnMock -> {
SyncBeanDef beanDef = mock(SyncBeanDef.class);
when(beanDef.getBeanClass()).thenReturn(FieldLayoutComponent.class);
return Collections.singletonList(beanDef);
});
when(instance.select(any(Class.class))).thenAnswer(invocationOnMock -> {
ManagedInstance<FieldLayoutComponent> nestedInstance = mock(ManagedInstance.class);
FieldLayoutComponent component = mock(FieldLayoutComponent.class);
when(component.getContentPart(any(), any())).thenReturn(Optional.of(mock(IsWidget.class)));
when(nestedInstance.get()).thenReturn(component);
return nestedInstance;
});
when(document.createElement(Mockito.<String>any())).thenAnswer(invocationOnMock -> mock(HTMLElement.class));
driver = new FormGeneratorDriver(beanManager, instance, wrapperWidgetUtil, document) {
@Override
FieldDefinition getFieldForLayoutComponent(LayoutComponent layoutComponent) {
return new TextBoxFieldDefinition();
}
@Override
public FieldLayoutComponent getFieldLayoutComponentForField(FieldDefinition field) {
return driver.getLayoutFields().get(0);
}
};
driver.setRenderingContext(context);
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition in project kie-wb-common by kiegroup.
the class FormLayoutTemplateGeneratorTest method init.
@Before
public void init() {
templateGenerator = getTemplateGenerator();
form = new FormDefinition();
form.setName("Test");
form.setId("Test-ID");
TextBoxFieldDefinition name = new TextBoxFieldDefinition();
name.setId("name");
name.setName("employee_name");
name.setLabel("Name");
name.setPlaceHolder("Name");
name.setBinding("name");
name.setStandaloneClassName(String.class.getName());
TextBoxFieldDefinition lastName = new TextBoxFieldDefinition();
lastName.setId("lastName");
lastName.setName("employee_lastName");
lastName.setLabel("Last Name");
lastName.setPlaceHolder("Last Name");
lastName.setBinding("lastName");
lastName.setStandaloneClassName(String.class.getName());
DatePickerFieldDefinition birthday = new DatePickerFieldDefinition();
birthday.setId("birthday");
birthday.setName("employee_birthday");
birthday.setLabel("Birthday");
birthday.setBinding("birthday");
birthday.setStandaloneClassName(Date.class.getName());
CheckBoxFieldDefinition married = new CheckBoxFieldDefinition();
married.setId("married");
married.setName("employee_married");
married.setLabel("Married");
married.setBinding("married");
married.setStandaloneClassName(Boolean.class.getName());
form.getFields().add(name);
form.getFields().add(lastName);
form.getFields().add(birthday);
form.getFields().add(married);
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition in project kie-wb-common by kiegroup.
the class FormLayoutTemplateGeneratorTest method testLayoutTemplateUpdate.
@Test
public void testLayoutTemplateUpdate() {
testTemplateGeneration();
TextBoxFieldDefinition address = new TextBoxFieldDefinition();
address.setId("address");
address.setName("employee_Address");
address.setLabel("Address");
address.setPlaceHolder("Address");
address.setBinding("Address");
address.setStandaloneClassName(String.class.getName());
TextBoxFieldDefinition age = new TextBoxFieldDefinition();
age.setId("age");
age.setName("employee_age");
age.setLabel("age");
age.setPlaceHolder("age");
age.setBinding("age");
age.setStandaloneClassName(Integer.class.getName());
List<FieldDefinition> newFields = new ArrayList<>();
newFields.add(address);
newFields.add(age);
templateGenerator.updateLayoutTemplate(form, newFields);
testGeneratedLayout();
}
Aggregations