use of elemental.json.impl.JreJsonObject in project linkki by linkki-framework.
the class BindComboBoxItemStyleAspectDefinitionTest method testCreateComponentValueSetter.
@Test
void testCreateComponentValueSetter() {
MockVaadin.setup();
String styleName = "bar";
BindComboBoxItemStyleAspectDefinition aspectDefinition = new BindComboBoxItemStyleAspectDefinition(styleName);
ComboBox<Object> comboBox = spy(ComponentFactory.newComboBox());
@SuppressWarnings("unchecked") ArgumentCaptor<LitRenderer<Object>> argumentCaptor = ArgumentCaptor.forClass(LitRenderer.class);
ComponentWrapper componentWrapper = new NoLabelComponentWrapper(comboBox);
Consumer<Function<Object, String>> componentValueSetter = aspectDefinition.createComponentValueSetter(componentWrapper);
componentValueSetter.accept(o -> EXPECTED_STYLE);
verify(comboBox).setRenderer(argumentCaptor.capture());
LitRenderer<Object> renderer = argumentCaptor.getValue();
Rendering<Object> render = renderer.render(new Element("div"), new KeyMapper<>());
JreJsonObject jsonObject = new JreJsonObject(new JreJsonFactory());
render.getDataGenerator().get().generateData(EXPECTED_LABEL, jsonObject);
assertThat(jsonObject.get("lr_0_" + BindComboBoxItemStyleAspectDefinition.LABEL).asString(), is(EXPECTED_LABEL));
assertThat(jsonObject.get("lr_0_" + BindComboBoxItemStyleAspectDefinition.STYLE).asString(), is(EXPECTED_STYLE));
MockVaadin.tearDown();
}
Aggregations