Update StmtTestUtils
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / KeyTest.java
index 3d2a772ab135c5beb7e34720a80c950d71fdfbde..c75ff64ddc160a6c60040aefaa5fbe2b2d536b2a 100644 (file)
@@ -11,27 +11,28 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
 
 public class KeyTest {
 
-    private static final YangStatementSourceImpl KEY_SIMPLE_AND_COMP = new YangStatementSourceImpl(
-            "/semantic-statement-parser/key-arg-parsing/key-simple-and-comp.yang", false);
-    private static final YangStatementSourceImpl KEY_COMP_DUPLICATE = new YangStatementSourceImpl(
-            "/semantic-statement-parser/key-arg-parsing/key-comp-duplicate.yang", false);
+    private static final StatementStreamSource KEY_SIMPLE_AND_COMP = sourceForResource(
+            "/semantic-statement-parser/key-arg-parsing/key-simple-and-comp.yang");
+    private static final StatementStreamSource KEY_COMP_DUPLICATE = sourceForResource(
+            "/semantic-statement-parser/key-arg-parsing/key-comp-duplicate.yang");
 
     @Test
     public void keySimpleTest() throws ReactorException {
 
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor, KEY_SIMPLE_AND_COMP);
+        reactor.addSources(KEY_SIMPLE_AND_COMP);
 
         EffectiveModelContext result = reactor.build();
         assertNotNull(result);
@@ -41,7 +42,7 @@ public class KeyTest {
     public void keyCompositeInvalid() {
 
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor, KEY_COMP_DUPLICATE);
+        reactor.addSources(KEY_COMP_DUPLICATE);
 
         try {
             reactor.build();
@@ -52,11 +53,4 @@ public class KeyTest {
             assertTrue(cause.getMessage().startsWith("Key argument 'key1 key2 key2' contains duplicates"));
         }
     }
-
-    private static void addSources(final BuildAction reactor, final YangStatementSourceImpl... sources) {
-        for (YangStatementSourceImpl source : sources) {
-            reactor.addSource(source);
-        }
-    }
-
 }