use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ElementPropertyMapTest method deferredUpdateFromClient_filterAllowsUpdate.
@Test
public void deferredUpdateFromClient_filterAllowsUpdate() throws PropertyChangeDeniedException {
ElementPropertyMap map = createSimplePropertyMap();
StateNode child = new StateNode(ElementPropertyMap.class);
ElementPropertyMap childModel = ElementPropertyMap.getModel(child);
map.setUpdateFromClientFilter("foo.bar"::equals);
map.put("foo", child);
assertDeferredUpdate_putResult(childModel, "bar");
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ElementPropertyMapTest method listChildPropertyUpdateFilter_setFilterBeforeChild.
@Test
public void listChildPropertyUpdateFilter_setFilterBeforeChild() {
ElementPropertyMap map = createSimplePropertyMap();
ModelList list = map.resolveModelList("foo");
StateNode child = new StateNode(ElementPropertyMap.class);
map.setUpdateFromClientFilter("foo.bar"::equals);
list.add(child);
ElementPropertyMap childModel = ElementPropertyMap.getModel(child);
Assert.assertTrue(childModel.mayUpdateFromClient("bar", "a"));
Assert.assertFalse(childModel.mayUpdateFromClient("baz", "a"));
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class NodeListEmptyRequiredFeatureTest method setUp.
@Before
public void setUp() {
node = new StateNode(Arrays.asList(ElementChildrenList.class)) {
@Override
public boolean isAttached() {
return true;
}
};
nodeList = node.getFeature(ElementChildrenList.class);
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class StateNodeNodeListTest method testClear.
@Test
public void testClear() {
StateNode one = StateNodeTest.createEmptyNode("one");
StateNode two = StateNodeTest.createEmptyNode("two");
nodeList.add(one);
nodeList.add(two);
Assert.assertEquals(2, nodeList.size());
nodeList.clear();
Assert.assertEquals(0, nodeList.size());
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class StateNodeNodeListTest method testSerializable.
@Test
public void testSerializable() {
StateNode one = StateNodeTest.createTestNode("one", ElementClassList.class);
one.getFeature(ElementClassList.class).add("foo");
one.getFeature(ElementClassList.class).add("bar");
StateNode two = StateNodeTest.createTestNode("two", ElementClassList.class);
two.getFeature(ElementClassList.class).add("baz");
nodeList.add(one);
nodeList.add(two);
List<StateNode> values = new ArrayList<>();
int size = nodeList.size();
for (int i = 0; i < size; i++) {
values.add(nodeList.get(i));
}
NodeList<StateNode> copy = SerializationUtils.deserialize(SerializationUtils.serialize(nodeList));
Assert.assertNotSame(nodeList, copy);
Assert.assertEquals(values.size(), copy.size());
for (int i = 0; i < size; i++) {
assertNodeEquals(values.get(i), copy.get(i));
}
// Also verify that original value wasn't changed by the serialization
Assert.assertEquals(values.size(), nodeList.size());
for (int i = 0; i < size; i++) {
assertNodeEquals(values.get(i), nodeList.get(i));
}
}
Aggregations