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.yangtools.yang.stmt.yin;
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
12 import static org.junit.jupiter.api.Assertions.assertTrue;
14 import java.util.Optional;
15 import org.junit.jupiter.api.Test;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
19 class YinFileGroupingStmtTest extends AbstractYinModulesTest {
22 final var testModule = context.findModules("config").iterator().next();
23 final var groupings = testModule.getGroupings();
24 assertEquals(1, groupings.size());
26 final var groupingsIterator = groupings.iterator();
27 final var grouping = groupingsIterator.next();
28 assertEquals("service-ref", grouping.getQName().getLocalName());
29 assertEquals(Optional.of("""
30 Type of references to a particular service instance. This type
31 can be used when defining module configuration to refer to a
32 particular service instance. Containers using this grouping
33 should not define anything else. The run-time implementation
34 is expected to inject a reference to the service as the value
35 of the container."""), grouping.getDescription());
37 final var children = grouping.getChildNodes();
38 assertEquals(2, children.size());
40 final var leaf1 = assertInstanceOf(LeafSchemaNode.class,
41 grouping.getDataChildByName(QName.create(testModule.getQNameModule(), "type")));
42 assertTrue(leaf1.isMandatory());
44 final var leaf2 = assertInstanceOf(LeafSchemaNode.class,
45 grouping.getDataChildByName(QName.create(testModule.getQNameModule(), "name")));
46 assertTrue(leaf2.isMandatory());