Use case arrows in mergeIntoModifiedNode()
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug5101Test.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.stmt;
9
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;
13
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;
21
22 class Bug5101Test extends AbstractYangTest {
23     @Test
24     void test() {
25         final var module = assertEffectiveModel("/bugs/bug5101.yang")
26             .getModuleStatement(QName.create("foo", "2016-01-29", "foo"));
27
28         final var myContainerInGrouping = module
29             .findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow()
30             .findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow();
31         assertEquals(Status.DEPRECATED, assertInstanceOf(ContainerSchemaNode.class, myContainerInGrouping).getStatus());
32
33         // This relies on schema definition order
34         final Iterator<ContainerEffectiveStatement> containers =
35             module.streamEffectiveSubstatements(ContainerEffectiveStatement.class).toList().iterator();
36
37         final ContainerEffectiveStatement root = containers.next();
38         assertEquals(Status.CURRENT, assertInstanceOf(ContainerSchemaNode.class, root).getStatus());
39
40         final ContainerEffectiveStatement rootMyContainer = root
41             .streamEffectiveSubstatements(ContainerEffectiveStatement.class)
42             .findAny().orElse(null);
43         assertEquals(Status.DEPRECATED, assertInstanceOf(ContainerSchemaNode.class, rootMyContainer).getStatus());
44
45         final ContainerEffectiveStatement myContainer = containers.next();
46         assertEquals(Status.DEPRECATED, assertInstanceOf(ContainerSchemaNode.class, myContainer).getStatus());
47         assertFalse(containers.hasNext());
48     }
49 }