Search in sources :

Example 1 with PresenceStatement

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

the class DeclaredStatementsTest method testDeclaredContainer.

@Test
public void testDeclaredContainer() throws ReactorException {
    final StatementStreamSource containerStmtModule = sourceForResource("/declared-statements-test/container-declared-test.yang");
    final SchemaContext schemaContext = StmtTestUtils.parseYangSources(containerStmtModule);
    assertNotNull(schemaContext);
    final Module testModule = schemaContext.findModules("container-declared-test").iterator().next();
    assertNotNull(testModule);
    final ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container"));
    assertNotNull(containerSchemaNode);
    final ContainerStatement containerStatement = ((ContainerEffectiveStatement) containerSchemaNode).getDeclared();
    final QName name = containerStatement.argument();
    assertNotNull(name);
    final WhenStatement containerStatementWhen = containerStatement.getWhenStatement().get();
    final Collection<? extends IfFeatureStatement> containerStatementIfFeatures = containerStatement.getIfFeatures();
    assertNotNull(containerStatementIfFeatures);
    assertEquals(1, containerStatementIfFeatures.size());
    final Collection<? extends MustStatement> containerStatementMusts = containerStatement.getMustStatements();
    assertNotNull(containerStatementMusts);
    assertEquals(1, containerStatementMusts.size());
    final PresenceStatement containerStatementPresence = containerStatement.getPresence();
    assertNotNull(containerStatementPresence);
    assertNotNull(containerStatementPresence.argument());
    assertTrue(containerStatement.getConfig().isPresent());
    assertTrue(containerStatement.getStatus().isPresent());
    assertTrue(containerStatement.getDescription().isPresent());
    assertTrue(containerStatement.getReference().isPresent());
    final Collection<? extends TypedefStatement> containerStatementTypedefs = containerStatement.getTypedefs();
    assertNotNull(containerStatementTypedefs);
    assertEquals(1, containerStatementTypedefs.size());
    final Collection<? extends GroupingStatement> containerStatementGroupings = containerStatement.getGroupings();
    assertNotNull(containerStatementGroupings);
    assertEquals(1, containerStatementGroupings.size());
    final Collection<? extends DataDefinitionStatement> containerStatementDataDefinitions = containerStatement.getDataDefinitions();
    assertNotNull(containerStatementDataDefinitions);
    assertEquals(1, containerStatementDataDefinitions.size());
}
Also used : PresenceStatement(org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement) StatementStreamSource(org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource) QName(org.opendaylight.yangtools.yang.common.QName) ContainerStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerStatement) WhenStatement(org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement) ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) ContainerEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) Module(org.opendaylight.yangtools.yang.model.api.Module) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 QName (org.opendaylight.yangtools.yang.common.QName)1 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)1 Module (org.opendaylight.yangtools.yang.model.api.Module)1 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)1 ContainerEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement)1 ContainerStatement (org.opendaylight.yangtools.yang.model.api.stmt.ContainerStatement)1 PresenceStatement (org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement)1 WhenStatement (org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement)1 StatementStreamSource (org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource)1