summaryrefslogtreecommitdiffstats
path: root/infra/data-impl/src/test/java
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-11-21 13:09:23 +0100
committerMarek Gradzki <mgradzki@cisco.com>2016-11-24 07:03:59 +0000
commit8128f33de85b2e839a8ce6d18812374a63b81c66 (patch)
treeab4e51ea3c95ea12c018145a022cfa8ab4e115a6 /infra/data-impl/src/test/java
parent567247ad5a1ba1c8aff3cb2b47211f7c68f0545d (diff)
Fix leaf list modification detection
Change-Id: Ib7bcde546faf8e9bf73d16adaf87c2f8c43ec4aa Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra/data-impl/src/test/java')
-rw-r--r--infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationDiffTest.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationDiffTest.java b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationDiffTest.java
index 29390e4c9..664b57378 100644
--- a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationDiffTest.java
+++ b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationDiffTest.java
@@ -28,6 +28,7 @@ import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -41,6 +42,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree
import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
@@ -60,6 +62,10 @@ public class ModificationDiffTest {
static final QName EMPTY_QNAME = QName.create(TOP_CONTAINER_QNAME, "empty");
static final QName IN_EMPTY_QNAME = QName.create(TOP_CONTAINER_QNAME, "in-empty");
+ static final QName FOR_LEAF_LIST_QNAME = QName.create(TOP_CONTAINER_QNAME, "for-leaf-list");
+ static final QName NESTED_LEAF_LIST_QNAME = QName.create(TOP_CONTAINER_QNAME, "nested-leaf-list");
+
+
static final QName WITH_CHOICE_CONTAINER_QNAME =
QName.create("urn:opendaylight:params:xml:ns:yang:test:diff", "2015-01-05", "with-choice");
static final QName CHOICE_QNAME = QName.create(WITH_CHOICE_CONTAINER_QNAME, "choice");
@@ -88,6 +94,24 @@ public class ModificationDiffTest {
}
@Test
+ public void testLeafList() throws Exception {
+ final TipProducingDataTree dataTree = getDataTree();
+ final DataTreeModification dataTreeModification = getModification(dataTree);
+ final ContainerNode topContainer = getTopContainerWithLeafList("string1", "string2");
+ final YangInstanceIdentifier TOP_CONTAINER_ID = YangInstanceIdentifier.of(TOP_CONTAINER_QNAME);
+ dataTreeModification.write(TOP_CONTAINER_ID, topContainer);
+ final DataTreeCandidateTip prepare = prepareModification(dataTree, dataTreeModification);
+
+ final ModificationDiff modificationDiff = getModificationDiff(prepare);
+
+ assertThat(modificationDiff.getUpdates().size(), is(1));
+ assertThat(modificationDiff.getUpdates().values().size(), is(1));
+ assertUpdate(modificationDiff.getUpdates().values().iterator().next(),
+ TOP_CONTAINER_ID.node(FOR_LEAF_LIST_QNAME), null,
+ topContainer.getChild(new YangInstanceIdentifier.NodeIdentifier(FOR_LEAF_LIST_QNAME)).get());
+ }
+
+ @Test
public void testWritePresenceEmptyContainer() throws Exception {
final TipProducingDataTree dataTree = getDataTree();
final DataTreeModification dataTreeModification = getModification(dataTree);
@@ -456,6 +480,26 @@ public class ModificationDiffTest {
.build();
}
+ static ContainerNode getTopContainerWithLeafList(final String... stringValue) {
+ final ListNodeBuilder<String, LeafSetEntryNode<String>> leafSetBuilder = Builders.leafSetBuilder();
+ for (final String value : stringValue) {
+ leafSetBuilder.withChild(Builders.<String>leafSetEntryBuilder()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(NESTED_LEAF_LIST_QNAME, value))
+ .withValue(value)
+ .build());
+ }
+
+ return Builders.containerBuilder()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_CONTAINER_QNAME))
+ .withChild(Builders.containerBuilder()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(FOR_LEAF_LIST_QNAME))
+ .withChild(leafSetBuilder
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(NESTED_LEAF_LIST_QNAME))
+ .build())
+ .build())
+ .build();
+ }
+
static MapNode getNestedList(final String listItemName, final String text) {
return Builders.mapBuilder()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(NESTED_LIST_QNAME))