2 * Copyright (c) 2017 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;
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.assertNotNull;
14 import java.util.Optional;
16 import org.junit.jupiter.api.Test;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureEffectiveStatement;
21 class Bug8922Test extends AbstractYangTest {
22 private static final QName MY_CON = QName.create("foo", "my-con");
23 private static final QName TARGET = QName.create("foo", "target");
26 void testAllFeaturesSupported() {
27 final var context = assertEffectiveModel("/bugs/bug8922/foo.yang");
28 final var findNode = assertInstanceOf(ContainerSchemaNode.class,
29 context.findDataTreeChild(TARGET, MY_CON).orElseThrow());
30 assertEquals(Optional.of("New description"), findNode.getDescription());
32 assertEquals(1, context.findModuleStatements("foo").iterator().next()
33 .streamEffectiveSubstatements(FeatureEffectiveStatement.class).count());
37 void testNoFeatureSupported() throws Exception {
38 final var context = StmtTestUtils.parseYangSource("/bugs/bug8922/foo.yang", Set.of());
39 assertNotNull(context);
40 assertEquals(Optional.empty(), context.findDataTreeChild(TARGET, MY_CON));
41 assertEquals(Set.of(), context.getAvailableAugmentations());
43 assertEquals(0, context.findModuleStatements("foo").iterator().next()
44 .streamEffectiveSubstatements(FeatureEffectiveStatement.class).count());