use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.
the class YT1209Test method testWhenStatementReuse.
@Test
public void testWhenStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1209/when.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
final LeafEffectiveStatement grpFoo = module.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(LeafEffectiveStatement.class).orElseThrow();
final LeafEffectiveStatement foo = module.findFirstEffectiveSubstatement(LeafEffectiveStatement.class).orElseThrow();
// The statements should not be the same due SchemaPath being part of LeafSchemaNode
assertNotSame(foo, grpFoo);
// The statements are instantiated in the same module, hence they should have the same argument
assertSame(foo.argument(), grpFoo.argument());
// The statements' when substatement should be reused
assertSame(foo.findFirstEffectiveSubstatement(WhenEffectiveStatement.class).orElseThrow(), grpFoo.findFirstEffectiveSubstatement(WhenEffectiveStatement.class).orElseThrow());
}
use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.
the class YT1208Test method testGroupingStatementReuse.
@Test
public void testGroupingStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/grouping.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
final NotificationEffectiveStatement notif = module.findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
final GroupingEffectiveStatement grpBar = notif.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow();
final GroupingEffectiveStatement contBar = notif.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow();
assertSame(contBar, grpBar);
}
use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.
the class YT1208Test method testChoiceStatementReuse.
@Test
public void testChoiceStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/choice.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
final NotificationEffectiveStatement notif = module.findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
final ChoiceEffectiveStatement grpBar = notif.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ChoiceEffectiveStatement.class).orElseThrow();
final ChoiceEffectiveStatement contBar = notif.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ChoiceEffectiveStatement.class).orElseThrow();
assertSame(contBar, grpBar);
}
use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.
the class YT1208Test method testUsesStatementReuse.
@Test
public void testUsesStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/uses.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
assertNotNull(module);
final List<GroupingEffectiveStatement> groupings = module.streamEffectiveSubstatements(GroupingEffectiveStatement.class).collect(Collectors.toList());
assertEquals(2, groupings.size());
final ContainerEffectiveStatement grpFoo = groupings.get(1).findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow();
final ContainerEffectiveStatement foo = module.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow();
assertNotSame(foo, grpFoo);
assertSame(foo.findFirstEffectiveSubstatement(UsesEffectiveStatement.class).orElseThrow(), grpFoo.findFirstEffectiveSubstatement(UsesEffectiveStatement.class).orElseThrow());
}
use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.
the class YT1208Test method testListStatementReuse.
@Test
public void testListStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/list.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
final NotificationEffectiveStatement notif = module.findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
final ListEffectiveStatement grpBar = notif.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ListEffectiveStatement.class).orElseThrow();
final ListEffectiveStatement contBar = notif.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ListEffectiveStatement.class).orElseThrow();
assertSame(contBar, grpBar);
}
Aggregations