Fix parsing of fields parameters 95/81195/1
authorJaroslav Tóth <jtoth@frinx.io>
Tue, 26 Mar 2019 15:02:24 +0000 (16:02 +0100)
committerJaroslav Tóth <jtoth@frinx.io>
Tue, 26 Mar 2019 15:02:24 +0000 (16:02 +0100)
- Multiple nested schema nodes splitted by semilcolon can be placed
  on one level of QNames, also, when the nested schema nodes are
  specified by multiple-nodes path; example:
  fields=service(type;instance/name;instance/provider)
- Previously, multiple-nodes nested path to schema node had to be
  listed as the last parameter in brackets without any other
  multi-nodes nested path.

Change-Id: I0d2f76047342e19a996fea0abe4001597d1c0a03
JIRA: NETCONF-320
Signed-off-by: Jaroslav Tóth <jtoth@frinx.io>
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserFieldsParameter.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserFieldsParameterTest.java
restconf/restconf-nb-rfc8040/src/test/resources/test-services/test-services@2019-03-25.yang [new file with mode: 0644]

index 9bd46d76e0a7cc08f5ac10ec02dd191c812b5a71..cc6cbda14a163ac56df72c2189e304f90308490f 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.restconf.nb.rfc8040.utils.parser;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
@@ -77,6 +78,10 @@ public final class ParserFieldsParameter {
         Set<QName> currentLevel = new HashSet<>();
         parsed.add(currentLevel);
 
+        DataSchemaContextNode<?> parenthesisNode = currentNode;
+        Set<QName> parenthesisLevel = currentLevel;
+        QNameModule parenthesisQNameModule = currentQNameModule;
+
         while (currentPosition < input.length()) {
             final char currentChar = input.charAt(currentPosition);
 
@@ -87,8 +92,7 @@ public final class ParserFieldsParameter {
                             currentNode,
                             input.substring(startPosition, currentPosition), currentQNameModule, currentLevel);
                     // go one level down
-                    currentLevel = new HashSet<>();
-                    parsed.add(currentLevel);
+                    currentLevel = prepareQNameLevel(parsed, currentLevel);
 
                     currentPosition++;
                     startPosition = currentPosition;
@@ -150,6 +154,11 @@ public final class ParserFieldsParameter {
                             currentNode,
                             input.substring(startPosition, currentPosition), currentQNameModule, currentLevel);
                     currentPosition++;
+
+                    // next nodes can be placed on already utilized level-s
+                    currentNode = parenthesisNode;
+                    currentQNameModule = parenthesisQNameModule;
+                    currentLevel = parenthesisLevel;
                     break;
                 default:
                     throw new RestconfDocumentedException(
@@ -166,6 +175,35 @@ public final class ParserFieldsParameter {
         }
     }
 
+    /**
+     * Preparation of the QName level that is used as storage for parsed QNames. If the current level exist at the
+     * index that doesn't equal to the last index of already parsed QNames, a new level of QNames is allocated and
+     * pushed to input parsed QNames.
+     *
+     * @param parsedQNames Already parsed list of QNames grouped to multiple levels.
+     * @param currentLevel Current level of QNames (set).
+     * @return Existing or new level of QNames.
+     */
+    private static Set<QName> prepareQNameLevel(final List<Set<QName>> parsedQNames, final Set<QName> currentLevel) {
+        final Optional<Set<QName>> existingLevel = parsedQNames.stream()
+                .filter(qNameSet -> qNameSet.equals(currentLevel))
+                .findAny();
+        if (existingLevel.isPresent()) {
+            final int index = parsedQNames.indexOf(existingLevel.get());
+            if (index == parsedQNames.size() - 1) {
+                final Set<QName> nextLevel = new HashSet<>();
+                parsedQNames.add(nextLevel);
+                return nextLevel;
+            } else {
+                return parsedQNames.get(index + 1);
+            }
+        } else {
+            final Set<QName> nextLevel = new HashSet<>();
+            parsedQNames.add(nextLevel);
+            return nextLevel;
+        }
+    }
+
     /**
      * Add parsed child of current node to result for current level.
      * @param currentNode current node
index 8883ac8f88da5e542fd0c34d6ac650e17843fc77..656e098182810de93d5eff2a2bdea24fc5cd8c35 100644 (file)
@@ -13,14 +13,16 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import com.google.common.collect.Sets;
 import java.net.URI;
 import java.util.List;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
@@ -38,80 +40,154 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 /**
  * Unit test for {@link ParserFieldsParameter}.
  */
+@RunWith(MockitoJUnitRunner.class)
 public class ParserFieldsParameterTest {
 
     @Mock
-    private InstanceIdentifierContext<ContainerSchemaNode> identifierContext;
+    private InstanceIdentifierContext<ContainerSchemaNode> identifierJukebox;
+
+    @Mock
+    private InstanceIdentifierContext<ContainerSchemaNode> identifierTestServices;
+
+    private static final QNameModule Q_NAME_MODULE_JUKEBOX = QNameModule.create(
+            URI.create("http://example.com/ns/example-jukebox"),
+            Revision.of("2015-04-04"));
+    private static final QNameModule Q_NAME_MODULE_TEST_SERVICES = QNameModule.create(
+            URI.create("tests:test-services"),
+            Revision.of("2019-03-25"));
 
     // container jukebox
     @Mock
     private ContainerSchemaNode containerJukebox;
-    private QName jukeboxQName;
+    private static final QName JUKEBOX_Q_NAME = QName.create(Q_NAME_MODULE_JUKEBOX, "jukebox");
 
     // container player
     @Mock
     private ContainerSchemaNode containerPlayer;
-    private QName playerQName;
+    private static final QName PLAYER_Q_NAME = QName.create(Q_NAME_MODULE_JUKEBOX, "player");
 
     // container library
     @Mock
     private ContainerSchemaNode containerLibrary;
-    private QName libraryQName;
+    private static final QName LIBRARY_Q_NAME = QName.create(Q_NAME_MODULE_JUKEBOX, "library");
 
     // container augmented library
     @Mock
     private ContainerSchemaNode augmentedContainerLibrary;
-    private QName augmentedLibraryQName;
+    private static final QName AUGMENTED_LIBRARY_Q_NAME = QName.create(
+            QNameModule.create(
+                    URI.create("http://example.com/ns/augmented-jukebox"),
+                    Revision.of("2016-05-05")),
+            "augmented-library");
 
     // list album
     @Mock
     private ListSchemaNode listAlbum;
-    private QName albumQName;
+    private static final QName ALBUM_Q_NAME = QName.create(Q_NAME_MODULE_JUKEBOX, "album");
 
     // leaf name
     @Mock
     private LeafSchemaNode leafName;
-    private QName nameQName;
+    private static final QName NAME_Q_NAME = QName.create(Q_NAME_MODULE_JUKEBOX, "name");
+
+    // container test data
+    @Mock
+    private ContainerSchemaNode containerTestData;
+    private static final QName TEST_DATA_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "test-data");
+
+    // list services
+    @Mock
+    private ListSchemaNode listServices;
+    private static final QName SERVICES_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "services");
+
+    // leaf type-of-service
+    @Mock
+    private LeafSchemaNode leafTypeOfService;
+    private static final QName TYPE_OF_SERVICE_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "type-of-service");
+
+    // list instance
+    @Mock
+    private ListSchemaNode listInstance;
+    private static final QName INSTANCE_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "instance");
+
+    // leaf instance-name
+    @Mock
+    private LeafSchemaNode leafInstanceName;
+    private static final QName INSTANCE_NAME_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "instance-name");
+
+    // leaf provider
+    @Mock
+    private LeafSchemaNode leafProvider;
+    private static final QName PROVIDER_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "provider");
+
+    // container next-data
+    @Mock
+    private ContainerSchemaNode containerNextData;
+    private static final QName NEXT_DATA_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "next-data");
+
+    // leaf next-service
+    @Mock
+    private LeafSchemaNode leafNextService;
+    private static final QName NEXT_SERVICE_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "next-service");
 
     @Before
     public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-        final SchemaContext schemaContext =
