use of com.vaadin.client.flow.reactive.FlushListener in project flow by vaadin.
the class InitialPropertiesHandlerTest method flushPropertyUpdates_updateIsNotInProgress_flushForEechProperty.
@Test
public void flushPropertyUpdates_updateIsNotInProgress_flushForEechProperty() {
Mockito.when(tree.isUpdateInProgress()).thenReturn(false);
StateNode node = new StateNode(1, tree);
NodeMap properties = node.getMap(NodeFeatures.ELEMENT_PROPERTIES);
MapProperty property1 = properties.getProperty("foo");
property1.setValue("bar");
MapProperty property2 = properties.getProperty("other");
property2.setValue("value");
handler.nodeRegistered(node);
Mockito.when(tree.getNode(node.getId())).thenReturn(node);
handler.flushPropertyUpdates();
property1.setValue("baz");
property2.setValue("foo");
handler.handlePropertyUpdate(property1);
handler.handlePropertyUpdate(property2);
AtomicInteger count = new AtomicInteger();
FlushListener listener = () -> count.incrementAndGet();
property1.addChangeListener(event -> Reactive.addFlushListener(listener));
property2.addChangeListener(event -> Reactive.addFlushListener(listener));
Reactive.flush();
Assert.assertEquals(2, count.get());
}
Aggregations