Search in sources :

Example 1 with Submodule

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

the class ModuleDependencySort method allImports.

private static Collection<? extends ModuleImport> allImports(final Module mod) {
    if (mod.getSubmodules().isEmpty()) {
        return mod.getImports();
    }
    final Collection<ModuleImport> concat = new LinkedHashSet<>();
    concat.addAll(mod.getImports());
    for (Submodule sub : mod.getSubmodules()) {
        concat.addAll(sub.getImports());
    }
    return concat;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ModuleImport(org.opendaylight.yangtools.yang.model.api.ModuleImport) Submodule(org.opendaylight.yangtools.yang.model.api.Submodule)

Example 2 with Submodule

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

the class SchemaContextProxyTest method testBasicSubmodule.

/*
     * CFG(R)
     * |   \
     * |    \
     * |    M2 -> M3
     * |
     * M41(S) => M4
     */
@Test
public void testBasicSubmodule() {
    Module moduleConfig = mockModule(CONFIG_NAME);
    Module module2 = mockModule(MODULE2_NAME);
    Module module3 = mockModule(MODULE3_NAME);
    Module module4 = mockModule(MODULE4_NAME);
    Submodule module41 = mockSubmodule(MODULE41_NAME);
    mockSubmodules(module4, module41);
    mockModuleImport(module2, moduleConfig, module3);
    mockModuleImport(module41, moduleConfig);
    SchemaContext schemaContext = mockSchema(moduleConfig, module2, module3, module4);
    FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleConfig);
    assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module3, module4);
}
Also used : Submodule(org.opendaylight.yangtools.yang.model.api.Submodule) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) AbstractSchemaContext(org.opendaylight.yangtools.yang.model.spi.AbstractSchemaContext) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module) Test(org.junit.Test)

Example 3 with Submodule

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

the class SchemaContextProxyTest method mockSubmodule.

private static Submodule mockSubmodule(final String name) {
    Submodule mockedModule = mock(Submodule.class);
    mockModuleLike(mockedModule, name);
    return mockedModule;
}
Also used : Submodule(org.opendaylight.yangtools.yang.model.api.Submodule)

Example 4 with Submodule

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

the class Bug3799Test method test.

@Test
public void test() throws Exception {
    SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug3799");
    assertNotNull(schema);
    Collection<? extends Module> modules = schema.getModules();
    assertNotNull(modules);
    assertEquals(1, modules.size());
    Module testModule = modules.iterator().next();
    Collection<? extends Submodule> subModules = testModule.getSubmodules();
    assertNotNull(subModules);
    assertEquals(1, subModules.size());
    Submodule testSubmodule = subModules.iterator().next();
    Collection<? extends NotificationDefinition> notifications = testSubmodule.getNotifications();
    assertNotNull(notifications);
    assertEquals(1, notifications.size());
    NotificationDefinition bazNotification = notifications.iterator().next();
    Collection<? extends DataSchemaNode> childNodes = bazNotification.getChildNodes();
    assertNotNull(childNodes);
    assertEquals(1, childNodes.size());
    DataSchemaNode child = childNodes.iterator().next();
    assertTrue(child instanceof LeafSchemaNode);
    LeafSchemaNode leafBar = (LeafSchemaNode) child;
    String bar = leafBar.getQName().getLocalName();
    assertEquals("bar", bar);
}
Also used : DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) NotificationDefinition(org.opendaylight.yangtools.yang.model.api.NotificationDefinition) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) Submodule(org.opendaylight.yangtools.yang.model.api.Submodule) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) Module(org.opendaylight.yangtools.yang.model.api.Module) Test(org.junit.Test)

Example 5 with Submodule

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

the class EffectiveModulesAndSubmodulesTest method printReferences.

private static void printReferences(final ModuleLike module, final boolean isSubmodule, final String indent) {
    LOG.debug("{}{} {}", indent, isSubmodule ? "Submodule" : "Module", module.getName());
    for (final Submodule submodule : module.getSubmodules()) {
        printReferences(submodule, true, indent + "      ");
        printChilds(submodule.getChildNodes(), indent + "            ");
    }
}
Also used : Submodule(org.opendaylight.yangtools.yang.model.api.Submodule)

Aggregations

Submodule (org.opendaylight.yangtools.yang.model.api.Submodule)14 Module (org.opendaylight.yangtools.yang.model.api.Module)9 Test (org.junit.Test)7 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)5 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)3 HashSet (java.util.HashSet)2 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)2 ModuleImport (org.opendaylight.yangtools.yang.model.api.ModuleImport)2 SourceIdentifier (org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier)2 YangTextSchemaSource (org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 ExecutionException (java.util.concurrent.ExecutionException)1 BasicCapability (org.opendaylight.netconf.api.capability.BasicCapability)1 Capability (org.opendaylight.netconf.api.capability.Capability)1 YangModuleCapability (org.opendaylight.netconf.api.capability.YangModuleCapability)1 SchemaSourceCache (org.opendaylight.netconf.test.tool.schemacache.SchemaSourceCache)1 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)1 LeafSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafSchemaNode)1 NotificationDefinition (org.opendaylight.yangtools.yang.model.api.NotificationDefinition)1