use of org.opendaylight.yangtools.yang.model.api.GroupingDefinition in project yangtools by opendaylight.
the class SchemaInferenceStackTest method findDataSchemaNodeTest2.
@Test
public void findDataSchemaNodeTest2() {
final QName myLeafInGrouping2 = QName.create(myModule.getQNameModule(), "my-leaf-in-gouping2");
final PathExpression expr = mock(PathExpression.class);
doReturn(true).when(expr).isAbsolute();
doReturn(new LocationPathSteps(YangLocationPath.relative(YangXPathAxis.CHILD.asStep(myLeafInGrouping2)))).when(expr).getSteps();
final GroupingDefinition grouping = getGroupingByName(myModule, "my-grouping");
final SchemaInferenceStack stack = SchemaInferenceStack.of(context);
assertSame(grouping, stack.enterGrouping(grouping.getQName()));
assertEquals(grouping.getDataChildByName(myLeafInGrouping2), stack.resolvePathExpression(expr));
}
use of org.opendaylight.yangtools.yang.model.api.GroupingDefinition in project yangtools by opendaylight.
the class YT1050Test method before.
@Before
public void before() {
context = YangParserTestUtils.parseYangResource("/yt1050.yang");
module = context.getModules().iterator().next();
final ListSchemaNode grpUses = (ListSchemaNode) module.findDataChildByName(GRP_USES).get();
primaryType = (LeafSchemaNode) grpUses.findDataChildByName(TYPE).get();
final GroupingDefinition grp = module.getGroupings().iterator().next();
secondaryType = (LeafSchemaNode) ((ListSchemaNode) grp.findDataChildByName(SECONDARY).get()).findDataChildByName(TYPE).get();
}
use of org.opendaylight.yangtools.yang.model.api.GroupingDefinition in project yangtools by opendaylight.
the class SchemaContextProxyTest method testGetGroupings.
@Test
public void testGetGroupings() {
final Module moduleConfig = mockModule(CONFIG_NAME);
final SchemaContext schemaContext = mockSchema(moduleConfig);
final FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, new HashSet<>(), moduleConfig);
final GroupingDefinition mockedGrouping = mock(GroupingDefinition.class);
final Set<GroupingDefinition> groupings = Collections.singleton(mockedGrouping);
doReturn(groupings).when(moduleConfig).getGroupings();
final Collection<? extends GroupingDefinition> schemaContextProxyGroupings = filteringSchemaContextProxy.getGroupings();
assertTrue(schemaContextProxyGroupings.contains(mockedGrouping));
}
use of org.opendaylight.yangtools.yang.model.api.GroupingDefinition in project yangtools by opendaylight.
the class UsesStatementSupport method createEffective.
@Override
protected UsesEffectiveStatement createEffective(final Current<QName, UsesStatement> stmt, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
final EffectiveStatement<?, ?> source = verifyNotNull(stmt.getFromNamespace(SourceGroupingNamespace.class, Empty.value())).buildEffective();
verify(source instanceof GroupingDefinition, "Unexpected source %s", source);
final GroupingDefinition sourceGrouping = (GroupingDefinition) source;
final int flags = EffectiveStmtUtils.historyAndStatusFlags(stmt.history(), substatements);
final QName argument = stmt.getArgument();
final UsesStatement declared = stmt.declared();
if (substatements.isEmpty()) {
return argument.equals(declared.argument()) ? new EmptyLocalUsesEffectiveStatement(declared, sourceGrouping, flags) : new SimpleCopiedUsesEffectiveStatement(declared, argument, sourceGrouping, flags);
}
if (declared.argument().equals(argument)) {
return new RegularLocalUsesEffectiveStatement(declared, sourceGrouping, flags, substatements);
}
if (findFirstStatement(substatements, RefineEffectiveStatement.class) == null) {
return new SimpleCopiedUsesEffectiveStatement(declared, argument, sourceGrouping, flags, substatements);
}
return new FullCopiedUsesEffectiveStatement(declared, argument, sourceGrouping, flags, substatements);
}
use of org.opendaylight.yangtools.yang.model.api.GroupingDefinition in project yangtools by opendaylight.
the class EffectiveBuildTest method extensionsTest.
@Test
public void extensionsTest() throws ReactorException {
SchemaContext result = RFC7950Reactors.defaultReactor().newBuild().addSource(YANG_EXT).buildEffective();
assertNotNull(result);
Collection<? extends GroupingDefinition> groupings = result.getGroupings();
assertEquals(1, groupings.size());
GroupingDefinition grp = groupings.iterator().next();
Collection<? extends DataSchemaNode> childNodes = grp.getChildNodes();
assertEquals(1, childNodes.size());
DataSchemaNode child = childNodes.iterator().next();
assertTrue(child instanceof LeafSchemaNode);
LeafSchemaNode leaf = (LeafSchemaNode) child;
assertNotNull(leaf.getType());
}
Aggregations