2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.restconf.nb.rfc8040.utils.parser;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertThrows;
13 import static org.junit.Assert.assertTrue;
14 import static org.mockito.Mockito.doReturn;
15 import static org.mockito.Mockito.when;
17 import java.util.List;
18 import java.util.Optional;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23 import org.mockito.Mock;
24 import org.mockito.junit.MockitoJUnitRunner;
25 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
26 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
27 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
28 import org.opendaylight.yangtools.yang.common.ErrorTag;
29 import org.opendaylight.yangtools.yang.common.ErrorType;
30 import org.opendaylight.yangtools.yang.common.QName;
31 import org.opendaylight.yangtools.yang.common.QNameModule;
32 import org.opendaylight.yangtools.yang.common.Revision;
33 import org.opendaylight.yangtools.yang.common.XMLNamespace;
34 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
35 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
36 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
37 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
38 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
39 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
40 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
41 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
42 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
43 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
44 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
47 * Unit test for {@link ParserFieldsParameter}.
49 @RunWith(MockitoJUnitRunner.class)
50 public class ParserFieldsParameterTest {
53 private InstanceIdentifierContext<ContainerSchemaNode> identifierJukebox;
56 private InstanceIdentifierContext<ContainerSchemaNode> identifierTestServices;
58 private static final QNameModule Q_NAME_MODULE_JUKEBOX = QNameModule.create(
59 XMLNamespace.of("http://example.com/ns/example-jukebox"), Revision.of("2015-04-04"));
60 private static final QNameModule Q_NAME_MODULE_TEST_SERVICES = QNameModule.create(
61 XMLNamespace.of("tests:test-services"), Revision.of("2019-03-25"));
62 private static final QNameModule Q_NAME_MODULE_AUGMENTED_JUKEBOX = QNameModule.create(
63 XMLNamespace.of("http://example.com/ns/augmented-jukebox"), Revision.of("2016-05-05"));
67 private ContainerSchemaNode containerJukebox;
68 private static final QName JUKEBOX_Q_NAME = QName.create(Q_NAME_MODULE_JUKEBOX, "jukebox");
72 private ContainerSchemaNode containerPlayer;
73 private static final QName PLAYER_Q_NAME = QName.create(Q_NAME_MODULE_JUKEBOX, "player");
77 private ContainerSchemaNode containerLibrary;
78 private static final QName LIBRARY_Q_NAME = QName.create(Q_NAME_MODULE_JUKEBOX, "library");
80 // container augmented library
82 private ContainerSchemaNode augmentedContainerLibrary;
83 private static final QName AUGMENTED_LIBRARY_Q_NAME = QName.create(Q_NAME_MODULE_AUGMENTED_JUKEBOX,
86 // augmentation that contains speed leaf
88 private AugmentationSchemaNode speedAugmentation;
92 private LeafSchemaNode leafSpeed;
93 private static final QName SPEED_Q_NAME = QName.create(Q_NAME_MODULE_AUGMENTED_JUKEBOX, "speed");
97 private ListSchemaNode listAlbum;
98 private static final QName ALBUM_Q_NAME = QName.create(Q_NAME_MODULE_JUKEBOX, "album");
102 private LeafSchemaNode leafName;
103 private static final QName NAME_Q_NAME = QName.create(Q_NAME_MODULE_JUKEBOX, "name");
105 // container test data
107 private ContainerSchemaNode containerTestData;
108 private static final QName TEST_DATA_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "test-data");
112 private ListSchemaNode listServices;
113 private static final QName SERVICES_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "services");
115 // leaf type-of-service
117 private LeafSchemaNode leafTypeOfService;
118 private static final QName TYPE_OF_SERVICE_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "type-of-service");
122 private ListSchemaNode listInstance;
123 private static final QName INSTANCE_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "instance");
125 // leaf instance-name
127 private LeafSchemaNode leafInstanceName;
128 private static final QName INSTANCE_NAME_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "instance-name");
132 private LeafSchemaNode leafProvider;
133 private static final QName PROVIDER_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "provider");
135 // container next-data
137 private ContainerSchemaNode containerNextData;
138 private static final QName NEXT_DATA_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "next-data");
142 private LeafSchemaNode leafNextService;
143 private static final QName NEXT_SERVICE_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "next-service");
145 // leaf-list protocols
147 private LeafListSchemaNode leafListProtocols;
148 private static final QName PROTOCOLS_Q_NAME = QName.create(Q_NAME_MODULE_TEST_SERVICES, "protocols");
151 public void setUp() throws Exception {
152 final EffectiveModelContext schemaContextJukebox =
153 YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/jukebox"));
154 initJukeboxSchemaNodes(schemaContextJukebox);
156 final EffectiveModelContext schemaContextTestServices =
157 YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/test-services"));
158 initTestServicesSchemaNodes(schemaContextTestServices);
161 private void initJukeboxSchemaNodes(final EffectiveModelContext schemaContext) {
162 when(identifierJukebox.getSchemaContext()).thenReturn(schemaContext);
163 when(containerJukebox.getQName()).thenReturn(JUKEBOX_Q_NAME);
164 when(identifierJukebox.getSchemaNode()).thenReturn(containerJukebox);
166 when(containerLibrary.getQName()).thenReturn(LIBRARY_Q_NAME);
167 when(containerJukebox.dataChildByName(LIBRARY_Q_NAME)).thenReturn(containerLibrary);
169 when(augmentedContainerLibrary.getQName()).thenReturn(AUGMENTED_LIBRARY_Q_NAME);
170 when(containerJukebox.dataChildByName(AUGMENTED_LIBRARY_Q_NAME))
171 .thenReturn(augmentedContainerLibrary);
173 when(containerPlayer.getQName()).thenReturn(PLAYER_Q_NAME);
174 when(containerJukebox.dataChildByName(PLAYER_Q_NAME)).thenReturn(containerPlayer);
176 when(listAlbum.getQName()).thenReturn(ALBUM_Q_NAME);
177 when(containerLibrary.dataChildByName(ALBUM_Q_NAME)).thenReturn(listAlbum);
179 when(leafName.getQName()).thenReturn(NAME_Q_NAME);
180 when(listAlbum.dataChildByName(NAME_Q_NAME)).thenReturn(leafName);
182 when(leafSpeed.getQName()).thenReturn(SPEED_Q_NAME);
183 when(leafSpeed.isAugmenting()).thenReturn(true);
184 when(containerPlayer.dataChildByName(SPEED_Q_NAME)).thenReturn(leafSpeed);
185 when(containerPlayer.getDataChildByName(SPEED_Q_NAME)).thenReturn(leafSpeed);
186 doReturn(List.of(leafSpeed)).when(speedAugmentation).getChildNodes();
187 doReturn(List.of(speedAugmentation)).when(containerPlayer).getAvailableAugmentations();
188 when(speedAugmentation.findDataChildByName(SPEED_Q_NAME)).thenReturn(Optional.of(leafSpeed));
191 private void initTestServicesSchemaNodes(final EffectiveModelContext schemaContext) {
192 when(identifierTestServices.getSchemaContext()).thenReturn(schemaContext);
193 when(containerTestData.getQName()).thenReturn(TEST_DATA_Q_NAME);
194 when(identifierTestServices.getSchemaNode()).thenReturn(containerTestData);
196 when(listServices.getQName()).thenReturn(SERVICES_Q_NAME);
197 when(containerTestData.dataChildByName(SERVICES_Q_NAME)).thenReturn(listServices);
199 when(leafListProtocols.getQName()).thenReturn(PROTOCOLS_Q_NAME);
200 when(containerTestData.dataChildByName(PROTOCOLS_Q_NAME)).thenReturn(leafListProtocols);
202 when(leafTypeOfService.getQName()).thenReturn(TYPE_OF_SERVICE_Q_NAME);
203 when(listServices.dataChildByName(TYPE_OF_SERVICE_Q_NAME)).thenReturn(leafTypeOfService);
205 when(listInstance.getQName()).thenReturn(INSTANCE_Q_NAME);
206 when(listServices.dataChildByName(INSTANCE_Q_NAME)).thenReturn(listInstance);
208 when(leafInstanceName.getQName()).thenReturn(INSTANCE_NAME_Q_NAME);
209 when(listInstance.dataChildByName(INSTANCE_NAME_Q_NAME)).thenReturn(leafInstanceName);
211 when(leafProvider.getQName()).thenReturn(PROVIDER_Q_NAME);
212 when(listInstance.dataChildByName(PROVIDER_Q_NAME)).thenReturn(leafProvider);
214 when(containerNextData.getQName()).thenReturn(NEXT_DATA_Q_NAME);
215 when(listServices.dataChildByName(NEXT_DATA_Q_NAME)).thenReturn(containerNextData);
217 when(leafNextService.getQName()).thenReturn(NEXT_SERVICE_Q_NAME);
218 when(containerNextData.dataChildByName(NEXT_SERVICE_Q_NAME)).thenReturn(leafNextService);
222 * Test parse fields parameter containing only one child selected.
225 public void parseFieldsParameterSimplePathTest() {
226 final String input = "library";
227 final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input);
229 assertNotNull(parsedFields);
230 assertEquals(1, parsedFields.size());
231 assertEquals(1, parsedFields.get(0).size());
232 assertTrue(parsedFields.get(0).contains(LIBRARY_Q_NAME));
236 * Test parse fields parameter containing two child nodes selected.
239 public void parseFieldsParameterDoublePathTest() {
240 final String input = "library;player";
241 final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input);
243 assertNotNull(parsedFields);
244 assertEquals(1, parsedFields.size());
245 assertEquals(2, parsedFields.get(0).size());
246 assertTrue(parsedFields.get(0).contains(LIBRARY_Q_NAME));
247 assertTrue(parsedFields.get(0).contains(PLAYER_Q_NAME));
251 * Test parse fields parameter containing sub-children selected delimited by slash.
254 public void parseFieldsParameterSubPathTest() {
255 final String input = "library/album/name";
256 final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input);
258 assertNotNull(parsedFields);
259 assertEquals(3, parsedFields.size());
261 assertEquals(1, parsedFields.get(0).size());
262 assertTrue(parsedFields.get(0).contains(LIBRARY_Q_NAME));
264 assertEquals(1, parsedFields.get(1).size());
265 assertTrue(parsedFields.get(1).contains(ALBUM_Q_NAME));
267 assertEquals(1, parsedFields.get(2).size());
268 assertTrue(parsedFields.get(2).contains(NAME_Q_NAME));
272 * Test parse fields parameter containing sub-children selected delimited by parenthesis.
275 public void parseFieldsParameterChildrenPathTest() {
276 final String input = "library(album(name))";
277 final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input);
279 assertNotNull(parsedFields);
280 assertEquals(3, parsedFields.size());
282 assertEquals(1, parsedFields.get(0).size());
283 assertTrue(parsedFields.get(0).contains(LIBRARY_Q_NAME));
285 assertEquals(1, parsedFields.get(1).size());
286 assertTrue(parsedFields.get(1).contains(ALBUM_Q_NAME));
288 assertEquals(1, parsedFields.get(2).size());
289 assertTrue(parsedFields.get(2).contains(NAME_Q_NAME));
293 * Test parse fields parameter when augmentation with different namespace is used.
296 public void parseFieldsParameterNamespaceTest() {
297 final String input = "augmented-jukebox:augmented-library";
298 final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input);
300 assertNotNull(parsedFields);
301 assertEquals(1, parsedFields.size());
303 assertEquals(1, parsedFields.get(0).size());
304 assertTrue(parsedFields.get(0).contains(AUGMENTED_LIBRARY_Q_NAME));
308 * Testing of fields parameter parsing when multiple nodes are wrapped in brackets and these nodes are not
309 * direct children of parent node - multiple children which are constructed using '/'.
312 public void parseFieldsParameterWithMultipleChildrenTest1() {
313 final String input = "services(type-of-service;instance/instance-name;instance/provider)";
314 final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierTestServices, input);
316 assertNotNull(parsedFields);
317 assertEquals(parsedFields.size(), 3);
319 assertEquals(parsedFields.get(0).size(), 1);
320 assertTrue(parsedFields.get(0).contains(SERVICES_Q_NAME));
322 assertEquals(parsedFields.get(1).size(), 2);
323 assertTrue(parsedFields.get(1).containsAll(List.of(TYPE_OF_SERVICE_Q_NAME, INSTANCE_Q_NAME)));
325 assertEquals(parsedFields.get(2).size(), 2);
326 assertTrue(parsedFields.get(2).containsAll(List.of(INSTANCE_NAME_Q_NAME, PROVIDER_Q_NAME)));
330 * Testing of fields parameter parsing when multiple nodes are wrapped in brackets and these nodes are not
331 * direct children of parent node - one of children nodes is typed using brackets, other is constructed using '/'.
334 public void parseFieldsParameterWithMultipleChildrenTest2() {
335 final String input = "services(type-of-service;instance(instance-name;provider))";
336 final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierTestServices, input);
338 assertNotNull(parsedFields);
339 assertEquals(parsedFields.size(), 3);
341 assertEquals(parsedFields.get(0).size(), 1);
342 assertTrue(parsedFields.get(0).contains(SERVICES_Q_NAME));
344 assertEquals(parsedFields.get(1).size(), 2);
345 assertTrue(parsedFields.get(1).containsAll(List.of(TYPE_OF_SERVICE_Q_NAME, INSTANCE_Q_NAME)));
347 assertEquals(parsedFields.get(2).size(), 2);
348 assertTrue(parsedFields.get(2).containsAll(List.of(INSTANCE_NAME_Q_NAME, PROVIDER_Q_NAME)));
352 * Testing of fields parameter parsing when multiple nodes are wrapped in brackets and these nodes are not
353 * direct children of parent node - multiple children with different parent nodes.
356 public void parseFieldsParameterWithMultipleChildrenTest3() {
357 final String input = "services(instance/instance-name;type-of-service;next-data/next-service)";
358 final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierTestServices, input);
360 assertNotNull(parsedFields);
361 assertEquals(parsedFields.size(), 3);
363 assertEquals(parsedFields.get(0).size(), 1);
364 assertTrue(parsedFields.get(0).contains(SERVICES_Q_NAME));
366 assertEquals(parsedFields.get(1).size(), 3);
367 assertTrue(parsedFields.get(1).containsAll(
368 List.of(TYPE_OF_SERVICE_Q_NAME, INSTANCE_Q_NAME, NEXT_DATA_Q_NAME)));
370 assertEquals(parsedFields.get(2).size(), 2);
371 assertTrue(parsedFields.get(2).containsAll(
372 List.of(INSTANCE_NAME_Q_NAME, NEXT_SERVICE_Q_NAME)));
376 * Test parse fields parameter containing not expected character.
379 public void parseFieldsParameterNotExpectedCharacterNegativeTest() {
380 final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
381 () -> ParserFieldsParameter.parseFieldsParameter(identifierJukebox, "*"));
383 assertEquals("Error type is not correct", ErrorType.PROTOCOL, ex.getErrors().get(0).getErrorType());
384 assertEquals("Error tag is not correct", ErrorTag.INVALID_VALUE, ex.getErrors().get(0).getErrorTag());
388 * Test parse fields parameter with missing closing parenthesis.
391 public void parseFieldsParameterMissingParenthesisNegativeTest() {
392 final String input = "library(";
394 final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
395 () -> ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input));
397 assertEquals("Error type is not correct", ErrorType.PROTOCOL, ex.getErrors().get(0).getErrorType());
398 assertEquals("Error tag is not correct", ErrorTag.INVALID_VALUE, ex.getErrors().get(0).getErrorTag());
402 * Test parse fields parameter when not existing child node selected.
405 public void parseFieldsParameterMissingChildNodeNegativeTest() {
406 final String input = "library(not-existing)";
408 final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
409 () -> ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input));
411 assertEquals("Error type is not correct", ErrorType.PROTOCOL, ex.getErrors().get(0).getErrorType());
412 assertEquals("Error tag is not correct", ErrorTag.INVALID_VALUE, ex.getErrors().get(0).getErrorTag());
416 * Test parse fields parameter with unexpected character after parenthesis.
419 public void parseFieldsParameterAfterParenthesisNegativeTest() {
420 final String input = "library(album);";
422 final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
423 () -> ParserFieldsParameter.parseFieldsParameter(identifierJukebox, input));
425 assertEquals("Error type is not correct", ErrorType.PROTOCOL, ex.getErrors().get(0).getErrorType());
426 assertEquals("Error tag is not correct", ErrorTag.INVALID_VALUE, ex.getErrors().get(0).getErrorTag());
430 * Test parse fields parameter with missing semicolon after parenthesis.
433 public void parseFieldsParameterMissingSemicolonNegativeTest() {
434 final String input = "library(album)player";
436 final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
437 () -> ParserFieldsParameter.parseFieldsParameter(this.identifierJukebox, input));
439 assertEquals("Error type is not correct", ErrorType.PROTOCOL, ex.getErrors().get(0).getErrorType());
440 assertEquals("Error tag is not correct", ErrorTag.INVALID_VALUE, ex.getErrors().get(0).getErrorTag());
444 public void parseTopLevelContainerToPathTest() {
445 final String input = "library";
446 final List<YangInstanceIdentifier> parsedFields = ParserFieldsParameter.parseFieldsPaths(
447 identifierJukebox, input);
449 assertNotNull(parsedFields);
450 assertEquals(1, parsedFields.size());
451 final List<PathArgument> pathArguments = parsedFields.get(0).getPathArguments();
452 assertEquals(1, pathArguments.size());
453 assertEquals(LIBRARY_Q_NAME, pathArguments.get(0).getNodeType());
457 public void parseTwoTopLevelContainersToPathsTest() {
458 final String input = "library;player";
459 final List<YangInstanceIdentifier> parsedFields = ParserFieldsParameter.parseFieldsPaths(
460 identifierJukebox, input);
462 assertNotNull(parsedFields);
463 assertEquals(2, parsedFields.size());
465 final Optional<YangInstanceIdentifier> libraryPath = findPath(parsedFields, LIBRARY_Q_NAME);
466 assertTrue(libraryPath.isPresent());
467 assertEquals(1, libraryPath.get().getPathArguments().size());
469 final Optional<YangInstanceIdentifier> playerPath = findPath(parsedFields, PLAYER_Q_NAME);
470 assertTrue(playerPath.isPresent());
471 assertEquals(1, libraryPath.get().getPathArguments().size());
475 public void parseNestedLeafToPathTest() {
476 final String input = "library/album/name";
477 final List<YangInstanceIdentifier> parsedFields = ParserFieldsParameter.parseFieldsPaths(
478 identifierJukebox, input);
480 assertEquals(1, parsedFields.size());
481 final List<PathArgument> pathArguments = parsedFields.get(0).getPathArguments();
482 assertEquals(3, pathArguments.size());
484 assertEquals(LIBRARY_Q_NAME, pathArguments.get(0).getNodeType());
485 assertEquals(ALBUM_Q_NAME, pathArguments.get(1).getNodeType());
486 assertEquals(NAME_Q_NAME, pathArguments.get(2).getNodeType());
490 public void parseAugmentedLeafToPathTest() {
491 final String input = "player/augmented-jukebox:speed";
492 final List<YangInstanceIdentifier> parsedFields = ParserFieldsParameter.parseFieldsPaths(
493 identifierJukebox, input);
495 assertEquals(1, parsedFields.size());
496 final List<PathArgument> pathArguments = parsedFields.get(0).getPathArguments();
498 assertEquals(3, pathArguments.size());
499 assertEquals(PLAYER_Q_NAME, pathArguments.get(0).getNodeType());
500 assertTrue(pathArguments.get(1) instanceof AugmentationIdentifier);
501 assertEquals(SPEED_Q_NAME, pathArguments.get(2).getNodeType());
505 public void parseMultipleFieldsOnDifferentLevelsToPathsTest() {
506 final String input = "services(type-of-service;instance/instance-name;instance/provider)";
507 final List<YangInstanceIdentifier> parsedFields = ParserFieldsParameter.parseFieldsPaths(
508 identifierTestServices, input);
510 assertEquals(3, parsedFields.size());
512 final Optional<YangInstanceIdentifier> tosPath = findPath(parsedFields, TYPE_OF_SERVICE_Q_NAME);
513 assertTrue(tosPath.isPresent());
514 assertEquals(2, tosPath.get().getPathArguments().size());
516 final Optional<YangInstanceIdentifier> instanceNamePath = findPath(parsedFields, INSTANCE_NAME_Q_NAME);
517 assertTrue(instanceNamePath.isPresent());
518 assertEquals(3, instanceNamePath.get().getPathArguments().size());
520 final Optional<YangInstanceIdentifier> providerPath = findPath(parsedFields, PROVIDER_Q_NAME);
521 assertTrue(providerPath.isPresent());
522 assertEquals(3, providerPath.get().getPathArguments().size());
526 public void parseListFieldUnderListToPathTest() {
527 final String input = "services/instance";
528 final List<YangInstanceIdentifier> parsedFields = ParserFieldsParameter.parseFieldsPaths(
529 identifierTestServices, input);
531 assertEquals(1, parsedFields.size());
532 final List<PathArgument> pathArguments = parsedFields.get(0).getPathArguments();
533 assertEquals(2, pathArguments.size());
535 assertEquals(SERVICES_Q_NAME, pathArguments.get(0).getNodeType());
536 assertTrue(pathArguments.get(0) instanceof NodeIdentifier);
537 assertEquals(INSTANCE_Q_NAME, pathArguments.get(1).getNodeType());
538 assertTrue(pathArguments.get(1) instanceof NodeIdentifier);
542 public void parseLeafListFieldToPathTest() {
543 final String input = "protocols";
544 final List<YangInstanceIdentifier> parsedFields = ParserFieldsParameter.parseFieldsPaths(
545 identifierTestServices, input);
547 assertEquals(1, parsedFields.size());
548 final List<PathArgument> pathArguments = parsedFields.get(0).getPathArguments();
549 assertEquals(1, pathArguments.size());
550 assertTrue(pathArguments.get(0) instanceof NodeIdentifier);
551 assertEquals(PROTOCOLS_Q_NAME, pathArguments.get(0).getNodeType());
554 private static Optional<YangInstanceIdentifier> findPath(final List<YangInstanceIdentifier> paths,
555 final QName lastPathArg) {
556 return paths.stream()
557 .filter(path -> lastPathArg.equals(path.getLastPathArgument().getNodeType()))