Adjust test suite parser update to conform with API changes
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / ExtensionStmtTest.java
index 0dd0ea4c73ced7c183ffd1dd703e224ac2cf5a0d..10d45274344ccbc6c5dbb82a588b517e1f174b5c 100644 (file)
@@ -21,28 +21,18 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
 
 public class ExtensionStmtTest {
-
-    private static final StatementStreamSource EXT_DEF_MODULE = sourceForResource("/model/bar.yang");
-    private static final StatementStreamSource EXT_DEF_MODULE2 = sourceForResource(
-        "/semantic-statement-parser/ext-typedef.yang");
-    private static final StatementStreamSource EXT_USE_MODULE = sourceForResource(
-        "/semantic-statement-parser/ext-use.yang");
-
     @Test
     public void testExtensionDefinition() throws ReactorException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSources(EXT_DEF_MODULE);
-
-        final SchemaContext result = reactor.buildEffective();
+        final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
+                .addSource(sourceForResource("/model/bar.yang"))
+                .buildEffective();
         assertNotNull(result);
 
-        final Module testModule = result.findModuleByName("bar", null);
+        final Module testModule = result.findModules("bar").iterator().next();
         assertNotNull(testModule);
 
         assertEquals(1, testModule.getExtensionSchemaNodes().size());
@@ -56,13 +46,13 @@ public class ExtensionStmtTest {
 
     @Test
     public void testExtensionUsage() throws ReactorException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSources(EXT_DEF_MODULE2, EXT_USE_MODULE);
-
-        final SchemaContext result = reactor.buildEffective();
+        final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
+                .addSource(sourceForResource("/semantic-statement-parser/ext-typedef.yang"))
+                .addSource(sourceForResource("/semantic-statement-parser/ext-use.yang"))
+                .buildEffective();
         assertNotNull(result);
 
-        final Module testModule1 = result.findModuleByName("ext-typedef", null);
+        final Module testModule1 = result.findModules("ext-typedef").iterator().next();
         assertNotNull(testModule1);
 
         assertEquals(1, testModule1.getExtensionSchemaNodes().size());
@@ -70,10 +60,11 @@ public class ExtensionStmtTest {
         final List<ExtensionDefinition> extensions = testModule1.getExtensionSchemaNodes();
         final ExtensionDefinition extensionDefinition = extensions.get(0);
 
-        final Module testModule2 = result.findModuleByName("ext-use", null);
+        final Module testModule2 = result.findModules("ext-use").iterator().next();
         assertNotNull(testModule2);
 
-        final LeafSchemaNode leaf = (LeafSchemaNode) testModule2.getDataChildByName(QName.create(testModule2.getQNameModule(), "value"));
+        final LeafSchemaNode leaf = (LeafSchemaNode) testModule2.getDataChildByName(
+            QName.create(testModule2.getQNameModule(), "value"));
         assertNotNull(leaf);
 
         assertEquals(1, leaf.getUnknownSchemaNodes().size());