+        final SchemaContext schemaContextJukebox =
                 YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/jukebox"));
+        initJukeboxSchemaNodes(schemaContextJukebox);
 
-        final QNameModule qNameModule = QNameModule.create(URI.create("http://example.com/ns/example-jukebox"),
-            Revision.of("2015-04-04"));
+        final SchemaContext schemaContextTestServices =
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/test-services"));
+        initTestServicesSchemaNodes(schemaContextTestServices);
+    }
 
-        this.jukeboxQName = QName.create(qNameModule, "jukebox");
-        this.playerQName = QName.create(qNameModule, "player");
-        this.libraryQName = QName.create(qNameModule, "library");
-        this.augmentedLibraryQName = QName.create(
-                QNameModule.create(
-                        URI.create("http://example.com/ns/augmented-jukebox"),
-                        Revision.of("2016-05-05")),
-                "augmented-library");
-        this.albumQName = QName.create(qNameModule, "album");
-        this.nameQName = QName.create(qNameModule, "name");
+    private void initJukeboxSchemaNodes(final SchemaContext schemaContext) {
+        Mockito.when(identifierJukebox.getSchemaContext()).thenReturn(schemaContext);
+        Mockito.when(containerJukebox.getQName()).thenReturn(JUKEBOX_Q_NAME);
+        Mockito.when(identifierJukebox.getSchemaNode()).thenReturn(containerJukebox);
 
-        Mockito.when(this.identifierContext.getSchemaContext()).thenReturn(schemaContext);
-        Mockito.when(this.containerJukebox.getQName()).thenReturn(this.jukeboxQName);
-        Mockito.when(this.identifierContext.getSchemaNode()).thenReturn(this.containerJukebox);
+        Mockito.when(containerLibrary.getQName()).thenReturn(LIBRARY_Q_NAME);
+        Mockito.when(containerJukebox.getDataChildByName(LIBRARY_Q_NAME)).thenReturn(containerLibrary);
 
-        Mockito.when(this.containerLibrary.getQName()).thenReturn(this.libraryQName);
-        Mockito.when(this.containerJukebox.getDataChildByName(this.libraryQName)).thenReturn(this.containerLibrary);
+        Mockito.when(augmentedContainerLibrary.getQName()).thenReturn(AUGMENTED_LIBRARY_Q_NAME);
+        Mockito.when(containerJukebox.getDataChildByName(AUGMENTED_LIBRARY_Q_NAME))
+                .thenReturn(augmentedContainerLibrary);
 
-        Mockito.when(this.augmentedContainerLibrary.getQName()).thenReturn(this.augmentedLibraryQName);
-        Mockito.when(this.containerJukebox.getDataChildByName(this.augmentedLibraryQName))
-                .thenReturn(this.augmentedContainerLibrary);
+        Mockito.when(containerPlayer.getQName()).thenReturn(PLAYER_Q_NAME);
+        Mockito.when(containerJukebox.getDataChildByName(PLAYER_Q_NAME)).thenReturn(containerPlayer);
 
-        Mockito.when(this.containerPlayer.getQName()).thenReturn(this.playerQName);
-        Mockito.when(this.containerJukebox.getDataChildByName(this.playerQName)).thenReturn(this.containerPlayer);
+        Mockito.when(listAlbum.getQName()).thenReturn(ALBUM_Q_NAME);
+        Mockito.when(containerLibrary.getDataChildByName(ALBUM_Q_NAME)).thenReturn(listAlbum);
+
+        Mockito.when(leafName.getQName()).thenReturn(NAME_Q_NAME);
+        Mockito.when(listAlbum.getDataChildByName(NAME_Q_NAME)).thenReturn(leafName);
+    }
 
