Search in sources :

Example 16 with Module

use of org.opendaylight.yangtools.yang.model.api.Module in project controller by opendaylight.

the class ModuleMXBeanEntryNameConflictTest method testNameConflicts.

@Ignore
@Test
public void testNameConflicts() {
    for (final String moduleName : testedModules) {
        final Module testedModule = loadYangs(moduleName, moduleName);
        try {
            LOG.debug("Testing {}", moduleName);
            ModuleMXBeanEntry.create(testedModule, new HashMap<>(), this.context, new TypeProviderWrapper(new TypeProviderImpl(this.context)), PACKAGE_NAME);
            fail(moduleName + " did not cause a name conflict and should");
        } catch (final NameConflictException e) {
            assertEquals(this.testedYangModulesToExpectedConflictingName.get(moduleName), e.getConflictingName());
        }
    }
}
Also used : Module(org.opendaylight.yangtools.yang.model.api.Module) TypeProviderImpl(org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl) NameConflictException(org.opendaylight.controller.config.yangjmxgenerator.plugin.util.NameConflictException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with Module

use of org.opendaylight.yangtools.yang.model.api.Module in project controller by opendaylight.

the class RuntimeBeanEntry method findQNameFromGrouping.

/**
 * Find "proper" qname of unknown node in case it comes from a grouping
 */
private static QName findQNameFromGrouping(final DataNodeContainer subtree, final SchemaContext ctx, final UnknownSchemaNode unknownSchemaNode, final String localIdentityName) {
    QName identityQName = null;
    for (UsesNode usesNode : subtree.getUses()) {
        SchemaNode dataChildByName = SchemaContextUtil.findDataSchemaNode(ctx, usesNode.getGroupingPath());
        Module m = SchemaContextUtil.findParentModule(ctx, dataChildByName);
        List<UnknownSchemaNode> unknownSchemaNodes = dataChildByName.getUnknownSchemaNodes();
        if (Collections2.transform(unknownSchemaNodes, UNKNOWN_NODE_TO_STRING).contains(UNKNOWN_NODE_TO_STRING.apply(unknownSchemaNode))) {
            identityQName = QName.create(dataChildByName.getQName(), localIdentityName);
        }
    }
    return identityQName;
}
Also used : LeafListSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode) UnknownSchemaNode(org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode) ListSchemaNode(org.opendaylight.yangtools.yang.model.api.ListSchemaNode) ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) SchemaNode(org.opendaylight.yangtools.yang.model.api.SchemaNode) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) QName(org.opendaylight.yangtools.yang.common.QName) Module(org.opendaylight.yangtools.yang.model.api.Module) UnknownSchemaNode(org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode) UsesNode(org.opendaylight.yangtools.yang.model.api.UsesNode)

Example 18 with Module

use of org.opendaylight.yangtools.yang.model.api.Module in project controller by opendaylight.

the class DOMRpcRoutingTable method findRpcDefinition.

private static RpcDefinition findRpcDefinition(final SchemaContext context, final SchemaPath schemaPath) {
    if (context != null) {
        final QName qname = schemaPath.getPathFromRoot().iterator().next();
        final Module module = context.findModule(qname.getModule()).orElse(null);
        if (module != null && module.getRpcs() != null) {
            for (RpcDefinition rpc : module.getRpcs()) {
                if (qname.equals(rpc.getQName())) {
                    return rpc;
                }
            }
        }
    }
    return null;
}
Also used : RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) QName(org.opendaylight.yangtools.yang.common.QName) Module(org.opendaylight.yangtools.yang.model.api.Module)

Aggregations

Module (org.opendaylight.yangtools.yang.model.api.Module)18 QName (org.opendaylight.yangtools.yang.common.QName)5 RpcDefinition (org.opendaylight.yangtools.yang.model.api.RpcDefinition)5 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)4 HashMap (java.util.HashMap)3 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)3 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Capability (org.opendaylight.controller.config.util.capability.Capability)2 YangModuleCapability (org.opendaylight.controller.config.util.capability.YangModuleCapability)2 TypeProviderImpl (org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl)2 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)2 IdentitySchemaNode (org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode)2 LeafListSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode)2 LeafSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafSchemaNode)2 ListSchemaNode (org.opendaylight.yangtools.yang.model.api.ListSchemaNode)2 SchemaNode (org.opendaylight.yangtools.yang.model.api.SchemaNode)2 SchemaPath (org.opendaylight.yangtools.yang.model.api.SchemaPath)2