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