diff options
author | Ilia Motornyi <elmot@vaadin.com> | 2018-04-17 15:50:41 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2018-04-17 15:50:41 +0300 |
commit | 307bdc7db64fd631ada4b62f0433f41e66781911 (patch) | |
tree | 60f9cd52a837cda6127b3fb65b6c03f63e08abe2 /server/src/test | |
parent | aac64dba9c3a2841ccd9ab524b752b6307f0159d (diff) | |
download | vaadin-framework-307bdc7db64fd631ada4b62f0433f41e66781911.tar.gz vaadin-framework-307bdc7db64fd631ada4b62f0433f41e66781911.zip |
Fixes declarative update of existing Composite (#10825)
Fixes #10170
Diffstat (limited to 'server/src/test')
-rw-r--r-- | server/src/test/java/com/vaadin/tests/server/component/tree/TreeDeclarativeTest.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/server/src/test/java/com/vaadin/tests/server/component/tree/TreeDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/tree/TreeDeclarativeTest.java index b2c0c8ae21..0e51c93d1d 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/tree/TreeDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/tree/TreeDeclarativeTest.java @@ -1,9 +1,13 @@ package com.vaadin.tests.server.component.tree; +import java.io.ByteArrayInputStream; + +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; import org.junit.Test; +import com.vaadin.data.SelectionModel; import com.vaadin.data.TreeData; import com.vaadin.data.provider.HierarchicalQuery; import com.vaadin.shared.ui.ContentMode; @@ -13,6 +17,7 @@ import com.vaadin.ui.Grid.SelectionMode; import com.vaadin.ui.IconGenerator; import com.vaadin.ui.ItemCaptionGenerator; import com.vaadin.ui.Tree; +import com.vaadin.ui.declarative.Design; public class TreeDeclarativeTest extends AbstractComponentDeclarativeTestBase<Tree> { @@ -140,6 +145,30 @@ public class TreeDeclarativeTest testWrite(design, tree); } + @Test + public void testUpdateExisting() { + Tree tree = new Tree(); + + String treeDesign = + "<vaadin-tree selection-mode=\"MULTI\">" + + "<node item=\"A\">A</node>" + + "<node item=\"B\">B</node>" + + "<node item=\"AA\" parent=\"A\">AA</node>" + + "</vaadin-tree>"; + + Design.read(new ByteArrayInputStream(treeDesign.getBytes()), tree); + Object[] items = tree.getDataProvider(). + fetchChildren(new HierarchicalQuery(null, null)).toArray(); + assertArrayEquals(new Object[]{"A", "B"}, items); + Object[] itemsA = tree.getDataProvider(). + fetchChildren(new HierarchicalQuery(null, "A")).toArray(); + assertArrayEquals(new Object[]{"AA"}, itemsA); + long countB = tree.getDataProvider(). + fetchChildren(new HierarchicalQuery(null, "B")).count(); + assertEquals(0L, countB); + assertTrue(tree.getSelectionModel() instanceof SelectionModel.Multi); + } + @Override protected String getComponentTag() { return "vaadin-tree"; |