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;
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 {
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());
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());
@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());