use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.
the class YT1208Test method testLeafListStatementReuse.
@Test
public void testLeafListStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/leaflist.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
final NotificationEffectiveStatement notif = module.findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
final LeafListEffectiveStatement grpBar = notif.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow();
final LeafListEffectiveStatement contBar = notif.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow();
assertSame(contBar, grpBar);
}
use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.
the class YT1208Test method testAugmentStatementReuse.
@Test
public void testAugmentStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/augment.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
final NotificationEffectiveStatement notif = module.findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
final AugmentEffectiveStatement grpAug = notif.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(AugmentEffectiveStatement.class).orElseThrow();
final AugmentEffectiveStatement contAug = notif.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(AugmentEffectiveStatement.class).orElseThrow();
assertSame(contAug, grpAug);
}
use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.
the class YT1212Test method testContainerStatementReuse.
@Test
public void testContainerStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1212/container.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
final NotificationEffectiveStatement notif = module.findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
final List<GroupingEffectiveStatement> groupings = notif.effectiveSubstatements().stream().filter(GroupingEffectiveStatement.class::isInstance).map(GroupingEffectiveStatement.class::cast).collect(Collectors.toList());
assertEquals(2, groupings.size());
final GroupingEffectiveStatement grp = groupings.get(0);
assertEquals("grp", grp.argument().getLocalName());
final GroupingEffectiveStatement barGrp = groupings.get(1);
assertEquals("bar", barGrp.argument().getLocalName());
final ContainerEffectiveStatement bar = notif.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow();
// Container needs to be reused
assertSame(bar.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow(), barGrp.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow());
}
use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.
the class Bug4610Test method findContainer.
private static ContainerEffectiveStatement findContainer(final EffectiveModelContext context, final QName grouping, final QName container) {
final ModuleEffectiveStatement module = context.getModuleStatement(grouping.getModule());
final GroupingEffectiveStatement grp = module.streamEffectiveSubstatements(GroupingEffectiveStatement.class).filter(stmt -> grouping.equals(stmt.argument())).findAny().orElseThrow();
final SchemaTreeEffectiveStatement<?> node = grp.findSchemaTreeNode(container).orElse(null);
assertThat(node, instanceOf(ContainerEffectiveStatement.class));
return (ContainerEffectiveStatement) node;
}
use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.
the class Bug7879Test method test.
@Test
public void test() throws Exception {
final ModuleEffectiveStatement module = assertEffectiveModelDir("/bugs/bug7879").getModuleStatement(qn("my-model"));
final SchemaTreeEffectiveStatement<?> container = module.findSchemaTreeNode(qn("my-alarm"), qn("my-content"), qn("my-event-container")).orElse(null);
assertThat(container, instanceOf(ContainerSchemaNode.class));
final SchemaTreeEffectiveStatement<?> leaf = module.findSchemaTreeNode(qn("my-alarm"), qn("my-content"), qn("my-event-value")).orElse(null);
assertThat(leaf, instanceOf(LeafSchemaNode.class));
assertEquals(Optional.of("new description"), ((LeafSchemaNode) leaf).getDescription());
}
Aggregations