-        Mockito.when(this.listAlbum.getQName()).thenReturn(this.albumQName);
-        Mockito.when(this.containerLibrary.getDataChildByName(this.albumQName)).thenReturn(this.listAlbum);
+    private void initTestServicesSchemaNodes(final SchemaContext schemaContext) {
+        Mockito.when(identifierTestServices.getSchemaContext()).thenReturn(schemaContext);
+        Mockito.when(containerTestData.getQName()).thenReturn(TEST_DATA_Q_NAME);
+        Mockito.when(identifierTestServices.getSchemaNode()).thenReturn(containerTestData);
 
-        Mockito.when(this.leafName.getQName()).thenReturn(this.nameQName);
-        Mockito.when(this.listAlbum.getDataChildByName(this.nameQName)).thenReturn(this.leafName);
+        Mockito.when(listServices.getQName()).thenReturn(SERVICES_Q_NAME);
+        Mockito.when(containerTestData.getDataChildByName(SERVICES_Q_NAME)).thenReturn(listServices);
+
+        Mockito.when(leafTypeOfService.getQName()).thenReturn(TYPE_OF_SERVICE_Q_NAME);
+        Mockito.when(listServices.getDataChildByName(TYPE_OF_SERVICE_Q_NAME)).thenReturn(leafTypeOfService);
+
+        Mockito.when(listInstance.getQName()).thenReturn(INSTANCE_Q_NAME);
+        Mockito.when(listServices.getDataChildByName(INSTANCE_Q_NAME)).thenReturn(listInstance);
+
+        Mockito.when(leafInstanceName.getQName()).thenReturn(INSTANCE_NAME_Q_NAME);
+        Mockito.when(listInstance.getDataChildByName(INSTANCE_NAME_Q_NAME)).thenReturn(leafInstanceName);
+
+        Mockito.when(leafProvider.getQName()).thenReturn(PROVIDER_Q_NAME);
+        Mockito.when(listInstance.getDataChildByName(PROVIDER_Q_NAME)).thenReturn(leafProvider);
+
+        Mockito.when(containerNextData.getQName()).thenReturn(NEXT_DATA_Q_NAME);
+        Mockito.when(listServices.getDataChildByName(NEXT_DATA_Q_NAME)).thenReturn(containerNextData);
+
+        Mockito.when(leafNextService.getQName()).thenReturn(NEXT_SERVICE_Q_NAME);
+        Mockito.when(containerNextData.getDataChildByName(NEXT_SERVICE_Q_NAME)).thenReturn(leafNextService);
     }
 
     /**
@@ -120,12 +196,12 @@ public class ParserFieldsParameterTest {
     @Test
     public void parseFieldsParameterSimplePathTest() {
         final String input = "library";
-        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input);
 
         assertNotNull(parsedFields);
         assertEquals(1, parsedFields.size());
         assertEquals(1, parsedFields.get(0).size());
-        assertTrue(parsedFields.get(0).contains(this.libraryQName));
+        assertTrue(parsedFields.get(0).contains(LIBRARY_Q_NAME));
     }
 
     /**
@@ -134,13 +210,13 @@ public class ParserFieldsParameterTest {
     @Test
     public void parseFieldsParameterDoublePathTest() {
         final String input = "library;player";
-        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input);
 
         assertNotNull(parsedFields);
         assertEquals(1, parsedFields.size());
         assertEquals(2, parsedFields.get(0).size());
-        assertTrue(parsedFields.get(0).contains(this.libraryQName));
-        assertTrue(parsedFields.get(0).contains(this.playerQName));
+        assertTrue(parsedFields.get(0).contains(LIBRARY_Q_NAME));
+        assertTrue(parsedFields.get(0).contains(PLAYER_Q_NAME));
     }
 
     /**
@@ -149,19 +225,19 @@ public class ParserFieldsParameterTest {
     @Test
     public void parseFieldsParameterSubPathTest() {
         final String input = "library/album/name";
-        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input);
 
         assertNotNull(parsedFields);
         assertEquals(3, parsedFields.size());
 
         assertEquals(1, parsedFields.get(0).size());
-        assertTrue(parsedFields.get(0).contains(this.libraryQName));
+        assertTrue(parsedFields.get(0).contains(LIBRARY_Q_NAME));
 
         assertEquals(1, parsedFields.get(1).size());
-        assertTrue(parsedFields.get(1).contains(this.albumQName));
+        assertTrue(parsedFields.get(1).contains(ALBUM_Q_NAME));
 
         assertEquals(1, parsedFields.get(2).size());
-        assertTrue(parsedFields.get(2).contains(this.nameQName));
+        assertTrue(parsedFields.get(2).contains(NAME_Q_NAME));
     }
 
     /**
@@ -170,19 +246,19 @@ public class ParserFieldsParameterTest {
     @Test
     public void parseFieldsParameterChildrenPathTest() {
         final String input = "library(album(name))";
-        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input);
 
         assertNotNull(parsedFields);
         assertEquals(3, parsedFields.size());
 
         assertEquals(1, parsedFields.get(0).size());
-        assertTrue(parsedFields.get(0).contains(this.libraryQName));
+        assertTrue(parsedFields.get(0).contains(LIBRARY_Q_NAME));
 
         assertEquals(1, parsedFields.get(1).size());
-        assertTrue(parsedFields.get(1).contains(this.albumQName));
+        assertTrue(parsedFields.get(1).contains(ALBUM_Q_NAME));
 
         assertEquals(1, parsedFields.get(2).size());
-        assertTrue(parsedFields.get(2).contains(this.nameQName));
+        assertTrue(parsedFields.get(2).contains(NAME_Q_NAME));
     }
 
     /**
@@ -191,13 +267,81 @@ public class ParserFieldsParameterTest {
     @Test
     public void parseFieldsParameterNamespaceTest() {
         final String input = "augmented-jukebox:augmented-library";
-        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input);
 
         assertNotNull(parsedFields);
         assertEquals(1, parsedFields.size());
 
         assertEquals(1, parsedFields.get(0).size());
-        assertTrue(parsedFields.get(0).contains(this.augmentedLibraryQName));
+        assertTrue(parsedFields.get(0).contains(AUGMENTED_LIBRARY_Q_NAME));
+    }
+
+    /**
+     * Testing of fields parameter parsing when multiple nodes are wrapped in brackets and these nodes are not
+     * direct children of parent node - multiple children which are constructed using '/'.
+     */
+    @Test
+    public void parseFieldsParameterWithMultipleChildrenTest1() {
+        final String input = "services(type-of-service;instance/instance-name;instance/provider)";
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierTestServices, input);
+
+        assertNotNull(parsedFields);
+        assertEquals(parsedFields.size(), 3);
+
+        assertEquals(parsedFields.get(0).size(), 1);
+        assertTrue(parsedFields.get(0).contains(SERVICES_Q_NAME));
+
+        assertEquals(parsedFields.get(1).size(), 2);
+        assertTrue(parsedFields.get(1).containsAll(Sets.newHashSet(TYPE_OF_SERVICE_Q_NAME, INSTANCE_Q_NAME)));
+
+        assertEquals(parsedFields.get(2).size(), 2);
+        assertTrue(parsedFields.get(2).containsAll(Sets.newHashSet(INSTANCE_NAME_Q_NAME, PROVIDER_Q_NAME)));
+    }
+
+    /**
+     * Testing of fields parameter parsing when multiple nodes are wrapped in brackets and these nodes are not
+     * direct children of parent node - one of children nodes is typed using brackets, other is constructed using '/'.
+     */
+    @Test
+    public void parseFieldsParameterWithMultipleChildrenTest2() {
+        final String input = "services(type-of-service;instance(instance-name;provider))";
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierTestServices, input);
+
+        assertNotNull(parsedFields);
+        assertEquals(parsedFields.size(), 3);
+
+        assertEquals(parsedFields.get(0).size(), 1);
+        assertTrue(parsedFields.get(0).contains(SERVICES_Q_NAME));
+
+        assertEquals(parsedFields.get(1).size(), 2);
+        assertTrue(parsedFields.get(1).containsAll(Sets.newHashSet(TYPE_OF_SERVICE_Q_NAME, INSTANCE_Q_NAME)));
+
+        assertEquals(parsedFields.get(2).size(), 2);
+        assertTrue(parsedFields.get(2).containsAll(Sets.newHashSet(INSTANCE_NAME_Q_NAME, PROVIDER_Q_NAME)));
+    }
+
+    /**
+     * Testing of fields parameter parsing when multiple nodes are wrapped in brackets and these nodes are not
+     * direct children of parent node - multiple children with different parent nodes.
+     */
+    @Test
+    public void parseFieldsParameterWithMultipleChildrenTest3() {
+        final String input = "services(instance/instance-name;type-of-service;next-data/next-service)";
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierTestServices, input);
+
+        assertNotNull(parsedFields);
+        assertEquals(parsedFields.size(), 3);
+
+        assertEquals(parsedFields.get(0).size(), 1);
+        assertTrue(parsedFields.get(0).contains(SERVICES_Q_NAME));
+
+        assertEquals(parsedFields.get(1).size(), 3);
+        assertTrue(parsedFields.get(1).containsAll(
+                Sets.newHashSet(TYPE_OF_SERVICE_Q_NAME, INSTANCE_Q_NAME, NEXT_DATA_Q_NAME)));
+
+        assertEquals(parsedFields.get(2).size(), 2);
+        assertTrue(parsedFields.get(2).containsAll(
+                Sets.newHashSet(INSTANCE_NAME_Q_NAME, NEXT_SERVICE_Q_NAME)));
     }
 
     /**
@@ -208,7 +352,7 @@ public class ParserFieldsParameterTest {
         final String input = "*";
 
         try {
-            ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
+            ParserFieldsParameter.parseFieldsParameter(this.identifierJukebox, input);
             fail("Test should fail due to not expected character used in parameter input value");
         } catch (final RestconfDocumentedException e) {
             // Bad request
@@ -226,7 +370,7 @@ public class ParserFieldsParameterTest {
         final String input = "library(";
 
         try {
-            ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
+            ParserFieldsParameter.parseFieldsParameter(this.identifierJukebox, input);
             fail("Test should fail due to missing closing parenthesis");
         } catch (final RestconfDocumentedException e) {
             // Bad request
@@ -244,7 +388,7 @@ public class ParserFieldsParameterTest {
         final String input = "library(not-existing)";
 
         try {
-            ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
+            ParserFieldsParameter.parseFieldsParameter(this.identifierJukebox, input);
             fail("Test should fail due to missing child node in parent node");
         } catch (final RestconfDocumentedException e) {
             // Bad request
@@ -262,7 +406,7 @@ public class ParserFieldsParameterTest {
         final String input = "library(album);";
 
         try {
-            ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
+            ParserFieldsParameter.parseFieldsParameter(this.identifierJukebox, input);
             fail("Test should fail due to unexpected character after parenthesis");
         } catch (final RestconfDocumentedException e) {
             // Bad request
@@ -280,7 +424,7 @@ public class ParserFieldsParameterTest {
         final String input = "library(album)player";
 
         try {
-            ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
+            ParserFieldsParameter.parseFieldsParameter(this.identifierJukebox, input);
             fail("Test should fail due to missing semicolon after parenthesis");
         } catch (final RestconfDocumentedException e) {
             // Bad request
@@ -289,4 +433,6 @@ public class ParserFieldsParameterTest {
             assertEquals("Error status code is not correct", 400, e.getErrors().get(0).getErrorTag().getStatusCode());
         }
     }
+
+
 }
\ No newline at end of file
diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/test-services/test-services@2019-03-25.yang b/restconf/restconf-nb-rfc8040/src/test/resources/test-services/test-services@2019-03-25.yang
new file mode 100644 (file)
index 0000000..48507d2
--- /dev/null
@@ -0,0 +1,37 @@
+module test-services {
+    yang-version 1.1;
+    namespace tests:test-services;
+    prefix ts;
+
+    revision "2019-03-25" {
+        description
+          "Initial revision.";
+    }
+
+    container test-data {
+        list services {
+            key "type-of-service";
+            leaf type-of-service {
+                type string;
+            }
+
+            list instance {
+                key "instance-name";
+
+                leaf instance-name {
+                    type string;
+                }
+
+                leaf provider {
+                    type string;
+                }
+            }
+
+            container next-data {
+                leaf next-service {
+                    type string;
+                }
+            }
+        }
+    }
+}
\ No newline at end of file