use of com.vaadin.client.flow.StateNode in project flow by vaadin.
the class MapPropertyTest method syncToServer_nodeIsInactive_propertyIsNotSent_eventIsFiredAndFlushed.
@Test
public void syncToServer_nodeIsInactive_propertyIsNotSent_eventIsFiredAndFlushed() {
TestTree tree = new TestTree();
tree.isActive = false;
StateNode node = new StateNode(7, tree);
MapProperty property = node.getMap(NodeFeatures.ELEMENT_PROPERTIES).getProperty("foo");
AtomicReference<MapPropertyChangeEvent> event = new AtomicReference<MapPropertyChangeEvent>();
property.addChangeListener(event::set);
AtomicBoolean flushListener = new AtomicBoolean();
Reactive.addFlushListener(() -> flushListener.set(true));
property.syncToServer("bar");
Assert.assertNull(tree.sentProperty);
Assert.assertNotNull(event.get());
MapPropertyChangeEvent propertyChangeEvent = event.get();
Assert.assertNull(propertyChangeEvent.getNewValue());
Assert.assertTrue(flushListener.get());
}
use of com.vaadin.client.flow.StateNode in project flow by vaadin.
the class MapPropertyTest method setValue_updateFromServerIsAppliedViaSyncToServer_syncToServerUpdatesValue.
@Test
public void setValue_updateFromServerIsAppliedViaSyncToServer_syncToServerUpdatesValue() {
TestTree tree = new TestTree();
StateNode node = new StateNode(7, tree);
MapProperty property = node.getMap(NodeFeatures.ELEMENT_PROPERTIES).getProperty("foo");
property.setValue("bar");
property.syncToServer("bar");
property.syncToServer("baz");
Assert.assertEquals("baz", property.getValue());
}
use of com.vaadin.client.flow.StateNode in project flow by vaadin.
the class MapPropertyTest method syncToServer_nodeIsActive_propertyIsSent.
@Test
public void syncToServer_nodeIsActive_propertyIsSent() {
TestTree tree = new TestTree();
StateNode node = new StateNode(7, tree);
MapProperty property = node.getMap(NodeFeatures.ELEMENT_PROPERTIES).getProperty("foo");
property.syncToServer("bar");
Assert.assertEquals(property, tree.sentProperty);
}
use of com.vaadin.client.flow.StateNode in project flow by vaadin.
the class MapPropertyTest method removeValue_updateFromServerIsNoCompleted_syncToServerDoesntUpdateValue.
@Test
public void removeValue_updateFromServerIsNoCompleted_syncToServerDoesntUpdateValue() {
TestTree tree = new TestTree();
StateNode node = new StateNode(7, tree);
MapProperty property = node.getMap(NodeFeatures.ELEMENT_PROPERTIES).getProperty("foo");
property.setValue("bar");
property.removeValue();
property.syncToServer("baz");
Assert.assertNull(property.getValue());
}
use of com.vaadin.client.flow.StateNode in project flow by vaadin.
the class MapPropertyTest method syncToServer_propertyHasNoValue_propertyIsSync.
@Test
public void syncToServer_propertyHasNoValue_propertyIsSync() {
TestTree tree = new TestTree();
StateNode node = new StateNode(11, tree);
MapProperty property = node.getMap(NodeFeatures.ELEMENT_PROPERTIES).getProperty("foo");
property.syncToServer(null);
Assert.assertEquals(property, tree.sentProperty);
}
Aggregations