use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorPresenterTest method testOnRemoveComponent.
public void testOnRemoveComponent(boolean noContext) {
loadContent();
loadAvailableFields();
addAllFields();
VerificationMode count = times(1);
if (noContext) {
when(editorHelper.getContent()).thenReturn(null);
count = never();
}
FormEditorPresenter presenterSpy = spy(presenter);
String formId = presenterSpy.getFormDefinition().getId();
FieldDefinition field = editorHelper.getFormDefinition().getFields().get(0);
ComponentRemovedEvent event = new ComponentRemovedEvent(createLayoutComponent(presenter.getFormDefinition(), field), false);
presenterSpy.onRemoveComponent(event);
verify(presenterSpy, count).onSyncPalette(formId);
verify(editorHelper, count).removeField(anyString(), anyBoolean());
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FieldPropertiesRendererTest method testResetFieldCopy.
@Test
public void testResetFieldCopy() {
FieldDefinition originalField = lastNameField;
loadContent();
FieldDefinition fieldCopy = renderer.resetFieldCopy(originalField);
assertEquals(originalField.getId(), fieldCopy.getId());
assertEquals(originalField.getName(), fieldCopy.getName());
assertEquals(originalField.getLabel(), fieldCopy.getLabel());
assertEquals(originalField.getStandaloneClassName(), fieldCopy.getStandaloneClassName());
assertEquals(originalField.getRequired(), fieldCopy.getRequired());
assertEquals(originalField.getReadOnly(), fieldCopy.getReadOnly());
assertEquals(originalField.getValidateOnChange(), fieldCopy.getValidateOnChange());
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class EditorFieldLayoutComponentTest method setupFormEditorHelper.
protected FieldDefinition setupFormEditorHelper() {
FieldDefinition newField = mock(FieldDefinition.class);
when(newField.getId()).thenReturn(EditorFieldLayoutComponent.FIELD_ID);
doReturn(newField).when(fieldManager).getFieldFromProvider(anyString(), any(TypeInfo.class));
FieldDefinition fieldCopy = propertiesRendererHelper.onFieldTypeChange(fieldDefinition, RadioGroupFieldType.NAME);
editorFieldLayoutComponent.setSettingValue(EditorFieldLayoutComponent.FORM_ID, EditorFieldLayoutComponent.FORM_ID);
editorFieldLayoutComponent.setSettingValue(EditorFieldLayoutComponent.FIELD_ID, EditorFieldLayoutComponent.FIELD_ID);
editorFieldLayoutComponent.generateContent(ctx);
return fieldCopy;
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class EditorFieldLayoutComponentTest method testOnPressOk.
protected void testOnPressOk(boolean bound, boolean withConfigContext) {
FieldDefinition fieldCopy = setupFormEditorHelper();
ModalConfigurationContext ctx = mock(ModalConfigurationContext.class);
if (bound) {
when(fieldCopy.getBinding()).thenReturn(BINDING_FIRSTNAME);
}
if (withConfigContext) {
when(ctx.getComponentProperties()).thenReturn(mock(Map.class));
editorFieldLayoutComponent.getConfigurationModal(ctx);
}
editorFieldLayoutComponent.onPressOk(fieldCopy);
assertSame(fieldCopy, editorFieldLayoutComponent.getField());
verify(syncPaletteEvent).fire(any());
verify(formEditorHelper, bound ? times(1) : times(0)).removeAvailableField(any());
verify(ctx, withConfigContext ? times(1) : times(0)).configurationFinished();
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class EditorFieldLayoutComponentTest method testOnFieldTypeChange.
@Test
public void testOnFieldTypeChange() {
FieldDefinition result = propertiesRendererHelper.onFieldTypeChange(fieldDefinition, RadioGroupFieldType.NAME);
verify(fieldManager).getFieldFromProvider(RadioGroupFieldType.NAME, fieldDefinition.getFieldTypeInfo());
assertEquals(fieldDefinition.getId(), result.getId());
assertEquals(fieldDefinition.getName(), result.getName());
assertEquals(fieldDefinition.getBinding(), result.getBinding());
assertNotEquals(fieldDefinition.getClass(), result.getClass());
}
Aggregations