Bug 6859 #1 Binding generator v1 refactoring
[mdsal.git] / binding / mdsal-binding-generator-impl / src / test / java / org / opendaylight / yangtools / sal / binding / generator / impl / UsesTest.java
index 524ef51962fd070976da7715c6d611ff82c635ae..7bd20394be56b9c5bd4eba6e53cf23d8e034f7f3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -18,21 +18,21 @@ import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
-
 import org.junit.Test;
-import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.generator.api.BindingGenerator;
+import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.mdsal.binding.model.api.GeneratedType;
+import org.opendaylight.mdsal.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class UsesTest {
 
     private static List<File> loadTestResources(final String testFile) {
         try {
-        final List<File> testModels = new ArrayList<File>();
+        final List<File> testModels = new ArrayList<>();
         final File listModelFile = new File(UsesTest.class.getResource(testFile).toURI());
         testModels.add(listModelFile);
         return testModels;
@@ -42,10 +42,9 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInGroupingDependenciesTest() throws IOException {
+    public void usesInGroupingDependenciesTest() throws IOException, SourceException, ReactorException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-dependencies.yang");
-        final YangContextParser parser = new YangParserImpl();
-        final SchemaContext context = parser.parseFiles(testModels);
+        final SchemaContext context = YangParserTestUtils.parseYangSources(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
@@ -97,10 +96,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInCaseTest() throws IOException {
+    public void usesInCaseTest() throws IOException, SourceException, ReactorException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-case.yang");
-        final YangContextParser parser = new YangParserImpl();
-        final SchemaContext context = parser.parseFiles(testModels);
+
+        final SchemaContext context = YangParserTestUtils.parseYangSources(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
@@ -145,10 +144,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInContainerTest() throws IOException {
+    public void usesInContainerTest() throws IOException, SourceException, ReactorException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-container.yang");
-        final YangContextParser parser = new YangParserImpl();
-        final SchemaContext context = parser.parseFiles(testModels);
+
+        final SchemaContext context = YangParserTestUtils.parseYangSources(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
@@ -198,10 +197,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInGroupingTest() throws IOException {
+    public void usesInGroupingTest() throws IOException, SourceException, ReactorException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-grouping.yang");
-        final YangContextParser parser = new YangParserImpl();
-        final SchemaContext context = parser.parseFiles(testModels);
+
+        final SchemaContext context = YangParserTestUtils.parseYangSources(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
@@ -249,10 +248,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInListTest() throws IOException {
+    public void usesInListTest() throws IOException, SourceException, ReactorException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-list.yang");
-        final YangContextParser parser = new YangParserImpl();
-        final SchemaContext context = parser.parseFiles(testModels);
+
+        final SchemaContext context = YangParserTestUtils.parseYangSources(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
@@ -331,10 +330,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInModulTest() throws IOException {
+    public void usesInModulTest() throws IOException, SourceException, ReactorException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-modul.yang");
-        final YangContextParser parser = new YangParserImpl();
-        final SchemaContext context = parser.parseFiles(testModels);
+
+        final SchemaContext context = YangParserTestUtils.parseYangSources(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
@@ -382,10 +381,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInRpcTest() throws IOException {
+    public void usesInRpcTest() throws IOException, SourceException, ReactorException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-rpc.yang");
-        final YangContextParser parser = new YangParserImpl();
-        final SchemaContext context = parser.parseFiles(testModels);
+
+        final SchemaContext context = YangParserTestUtils.parseYangSources(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
@@ -475,10 +474,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInAugmentTest() throws IOException {
+    public void usesInAugmentTest() throws IOException, SourceException, ReactorException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-augment.yang");
-        final YangContextParser parser = new YangParserImpl();
-        final SchemaContext context = parser.parseFiles(testModels);
+
+        final SchemaContext context = YangParserTestUtils.parseYangSources(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
@@ -528,10 +527,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInNotification() throws IOException {
+    public void usesInNotification() throws IOException, SourceException, ReactorException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-notification.yang");
-        final YangContextParser parser = new YangParserImpl();
-        final SchemaContext context = parser.parseFiles(testModels);
+
+        final SchemaContext context = YangParserTestUtils.parseYangSources(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl(true);