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;
}
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);
}
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;
}
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);
}
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 + " ");
}
}
Aggregations