Search in sources :

Example 1 with AnyxmlStatement

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

the class DeclaredStatementsTest method testDeclaredAnyXml.

@Test
public void testDeclaredAnyXml() throws ReactorException {
    final StatementStreamSource anyxmlStmtModule = sourceForResource("/declared-statements-test/anyxml-declared-test.yang");
    final SchemaContext schemaContext = StmtTestUtils.parseYangSources(anyxmlStmtModule);
    assertNotNull(schemaContext);
    final Module testModule = schemaContext.findModules("anyxml-declared-test").iterator().next();
    assertNotNull(testModule);
    final AnyxmlSchemaNode anyxmlSchemaNode = (AnyxmlSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "foobar"));
    assertNotNull(anyxmlSchemaNode);
    final AnyxmlStatement anyxmlStatement = ((AnyxmlEffectiveStatement) anyxmlSchemaNode).getDeclared();
    final QName name = anyxmlStatement.argument();
    assertNotNull(name);
    final WhenStatement whenStatement = anyxmlStatement.getWhenStatement().get();
    assertNotNull(whenStatement.argument());
    final DescriptionStatement whenStatementDescription = whenStatement.getDescription().get();
    assertTrue(whenStatement.getReference().isPresent());
    final Collection<? extends IfFeatureStatement> ifFeatureStatements = anyxmlStatement.getIfFeatures();
    assertNotNull(ifFeatureStatements);
    assertEquals(1, ifFeatureStatements.size());
    final Predicate<Set<QName>> ifFeaturePredicate = ifFeatureStatements.iterator().next().getIfFeaturePredicate();
    assertNotNull(ifFeaturePredicate);
    final Collection<? extends MustStatement> mustStatements = anyxmlStatement.getMustStatements();
    assertNotNull(mustStatements);
    assertEquals(1, mustStatements.size());
    final MustStatement mustStatement = mustStatements.iterator().next();
    assertNotNull(mustStatement.argument());
    assertTrue(mustStatement.getErrorAppTagStatement().isPresent());
    assertTrue(mustStatement.getErrorMessageStatement().isPresent());
    assertTrue(mustStatement.getDescription().isPresent());
    assertTrue(mustStatement.getReference().isPresent());
    final ConfigStatement configStatement = anyxmlStatement.getConfig().get();
    assertFalse(configStatement.getValue());
    final StatusStatement statusStatement = anyxmlStatement.getStatus().get();
    final Status status = statusStatement.argument();
    assertNotNull(status);
    final DescriptionStatement descriptionStatement = anyxmlStatement.getDescription().get();
    assertEquals("anyxml description", descriptionStatement.argument());
    final ReferenceStatement referenceStatement = anyxmlStatement.getReference().get();
    assertEquals("anyxml reference", referenceStatement.argument());
    assertTrue(anyxmlStatement.getMandatory().isPresent());
}
Also used : MustStatement(org.opendaylight.yangtools.yang.model.api.stmt.MustStatement) Status(org.opendaylight.yangtools.yang.model.api.Status) ConfigStatement(org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement) Set(java.util.Set) StatementStreamSource(org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource) QName(org.opendaylight.yangtools.yang.common.QName) ReferenceStatement(org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement) StatusStatement(org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement) AnyxmlSchemaNode(org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode) WhenStatement(org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement) DescriptionStatement(org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement) AnyxmlEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlEffectiveStatement) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) Module(org.opendaylight.yangtools.yang.model.api.Module) AnyxmlStatement(org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlStatement) Test(org.junit.Test)

Aggregations

Set (java.util.Set)1 Test (org.junit.Test)1 QName (org.opendaylight.yangtools.yang.common.QName)1 AnyxmlSchemaNode (org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode)1 Module (org.opendaylight.yangtools.yang.model.api.Module)1 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)1 Status (org.opendaylight.yangtools.yang.model.api.Status)1 AnyxmlEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlEffectiveStatement)1 AnyxmlStatement (org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlStatement)1 ConfigStatement (org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement)1 DescriptionStatement (org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement)1 MustStatement (org.opendaylight.yangtools.yang.model.api.stmt.MustStatement)1 ReferenceStatement (org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement)1 StatusStatement (org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement)1 WhenStatement (org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement)1 StatementStreamSource (org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource)1