use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ModelMapTest method dotInvalidInKey.
@Test(expected = IllegalArgumentException.class)
public void dotInvalidInKey() {
ModelMap map = new ModelMap(new StateNode());
map.setValue("foo.bar", "a");
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ModelMapTest method hasValue.
@Test
public void hasValue() {
ModelMap map = new ModelMap(new StateNode());
Assert.assertFalse(map.hasValue("foo"));
map.setValue("foo", "bar");
Assert.assertTrue(map.hasValue("foo"));
map.remove("foo");
Assert.assertFalse(map.hasValue("foo"));
}
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