BUG-4688: Rework SchemaContext module lookups
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / IfFeatureResolutionTest.java
index 5a2a5f9d0e07760909e7ce47099f93a7852eda73..a4c6cc1e5d8cfa3cfe7d3324d7678ae781e32d6e 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
 import com.google.common.collect.ImmutableSet;
 import java.util.Set;
@@ -25,14 +26,11 @@ 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;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
 
 public class IfFeatureResolutionTest {
 
-    private static final StatementStreamSource FOO_MODULE =
-            new YangStatementSourceImpl("/if-feature-resolution-test/foo.yang", false);
-    private static final StatementStreamSource BAR_MODULE =
-            new YangStatementSourceImpl("/if-feature-resolution-test/bar.yang", false);
+    private static final StatementStreamSource FOO_MODULE = sourceForResource("/if-feature-resolution-test/foo.yang");
+    private static final StatementStreamSource BAR_MODULE = sourceForResource("/if-feature-resolution-test/bar.yang");
 
     @Test
     public void testSomeFeaturesSupported() throws ReactorException {
@@ -42,13 +40,14 @@ public class IfFeatureResolutionTest {
                 QName.create("foo-namespace", "1970-01-01", "test-feature-3"),
                 QName.create("bar-namespace", "1970-01-01", "imp-feature"));
 
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(supportedFeatures);
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
         reactor.addSources(FOO_MODULE, BAR_MODULE);
+        reactor.setSupportedFeatures(supportedFeatures);
 
         final SchemaContext schemaContext = reactor.buildEffective();
         assertNotNull(schemaContext);
 
-        final Module testModule = schemaContext.findModuleByName("foo", null);
+        final Module testModule = schemaContext.findModules("foo").iterator().next();
         assertNotNull(testModule);
 
         assertEquals(9, testModule.getChildNodes().size());
@@ -154,7 +153,7 @@ public class IfFeatureResolutionTest {
         final SchemaContext schemaContext = reactor.buildEffective();
         assertNotNull(schemaContext);
 
-        final Module testModule = schemaContext.findModuleByName("foo", null);
+        final Module testModule = schemaContext.findModules("foo").iterator().next();
         assertNotNull(testModule);
 
         assertEquals(11, testModule.getChildNodes().size());
@@ -275,15 +274,14 @@ public class IfFeatureResolutionTest {
 
     @Test
     public void testNoFeaturesSupported() throws ReactorException {
-        final Set<QName> supportedFeatures = ImmutableSet.of();
-
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(supportedFeatures);
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
         reactor.addSources(FOO_MODULE, BAR_MODULE);
+        reactor.setSupportedFeatures(ImmutableSet.of());
 
         final SchemaContext schemaContext = reactor.buildEffective();
         assertNotNull(schemaContext);
 
-        final Module testModule = schemaContext.findModuleByName("foo", null);
+        final Module testModule = schemaContext.findModules("foo").iterator().next();
         assertNotNull(testModule);
 
         assertEquals(6, testModule.getChildNodes().size());