use of com.vaadin.client.flow.StateNode in project flow by vaadin.
the class MapPropertyTest method setValue_updateFromServerIsApplied_syncToServerUpdatesValue.
@Test
public void setValue_updateFromServerIsApplied_syncToServerUpdatesValue() {
TestTree tree = new TestTree();
StateNode node = new StateNode(7, tree);
MapProperty property = node.getMap(NodeFeatures.ELEMENT_PROPERTIES).getProperty("foo");
property.setValue("bar");
Reactive.flush();
property.syncToServer("baz");
Assert.assertEquals("baz", property.getValue());
}
use of com.vaadin.client.flow.StateNode in project flow by vaadin.
the class MapPropertyTest method setValue_updateFromServerIsNoCompleted_syncToServerDoesntUpdateValue.
@Test
public void setValue_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.syncToServer("baz");
Assert.assertEquals("bar", property.getValue());
}
use of com.vaadin.client.flow.StateNode in project flow by vaadin.
the class MapPropertyTest method removeValue_updateFromServerIsApplied_syncToServerUpdatesValue.
@Test
public void removeValue_updateFromServerIsApplied_syncToServerUpdatesValue() {
TestTree tree = new TestTree();
StateNode node = new StateNode(7, tree);
MapProperty property = node.getMap(NodeFeatures.ELEMENT_PROPERTIES).getProperty("foo");
property.setValue("bar");
property.removeValue();
Reactive.flush();
property.syncToServer("baz");
Assert.assertEquals("baz", property.getValue());
}
use of com.vaadin.client.flow.StateNode in project flow by vaadin.
the class NodeMapTest method getProperty_returnPropertyWhichAlwaysUpdatesTheValue.
@Test
public void getProperty_returnPropertyWhichAlwaysUpdatesTheValue() {
NodeMap map = new NodeMap(NodeFeatures.ELEMENT_PROPERTIES, new StateNode(0, new StateTree(null)));
MapProperty property = map.getProperty("innerHTML");
AtomicReference<MapPropertyChangeEvent> capture = new AtomicReference<>();
property.addChangeListener(capture::set);
property.setValue("foo");
Assert.assertNotNull(capture.get());
// reset
capture.set(null);
// set the same value again
property.setValue("foo");
Assert.assertNotNull(capture.get());
}
use of com.vaadin.client.flow.StateNode in project flow by vaadin.
the class InitialPropertiesHandlerTest method flushPropertyUpdates_updateIsNotInProgress_collectInitialProperties.
@Test
public void flushPropertyUpdates_updateIsNotInProgress_collectInitialProperties() {
Mockito.when(tree.isUpdateInProgress()).thenReturn(false);
StateNode node = new StateNode(1, tree);
NodeMap properties = node.getMap(NodeFeatures.ELEMENT_PROPERTIES);
MapProperty serverSidePropertyUpdatedByClient = properties.getProperty("foo");
serverSidePropertyUpdatedByClient.setValue("bar");
MapProperty serverSideProperty = properties.getProperty("other");
serverSideProperty.setValue("value");
handler.nodeRegistered(node);
Mockito.when(tree.getNode(node.getId())).thenReturn(node);
handler.flushPropertyUpdates();
serverSidePropertyUpdatedByClient.setValue("updated");
MapProperty clientSideProperty = properties.getProperty("client");
clientSideProperty.setValue("baz");
handler.handlePropertyUpdate(serverSidePropertyUpdatedByClient);
handler.handlePropertyUpdate(clientSideProperty);
Reactive.flush();
Assert.assertEquals("bar", properties.getProperty("foo").getValue());
Assert.assertEquals("value", properties.getProperty("other").getValue());
Assert.assertEquals("baz", properties.getProperty("client").getValue());
Mockito.verify(tree, Mockito.times(0)).sendNodePropertySyncToServer(serverSidePropertyUpdatedByClient);
Mockito.verify(tree, Mockito.times(0)).sendNodePropertySyncToServer(serverSideProperty);
Mockito.verify(tree).sendNodePropertySyncToServer(clientSideProperty);
}
Aggregations