use of elemental.json.impl.JreJsonFactory in project flow-components by vaadin.
the class CrudTest method itemAvailableInAllEvents.
@Test
public void itemAvailableInAllEvents() {
// Assert that all these events come with an item.
systemUnderTest.addCancelListener(e -> Assert.assertNotNull(e.getItem()));
systemUnderTest.addDeleteListener(e -> Assert.assertNotNull(e.getItem()));
systemUnderTest.addEditListener(e -> Assert.assertNotNull(e.getItem()));
systemUnderTest.addSaveListener(e -> Assert.assertNotNull(e.getItem()));
systemUnderTest.addNewListener(e -> Assert.assertNotNull(e.getItem()));
// A client-side Grid item.
final JsonObject selectedItem = new JreJsonFactory().parse("{\"key\": \"1\"}");
// Simulate a sequence of interactions.
Arrays.asList(new Crud.NewEvent<>(systemUnderTest, false, null), new Crud.CancelEvent<>(systemUnderTest, false, null), new Crud.EditEvent<>(systemUnderTest, false, selectedItem, null), new Crud.DeleteEvent<>(systemUnderTest, false, null), new Crud.EditEvent<>(systemUnderTest, false, selectedItem, null), new Crud.SaveEvent<>(systemUnderTest, false, null)).forEach(e -> ComponentUtil.fireEvent(systemUnderTest, e));
}
use of elemental.json.impl.JreJsonFactory 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();
}
use of elemental.json.impl.JreJsonFactory in project flow-components by vaadin.
the class ChartsSerializableTest method verifyJsonFactoryDeserialization.
@Test
public void verifyJsonFactoryDeserialization() throws Throwable {
final Chart chart = new Chart();
final JreJsonFactory jsonFactory = chart.getJsonFactory();
final Chart deserializedChart = super.serializeAndDeserialize(chart);
Assert.assertNotNull(deserializedChart);
Assert.assertNotNull(deserializedChart.getJsonFactory());
Assert.assertNotEquals(chart, deserializedChart);
Assert.assertNotEquals(jsonFactory, deserializedChart.getJsonFactory());
}
Aggregations