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;
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertFalse;
12 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
14 import java.util.Iterator;
15 import org.junit.jupiter.api.Test;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.Status;
19 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
22 class Bug5101Test extends AbstractYangTest {
24 void test() throws Exception {
25 final var module = assertEffectiveModel("/bugs/bug5101.yang")
26 .getModuleStatement(QName.create("foo", "2016-01-29", "foo"));
28 final var myContainerInGrouping = module
29 .findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow()
30 .findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow();
31 assertEquals(Status.DEPRECATED, assertInstanceOf(ContainerSchemaNode.class, myContainerInGrouping).getStatus());
33 // This relies on schema definition order
34 final Iterator<ContainerEffectiveStatement> containers =
35 module.streamEffectiveSubstatements(ContainerEffectiveStatement.class).toList().iterator();
37 final ContainerEffectiveStatement root = containers.next();
38 assertEquals(Status.CURRENT, assertInstanceOf(ContainerSchemaNode.class, root).getStatus());
40 final ContainerEffectiveStatement rootMyContainer = root
41 .streamEffectiveSubstatements(ContainerEffectiveStatement.class)
42 .findAny().orElse(null);
43 assertEquals(Status.DEPRECATED, assertInstanceOf(ContainerSchemaNode.class, rootMyContainer).getStatus());
45 final ContainerEffectiveStatement myContainer = containers.next();
46 assertEquals(Status.DEPRECATED, assertInstanceOf(ContainerSchemaNode.class, myContainer).getStatus());
47 assertFalse(containers.hasNext());