Use DatabindContext in InstanceIdentifierContext
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / nb / rfc8040 / AbstractJukeboxTest.java
index 077e04ca7968d185b30147161490b3bcf9e75c07..909a8e952231c0dac1b2723b8c72b1daaa784618 100644 (file)
@@ -10,6 +10,8 @@ package org.opendaylight.restconf.nb.rfc8040;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.restconf.nb.rfc8040.databind.DatabindContext;
 import org.opendaylight.yangtools.yang.common.Decimal64;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -18,6 +20,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
@@ -31,6 +34,12 @@ public abstract class AbstractJukeboxTest {
     protected static final QName PLAYER_QNAME = QName.create(JUKEBOX_QNAME, "player");
     // container library
     protected static final QName LIBRARY_QNAME = QName.create(JUKEBOX_QNAME, "library");
+    // list song
+    protected static final QName SONG_QNAME = QName.create(JUKEBOX_QNAME, "song");
+    // leaf id
+    protected static final QName SONG_ID_QNAME = QName.create(JUKEBOX_QNAME, "id");
+    // leaf index
+    protected static final QName SONG_INDEX_QNAME = QName.create(JUKEBOX_QNAME, "index");
     // list artist
     protected static final QName ARTIST_QNAME = QName.create(JUKEBOX_QNAME, "artist");
     // list album
@@ -66,9 +75,32 @@ public abstract class AbstractJukeboxTest {
         .withChild(ImmutableNodes.leafNode(NAME_QNAME, "name of band"))
         .withChild(ImmutableNodes.leafNode(DESCRIPTION_QNAME, "band description"))
         .build();
+    protected static final MapEntryNode SONG1 = Builders.mapEntryBuilder()
+        .withNodeIdentifier(YangInstanceIdentifier.NodeIdentifierWithPredicates.of(SONG_QNAME, SONG_INDEX_QNAME,
+            "1"))
+        .withChild(ImmutableNodes.leafNode(SONG_ID_QNAME, "A"))
+        .build();
+    protected static final MapEntryNode SONG2 = Builders.mapEntryBuilder()
+        .withNodeIdentifier(YangInstanceIdentifier.NodeIdentifierWithPredicates.of(SONG_QNAME, SONG_INDEX_QNAME,
+            "2"))
+        .withChild(ImmutableNodes.leafNode(SONG_ID_QNAME, "B"))
+        .build();
+    protected static final SystemMapNode PLAYLIST_WITH_SONGS = Builders.mapBuilder()
+        .withNodeIdentifier(new NodeIdentifier(JUKEBOX_QNAME))
+        .withChild(Builders.mapEntryBuilder()
+            .withNodeIdentifier(YangInstanceIdentifier.NodeIdentifierWithPredicates.of(PLAYLIST_QNAME, NAME_QNAME,
+                "0"))
+                .withChild(Builders.orderedMapBuilder()
+                    .withNodeIdentifier(new NodeIdentifier(SONG_QNAME))
+                    .withChild(SONG1)
+                    .withChild(SONG2)
+                    .build())
+                .build())
+            .build();
 
-    protected static final EffectiveModelContext JUKEBOX_SCHEMA =
+    protected static final @NonNull EffectiveModelContext JUKEBOX_SCHEMA =
         YangParserTestUtils.parseYangResourceDirectory("/jukebox");
+    protected static final @NonNull DatabindContext JUKEBOX_DATABIND = DatabindContext.ofModel(JUKEBOX_SCHEMA);
 
     protected static final InputStream stringInputStream(final String str) {
         return new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));