use of com.vaadin.flow.internal.change.NodeChange in project flow by vaadin.
the class StateTreeTest method allValuesAfterReattach.
@Test
public void allValuesAfterReattach() {
StateNode node1 = tree.getRootNode();
StateNode node2 = new StateNode(ElementData.class);
StateNodeTest.setParent(node2, node1);
node2.getFeature(ElementData.class).setTag("foo");
collectChangesExceptChildrenAddRemove();
StateNodeTest.setParent(node2, null);
collectChangesExceptChildrenAddRemove();
StateNodeTest.setParent(node2, node1);
List<NodeChange> changes = collectChangesExceptChildrenAddRemove();
Assert.assertEquals("Should be two changes.", 2, changes.size());
Assert.assertTrue("First change should re-attach the node.", changes.get(0) instanceof NodeAttachChange);
Assert.assertTrue("Second change should re-put the value.", changes.get(1) instanceof MapPutChange);
MapPutChange nodeChange = (MapPutChange) changes.get(1);
Assert.assertEquals(ElementData.class, nodeChange.getFeature());
Assert.assertEquals("tag", nodeChange.getKey());
Assert.assertEquals("foo", nodeChange.getValue());
}
use of com.vaadin.flow.internal.change.NodeChange in project flow by vaadin.
the class StateTreeTest method testTreeChangeCollection.
@Test
public void testTreeChangeCollection() {
StateNode node2 = StateNodeTest.createEmptyNode();
StateNodeTest.setParent(node2, tree.getRootNode());
List<NodeChange> changes = collectChangesExceptChildrenAddRemove();
Assert.assertEquals(1, changes.size());
NodeAttachChange nodeChange = (NodeAttachChange) changes.get(0);
Assert.assertSame(node2, nodeChange.getNode());
}
use of com.vaadin.flow.internal.change.NodeChange in project flow by vaadin.
the class NodeListAddRemoveTest method verifyRemoved.
private void verifyRemoved(List<NodeChange> changes, List<String> items, Integer... indexes) {
Assert.assertTrue(changes.size() > 0);
for (int i = 0; i < indexes.length; i++) {
NodeChange nodeChange = changes.get(i);
Assert.assertThat(nodeChange, CoreMatchers.instanceOf(ListRemoveChange.class));
ListRemoveChange<?> change = (ListRemoveChange<?>) nodeChange;
Assert.assertEquals(indexes[i].intValue(), change.getIndex());
Assert.assertEquals(items.get(i), change.getRemovedItem());
}
}
use of com.vaadin.flow.internal.change.NodeChange in project flow by vaadin.
the class NodeListEmptyRequiredFeatureTest method generateChangesFromEmpty_noEmptyChange.
@Test
public void generateChangesFromEmpty_noEmptyChange() {
nodeList.add(new StateNode());
node.clearChanges();
nodeList.generateChangesFromEmpty();
List<NodeChange> changes = new ArrayList<>();
node.collectChanges(changes::add);
Assert.assertEquals(1, changes.size());
Assert.assertTrue(changes.get(0) instanceof ListAddChange<?>);
}
use of com.vaadin.flow.internal.change.NodeChange in project flow by vaadin.
the class NodeListEmptyRequiredFeatureTest method collectChanges_noEmptyChange.
@Test
public void collectChanges_noEmptyChange() {
nodeList.add(new StateNode());
List<NodeChange> changes = new ArrayList<>();
node.collectChanges(changes::add);
Assert.assertEquals(1, changes.size());
Assert.assertTrue(changes.get(0) instanceof ListAddChange<?>);
}
Aggregations