use of org.linkki.core.vaadin.component.base.LabelComponentFormItem in project linkki by linkki-framework.
the class DialogBindingManagerTest method testBindingsInCreatedContextsDisplayMessagesFromDialog.
@Test
public void testBindingsInCreatedContextsDisplayMessagesFromDialog() {
OkCancelDialog dialog = OkCancelDialog.builder("").build();
// Use the NOP validation service in the binding manager
DialogBindingManager manager = new DialogBindingManager(dialog, ValidationService.NOP_VALIDATION_SERVICE);
BindingContext ctx = manager.getContext("foo");
// Change the dialog's validation service to make sure dialog's validate method is used and
// not the validation service the manager was created with (so that the dialog could filter
// the messages)
MessageList messages = new MessageList(Message.newError("code", "text"));
dialog.setValidationService(ValidationService.of(messages));
PropertyDispatcher propertyDispatcher = mock(PropertyDispatcher.class);
Object pmo = mock(Object.class);
when(propertyDispatcher.getBoundObject()).thenReturn(pmo);
when(propertyDispatcher.getMessages(any())).thenReturn(new MessageList());
FormItemComponentWrapper componentWrapper = new FormItemComponentWrapper(new LabelComponentFormItem(new Button(), new Label()));
ElementBinding binding = spy(new ElementBinding(componentWrapper, propertyDispatcher, Handler.NOP_HANDLER, new ArrayList<>()));
ctx.add(binding, componentWrapper);
ctx.modelChanged();
verify(binding).displayMessages(messages);
}
use of org.linkki.core.vaadin.component.base.LabelComponentFormItem in project linkki by linkki-framework.
the class FormItemComponentWrapperTest method testSetTooltip.
@Test
void testSetTooltip() {
TextField formTextField = new TextField();
LabelComponentFormItem formItem = new LabelComponentFormItem(formTextField, new Label("SomeText"));
FormItemComponentWrapper wrapper = new FormItemComponentWrapper(formItem);
wrapper.setTooltip("testTip");
assertThat(getTitleAttribute(wrapper), is("testTip"));
wrapper.setTooltip("<script>");
assertThat(getTitleAttribute(wrapper), is(""));
wrapper.setTooltip("<div> some text </div>");
assertThat(getTitleAttribute(wrapper), is(" some text "));
wrapper.setTooltip("<div> some text <br> with page break</div> ");
assertThat(getTitleAttribute(wrapper), is(" some text \n with page break "));
}
use of org.linkki.core.vaadin.component.base.LabelComponentFormItem in project linkki by linkki-framework.
the class UINestedComponentIntegrationTest method testApsectOnNestedComponent.
@Test
public void testApsectOnNestedComponent() {
NestedComponentPmo pmo = new NestedComponentPmo();
BindingContext bindingContext = new BindingContext();
BaseSection component = (BaseSection) VaadinUiCreator.createComponent(pmo, bindingContext);
LabelComponentFormItem nestedComponent = (LabelComponentFormItem) getChild(component.getContentWrapper(), 1);
assertThat(nestedComponent.isVisible(), is(true));
pmo.setVisible(false);
bindingContext.modelChanged();
assertThat(nestedComponent.isVisible(), is(false));
}
use of org.linkki.core.vaadin.component.base.LabelComponentFormItem in project linkki by linkki-framework.
the class FormItemComponentWrapperTest method setUp.
@BeforeEach
void setUp() {
propertyDispatcherValue = mock(PropertyDispatcher.class);
when(propertyDispatcherValue.getProperty()).thenReturn("value");
propertyDispatcherEnumValue = mock(PropertyDispatcher.class);
when(propertyDispatcherEnumValue.getProperty()).thenReturn("enumValue");
doReturn(TestEnum.class).when(propertyDispatcherEnumValue).getValueClass();
messageList = new MessageList();
when(propertyDispatcherValue.getMessages(any(MessageList.class))).thenReturn(messageList);
when(propertyDispatcherEnumValue.getMessages(any(MessageList.class))).thenReturn(messageList);
selectBinding = new ElementBinding(new FormItemComponentWrapper(new LabelComponentFormItem(selectField, label)), propertyDispatcherEnumValue, Handler.NOP_HANDLER, new ArrayList<>());
}
use of org.linkki.core.vaadin.component.base.LabelComponentFormItem in project linkki by linkki-framework.
the class FormItemComponentWrapperTest method testUpdateFromPmo_updateAspect.
@Test
void testUpdateFromPmo_updateAspect() {
Handler componentUpdater = mock(Handler.class);
LinkkiAspectDefinition aspectDefinition = mock(LinkkiAspectDefinition.class);
when(aspectDefinition.supports(any())).thenReturn(true);
when(aspectDefinition.createUiUpdater(any(), any())).thenReturn(componentUpdater);
ElementBinding fieldBinding = new ElementBinding(new FormItemComponentWrapper(new LabelComponentFormItem(field, label)), propertyDispatcherValue, Handler.NOP_HANDLER, Arrays.asList(aspectDefinition));
fieldBinding.updateFromPmo();
verify(componentUpdater).apply();
}
Aggregations