use of org.linkki.core.vaadin.component.base.LinkkiText in project linkki by linkki-framework.
the class OkCancelDialogTest method displayingMessage.
private Matcher<OkCancelDialog> displayingMessage(String text) {
return new TypeSafeMatcher<OkCancelDialog>() {
@Override
public void describeTo(Description description) {
description.appendText("an OkCancelDialog displaying a message with the text '");
description.appendText(text);
description.appendText("'");
}
@Override
protected boolean matchesSafely(OkCancelDialog dialog) {
@NonNull Div layout = dialog.getMessageArea();
LinkkiText message = (LinkkiText) layout.getComponentAt(0);
return text.contentEquals(message.getText());
}
};
}
use of org.linkki.core.vaadin.component.base.LinkkiText in project linkki by linkki-framework.
the class BindLabelValueAspectDefinitionTest method testCreateComponentValueSetter_UsesCustomConverter.
@Test
void testCreateComponentValueSetter_UsesCustomConverter() {
LinkkiText label = new LinkkiText();
Consumer<Object> valueSetter = new BindLabelValueAspectDefinition().createComponentValueSetter(new NoLabelComponentWrapper(label));
LinkkiConverterRegistry converterRegistry = LinkkiConverterRegistry.DEFAULT.with(new Converter<String, FooBar>() {
private static final long serialVersionUID = 1L;
@Override
public Result<FooBar> convertToModel(String value, ValueContext context) {
return Result.ok(FooBar.valueOf(value));
}
@Override
public String convertToPresentation(FooBar value, ValueContext context) {
return value == FooBar.FOO ? "Foo" : "Bar";
}
});
VaadinSession vaadinSession = mock(VaadinSession.class);
when(vaadinSession.getAttribute(LinkkiConverterRegistry.class)).thenReturn(converterRegistry);
VaadinSession.setCurrent(vaadinSession);
valueSetter.accept(FooBar.FOO);
assertThat(label.getText(), is("Foo"));
}
use of org.linkki.core.vaadin.component.base.LinkkiText in project linkki by linkki-framework.
the class BindLabelValueAspectDefinitionTest method testCreateComponentValueSetter_UsesStandardConverter.
@Test
void testCreateComponentValueSetter_UsesStandardConverter() {
UI.getCurrent().setLocale(Locale.GERMAN);
LinkkiText label = new LinkkiText();
Consumer<Object> valueSetter = new BindLabelValueAspectDefinition().createComponentValueSetter(new NoLabelComponentWrapper(label));
valueSetter.accept(Integer.valueOf(123456));
assertThat(label.getText(), is("123.456"));
}
use of org.linkki.core.vaadin.component.base.LinkkiText in project linkki by linkki-framework.
the class BindLabelValueAspectDefinitionTest method testCreateComponentValueSetter_SetsString.
@Test
void testCreateComponentValueSetter_SetsString() {
LinkkiText label = new LinkkiText();
Consumer<Object> valueSetter = new BindLabelValueAspectDefinition().createComponentValueSetter(new NoLabelComponentWrapper(label));
valueSetter.accept("foo");
assertThat(label.getText(), is("foo"));
assertThat(label.getElement().getProperty("innerHTML"), is(nullValue()));
}
use of org.linkki.core.vaadin.component.base.LinkkiText in project linkki by linkki-framework.
the class BindLabelValueAspectDefinitionTest method testCreateComponentValueSetter_UsesStandardConverter_DependingOnUiLocale.
@Test
void testCreateComponentValueSetter_UsesStandardConverter_DependingOnUiLocale() {
UI.getCurrent().setLocale(Locale.US);
LinkkiText label = new LinkkiText();
Consumer<Object> valueSetter = new BindLabelValueAspectDefinition().createComponentValueSetter(new NoLabelComponentWrapper(label));
valueSetter.accept(Integer.valueOf(123456));
assertThat(label.getText(), is("123,456"));
}
Aggregations