X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-rfc7950%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fstmt%2FEffectiveSchemaContextTest.java;h=5a15a0a25f3089b746665866352cb784b716e15e;hb=c4517068c0183a892703b26baf098c97bfb2a854;hp=70fb76b8e8268ef4682f2e58c55f4f1646d3231b;hpb=862bc29f99617a37daecb59f3c2fa72c40dfa975;p=yangtools.git diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java index 70fb76b8e8..5a15a0a25f 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.yangtools.yang.stmt; import static org.junit.Assert.assertEquals; @@ -15,15 +14,15 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.IOException; -import java.net.URI; import java.net.URISyntaxException; import java.text.ParseException; import java.util.Collection; -import java.util.List; +import java.util.Optional; import java.util.Set; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.XMLNamespace; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition; import org.opendaylight.yangtools.yang.model.api.Module; @@ -32,57 +31,52 @@ import org.opendaylight.yangtools.yang.model.api.RpcDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; -import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement; import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; -import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; import org.opendaylight.yangtools.yang.model.util.SimpleSchemaContext; import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors; -import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveSchemaContext; public class EffectiveSchemaContextTest { - @Test public void testEffectiveSchemaContext() throws ReactorException, ParseException, URISyntaxException, IOException, YangSyntaxErrorException { final EffectiveSchemaContext schemaContext = RFC7950Reactors.defaultReactor().newBuild() - .addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource( - "/effective-schema-context-test/foo.yang"))) - .addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource( - "/effective-schema-context-test/bar.yang"))) - .addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource( - "/effective-schema-context-test/baz.yang"))) - .buildEffective(); + .addSource(StmtTestUtils.sourceForResource("/effective-schema-context-test/foo.yang")) + .addSource(StmtTestUtils.sourceForResource("/effective-schema-context-test/bar.yang")) + .addSource(StmtTestUtils.sourceForResource("/effective-schema-context-test/baz.yang")) + .buildEffective(); assertNotNull(schemaContext); - final Set dataDefinitions = schemaContext.getDataDefinitions(); + final Collection dataDefinitions = schemaContext.getDataDefinitions(); assertEquals(3, dataDefinitions.size()); - final Collection childNodes = schemaContext.getChildNodes(); + final Collection childNodes = schemaContext.getChildNodes(); assertEquals(3, childNodes.size()); - final Set notifications = schemaContext.getNotifications(); + final Collection notifications = schemaContext.getNotifications(); assertEquals(3, notifications.size()); - final Set rpcs = schemaContext.getOperations(); + final Collection rpcs = schemaContext.getOperations(); assertEquals(3, rpcs.size()); - final Set extensions = schemaContext.getExtensions(); + final Collection extensions = schemaContext.getExtensions(); assertEquals(3, extensions.size()); - final List unknownSchemaNodes = schemaContext.getUnknownSchemaNodes(); - assertEquals(3, unknownSchemaNodes.size()); + for (ModuleEffectiveStatement module : schemaContext.getModuleStatements().values()) { + assertEquals(1, module.getDeclared().declaredSubstatements(UnrecognizedStatement.class).size()); + } - assertNull(schemaContext.getDataChildByName(QName.create("foo-namespace", "2016-09-21", "foo-cont"))); + assertNull(schemaContext.dataChildByName(QName.create("foo-namespace", "2016-09-21", "foo-cont"))); assertFalse(schemaContext.findModule("foo", Revision.of("2016-08-21")).isPresent()); - assertFalse(schemaContext.findModule(URI.create("foo-namespace"), Revision.of("2016-08-21")).isPresent()); + assertFalse(schemaContext.findModule(XMLNamespace.of("foo-namespace"), Revision.of("2016-08-21")).isPresent()); assertFalse(schemaContext.isAugmenting()); assertFalse(schemaContext.isAddedByUses()); - assertFalse(schemaContext.isConfiguration()); - assertFalse(schemaContext.isPresenceContainer()); + assertEquals(Optional.empty(), schemaContext.effectiveConfig()); assertFalse(schemaContext.getWhenCondition().isPresent()); assertEquals(0, schemaContext.getMustConstraints().size()); assertFalse(schemaContext.getDescription().isPresent());