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.hamcrest.CoreMatchers.instanceOf;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertTrue;
16 import com.google.common.collect.ImmutableSet;
17 import java.util.Optional;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureEffectiveStatement;
23 public class Bug8922Test {
24 private static final QName MY_CON = QName.create("foo", "my-con");
25 private static final QName TARGET = QName.create("foo", "target");
28 public void testAllFeaturesSupported() throws Exception {
29 final var context = StmtTestUtils.parseYangSource("/bugs/bug8922/foo.yang");
30 assertNotNull(context);
31 final var findNode = context.findDataTreeChild(TARGET, MY_CON).get();
32 assertThat(findNode, instanceOf(ContainerSchemaNode.class));
33 assertEquals(Optional.of("New description"), findNode.getDescription());
35 assertEquals(1, context.findModuleStatements("foo").iterator().next()
36 .streamEffectiveSubstatements(FeatureEffectiveStatement.class).count());
40 public void testNoFeatureSupported() throws Exception {
41 final var context = StmtTestUtils.parseYangSource("/bugs/bug8922/foo.yang", ImmutableSet.of());
42 assertNotNull(context);
43 assertEquals(Optional.empty(), context.findDataTreeChild(TARGET, MY_CON));
44 assertTrue(context.getAvailableAugmentations().isEmpty());
46 assertEquals(0, context.findModuleStatements("foo").iterator().next()
47 .streamEffectiveSubstatements(FeatureEffectiveStatement.class).count());