Search in sources :

Example 1 with AugmentEffectiveStatement

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

the class YT1208Test method testAugmentStatementReuse.

@Test
public void testAugmentStatementReuse() throws Exception {
    final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/augment.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
    final NotificationEffectiveStatement notif = module.findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
    final AugmentEffectiveStatement grpAug = notif.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(AugmentEffectiveStatement.class).orElseThrow();
    final AugmentEffectiveStatement contAug = notif.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(AugmentEffectiveStatement.class).orElseThrow();
    assertSame(contAug, grpAug);
}
Also used : ContainerEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement) GroupingEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement) NotificationEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement) AugmentEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.AugmentEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) Test(org.junit.Test)

Example 2 with AugmentEffectiveStatement

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

the class DeclaredStatementsTest method testDeclaredAugment.

@Test
public void testDeclaredAugment() throws ReactorException {
    final StatementStreamSource augmentStmtModule = sourceForResource("/declared-statements-test/augment-declared-test.yang");
    final SchemaContext schemaContext = StmtTestUtils.parseYangSources(augmentStmtModule);
    assertNotNull(schemaContext);
    final Module testModule = schemaContext.findModules("augment-declared-test").iterator().next();
    assertNotNull(testModule);
    final Collection<? extends AugmentationSchemaNode> augmentationSchemas = testModule.getAugmentations();
    assertNotNull(augmentationSchemas);
    assertEquals(1, augmentationSchemas.size());
    final AugmentationSchemaNode augmentationSchema = augmentationSchemas.iterator().next();
    final AugmentStatement augmentStatement = ((AugmentEffectiveStatement) augmentationSchema).getDeclared();
    final SchemaNodeIdentifier targetNode = augmentStatement.argument();
    assertNotNull(targetNode);
    final Collection<? extends DataDefinitionStatement> augmentStatementDataDefinitions = augmentStatement.getDataDefinitions();
    assertNotNull(augmentStatementDataDefinitions);
    assertEquals(1, augmentStatementDataDefinitions.size());
}
Also used : AugmentationSchemaNode(org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode) StatementStreamSource(org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) Module(org.opendaylight.yangtools.yang.model.api.Module) AugmentStatement(org.opendaylight.yangtools.yang.model.api.stmt.AugmentStatement) SchemaNodeIdentifier(org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier) AugmentEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.AugmentEffectiveStatement) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 AugmentEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.AugmentEffectiveStatement)2 AugmentationSchemaNode (org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode)1 Module (org.opendaylight.yangtools.yang.model.api.Module)1 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)1 AugmentStatement (org.opendaylight.yangtools.yang.model.api.stmt.AugmentStatement)1 ContainerEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement)1 GroupingEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement)1 ModuleEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement)1 NotificationEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement)1 SchemaNodeIdentifier (org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier)1 StatementStreamSource (org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource)1