Search in sources :

Example 6 with GroupingEffectiveStatement

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;
}
Also used : GroupingEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) NonNull(org.eclipse.jdt.annotation.NonNull) Objects.requireNonNull(java.util.Objects.requireNonNull)

Example 7 with GroupingEffectiveStatement

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);
}
Also used : ContainerEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement) GroupingEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement) NotificationEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) Test(org.junit.Test)

Example 8 with GroupingEffectiveStatement

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());
}
Also used : ContainerEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement) GroupingEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) Test(org.junit.Test)

Example 9 with GroupingEffectiveStatement

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);
}
Also used : QName(org.opendaylight.yangtools.yang.common.QName) GroupingEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) Test(org.junit.Test)

Aggregations

GroupingEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement)9 ModuleEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement)7 Test (org.junit.Test)6 ContainerEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement)4 Objects.requireNonNull (java.util.Objects.requireNonNull)2 NonNull (org.eclipse.jdt.annotation.NonNull)2 NotificationEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement)2 ContextInstanceEffectiveStatement (org.opendaylight.yangtools.odlext.model.api.ContextInstanceEffectiveStatement)1 ContextReferenceEffectiveStatement (org.opendaylight.yangtools.odlext.model.api.ContextReferenceEffectiveStatement)1 QName (org.opendaylight.yangtools.yang.common.QName)1 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)1 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)1 LeafEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement)1 LeafListEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement)1 ListEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ListEffectiveStatement)1