Search in sources :

Example 6 with Deviation

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

the class EffectiveModuleTest method effectiveBuildTest.

@Test
public void effectiveBuildTest() throws Exception {
    final Module rootModule = TestUtils.parseYangSource("/semantic-statement-parser/effective-module/root.yang", "/semantic-statement-parser/effective-module/imported.yang", "/semantic-statement-parser/effective-module/submod.yang").findModules("root").iterator().next();
    assertNotNull(rootModule);
    assertEquals("root-pref", rootModule.getPrefix());
    assertEquals(YangVersion.VERSION_1, rootModule.getYangVersion());
    assertEquals(Optional.of("cisco"), rootModule.getOrganization());
    assertEquals(Optional.of("cisco email"), rootModule.getContact());
    final ContainerSchemaNode contSchemaNode = (ContainerSchemaNode) rootModule.getDataChildByName(CONT);
    assertNotNull(contSchemaNode);
    final Collection<? extends AugmentationSchemaNode> augmentations = rootModule.getAugmentations();
    assertEquals(1, augmentations.size());
    assertEquals(Absolute.of(CONT), augmentations.iterator().next().getTargetPath());
    final Collection<? extends ModuleImport> imports = rootModule.getImports();
    assertEquals(1, imports.size());
    final ModuleImport importStmt = imports.iterator().next();
    assertNotNull(importStmt);
    assertEquals("imported", importStmt.getModuleName());
    assertEquals(Optional.of(REVISION), importStmt.getRevision());
    assertEquals("imp-pref", importStmt.getPrefix());
    final Collection<? extends Submodule> submodules = rootModule.getSubmodules();
    assertEquals(1, submodules.size());
    assertEquals("submod", submodules.iterator().next().getName());
    final Collection<? extends NotificationDefinition> notifications = rootModule.getNotifications();
    assertEquals(1, notifications.size());
    assertEquals("notif1", notifications.iterator().next().getQName().getLocalName());
    final Collection<? extends RpcDefinition> rpcs = rootModule.getRpcs();
    assertEquals(1, rpcs.size());
    assertEquals("rpc1", rpcs.iterator().next().getQName().getLocalName());
    final Collection<? extends Deviation> deviations = rootModule.getDeviations();
    assertEquals(1, deviations.size());
    final Deviation deviationStmt = deviations.iterator().next();
    assertNotNull(deviationStmt);
    final QNameModule importedModuleQName = QNameModule.create(XMLNamespace.of("imported"), REVISION);
    final QName importedContQName = QName.create(importedModuleQName, "cont");
    assertEquals(Absolute.of(importedContQName), deviationStmt.getTargetPath());
    assertEquals(DeviateKind.ADD, deviationStmt.getDeviates().iterator().next().getDeviateType());
    assertEquals(Optional.of("deviate reference"), deviationStmt.getReference());
    final Collection<? extends IdentitySchemaNode> identities = rootModule.getIdentities();
    assertEquals(1, identities.size());
    assertEquals("identity1", identities.iterator().next().getQName().getLocalName());
    final Collection<? extends FeatureDefinition> features = rootModule.getFeatures();
    assertEquals(1, features.size());
    final FeatureDefinition featureStmt = features.iterator().next();
    assertNotNull(featureStmt);
    assertEquals(FEATURE1, featureStmt.getQName());
    assertEquals(Optional.of("feature1 description"), featureStmt.getDescription());
    assertEquals(Optional.of("feature1 reference"), featureStmt.getReference());
    assertEquals(Status.CURRENT, featureStmt.getStatus());
    final Collection<? extends ExtensionDefinition> extensionSchemaNodes = rootModule.getExtensionSchemaNodes();
    assertEquals(1, extensionSchemaNodes.size());
    assertEquals("ext1", extensionSchemaNodes.iterator().next().getQName().getLocalName());
}
Also used : QName(org.opendaylight.yangtools.yang.common.QName) ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) ModuleImport(org.opendaylight.yangtools.yang.model.api.ModuleImport) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Deviation(org.opendaylight.yangtools.yang.model.api.Deviation) FeatureDefinition(org.opendaylight.yangtools.yang.model.api.FeatureDefinition) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 Deviation (org.opendaylight.yangtools.yang.model.api.Deviation)6 Module (org.opendaylight.yangtools.yang.model.api.Module)5 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)4 Revision (org.opendaylight.yangtools.yang.common.Revision)3 QName (org.opendaylight.yangtools.yang.common.QName)2 DeviateDefinition (org.opendaylight.yangtools.yang.model.api.DeviateDefinition)2 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)1 XMLNamespace (org.opendaylight.yangtools.yang.common.XMLNamespace)1 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)1 DeviateKind (org.opendaylight.yangtools.yang.model.api.DeviateKind)1 FeatureDefinition (org.opendaylight.yangtools.yang.model.api.FeatureDefinition)1 LeafSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafSchemaNode)1 ModuleImport (org.opendaylight.yangtools.yang.model.api.ModuleImport)1 Uint32TypeDefinition (org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition)1