Handle empty type in NormalizedNode streaming
authorTom Pantelis <tompantelis@gmail.com>
Sat, 20 Jan 2018 00:19:03 +0000 (19:19 -0500)
committerRobert Varga <nite@hq.sk>
Mon, 22 Jan 2018 19:58:31 +0000 (19:58 +0000)
The yang "empty" type is now represented as
org.opendaylight.yangtools.yang.common.Empty so handle it.

NormalizedNode no longer allows a null value but we still need
to handle NULL_TYPE on input for backwards compatibility. NULL_TYPE
is translated to Empty.

Change-Id: I99b87138d7358d37170cf603d993cd1a4f6a2087
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
node/utils/stream/NormalizedNodeStreamReaderWriterTest.java
util/TestModel.java

index e2e5aa4befda521a389f37e7c6df020464767e35..147cc663d956ca4d7f4bac89d187407b575cfb38 100644 (file)
@@ -26,6 +26,7 @@ import org.apache.commons.lang.SerializationUtils;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.util.TestModel;
+import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
@@ -92,6 +93,7 @@ public class NormalizedNodeStreamReaderWriterTest {
                         new NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME))
                         .withChild(entry1).withChild(entry2).build())
                 .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1, 2, 3, 4}))
+                .withChild(ImmutableNodes.leafNode(TestModel.EMPTY_QNAME, Empty.getInstance()))
                 .withChild(Builders.orderedMapBuilder()
                       .withNodeIdentifier(new NodeIdentifier(TestModel.ORDERED_LIST_QNAME))
                       .withChild(ImmutableNodes.mapEntry(TestModel.ORDERED_LIST_ENTRY_QNAME,
index 72b8a3bb7f2e3eea6f325ba3753a83338087c12d..7cdd7839954397c440858070adb6268013124b4e 100644 (file)
@@ -94,6 +94,7 @@ public final class TestModel {
     public static final QName CHOICE_QNAME = QName.create(TEST_QNAME, "choice");
     public static final QName SHOE_QNAME = QName.create(TEST_QNAME, "shoe");
     public static final QName ANY_XML_QNAME = QName.create(TEST_QNAME, "any");
+    public static final QName EMPTY_QNAME = QName.create(TEST_QNAME, "empty-leaf");
     public static final QName INVALID_QNAME = QName.create(TEST_QNAME, "invalid");
     private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
     private static final String DATASTORE_AUG_YANG = "/odl-datastore-augmentation.yang";