use of org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement in project yangtools by opendaylight.
the class SchemaInferenceStack method pushFirstGrouping.
@NonNull
private GroupingEffectiveStatement pushFirstGrouping(@NonNull final QName nodeIdentifier) {
final ModuleEffectiveStatement module = getModule(nodeIdentifier);
final GroupingEffectiveStatement ret = pushGrouping(module, nodeIdentifier);
currentModule = module;
return ret;
}
use of org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement 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.GroupingEffectiveStatement 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.GroupingEffectiveStatement in project yangtools by opendaylight.
the class EffectiveUsesRefineAndConstraintsTest method refineTest.
@Test
public void refineTest() throws Exception {
final EffectiveModelContext result = StmtTestUtils.parseYangSource("/stmt-test/uses/refine-test.yang");
final ModuleEffectiveStatement module = Iterables.getOnlyElement(result.getModuleStatements().values());
final QNameModule qnameModule = module.localQNameModule();
final QName rootContainer = QName.create(qnameModule, "root-container");
final QName containerFromGrouping = QName.create(qnameModule, "container-from-grouping");
final QName listInContainer = QName.create(qnameModule, "list-in-container");
final QName choiceFromGrp = QName.create(qnameModule, "choice-from-grp");
final QName containerFromGrouping2 = QName.create(qnameModule, "container-from-grouping2");
final QName presenceContainer = QName.create(qnameModule, "presence-container");
checkRefinedList(module, rootContainer, containerFromGrouping, listInContainer);
checkRefinedChoice(module, rootContainer, containerFromGrouping, choiceFromGrp);
checkRefinedContainer(module, rootContainer, containerFromGrouping2, presenceContainer);
final GroupingEffectiveStatement grp = module.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow();
assertEquals(QName.create(qnameModule, "grp-1"), grp.argument());
checkOriginalList(grp, containerFromGrouping, listInContainer);
checkOriginalChoice(grp, containerFromGrouping, choiceFromGrp);
checkOriginalContainer(grp, containerFromGrouping2, presenceContainer);
}
Aggregations