2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.Assert.assertNotNull;
11 import static org.junit.Assert.assertSame;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QNameModule;
16 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
22 public class YT1208Test {
24 public void testLeafStatementReuse() throws Exception {
25 final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/leaf.yang")
26 .getModuleStatements()
27 .get(QNameModule.create(URI.create("foo")));
28 assertNotNull(module);
30 final NotificationEffectiveStatement notif = module
31 .findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
33 final LeafEffectiveStatement grpBar = notif
34 .findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow()
35 .findFirstEffectiveSubstatement(LeafEffectiveStatement.class).orElseThrow();
36 final LeafEffectiveStatement contBar = notif
37 .findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow()
38 .findFirstEffectiveSubstatement(LeafEffectiveStatement.class).orElseThrow();
40 assertSame(contBar, grpBar);