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