Removed usage of deprecated YangParserImpl from tests in mdsal project
[mdsal.git] / binding / mdsal-binding-generator-util / src / test / java / org / opendaylight / yangtools / binding / generator / util / BindingGeneratorUtilTest.java
index 91e93ed1b8f7407de49d9647c57024e1bd9d1392..5a3581b0e7f319d621f0bbd1024aaa4f738cd6ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 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,
@@ -14,7 +14,11 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
 import com.google.common.base.Optional;
+
 import java.io.File;
 import java.io.IOException;
 import java.io.Serializable;
@@ -23,6 +27,7 @@ import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
+
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -43,7 +48,6 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
-import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.model.util.BaseConstraints;
 import org.opendaylight.yangtools.yang.model.util.DataNodeIterator;
 import org.opendaylight.yangtools.yang.model.util.Decimal64;
@@ -53,7 +57,6 @@ import org.opendaylight.yangtools.yang.model.util.Int16;
 import org.opendaylight.yangtools.yang.model.util.StringType;
 import org.opendaylight.yangtools.yang.model.util.Uint16;
 import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class BindingGeneratorUtilTest {
 
@@ -74,20 +77,22 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Tests methods:
-     * <ul>
-     * <li>moduleNamespaceToPackageName</li> - with revision
-     * <li>packageNameForGeneratedType</li>
-     * <ul>
-     * <li>validateJavaPackage</li>
-     * </ul>
-     * <li>packageNameForTypeDefinition</li> <li>moduleNamespaceToPackageName</li>
-     * - without revision </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;moduleNamespaceToPackageName&lt;/li&gt; - with revision
+     * &lt;li&gt;packageNameForGeneratedType&lt;/li&gt;
+     * &lt;ul&gt;
+     * &lt;li&gt;validateJavaPackage&lt;/li&gt;
+     * &lt;/ul&gt;
+     * &lt;li&gt;packageNameForTypeDefinition&lt;/li&gt; &lt;li&gt;moduleNamespaceToPackageName&lt;/li&gt;
+     * - without revision &lt;/ul&gt;
+     * @throws ReactorException Reactor exception
+     * @throws SourceException Source exception
      */
     @Test
-    public void testBindingGeneratorUtilMethods() throws IOException {
+    public void testBindingGeneratorUtilMethods() throws IOException, SourceException, ReactorException {
         List<File> testModels = loadTestResources("/module.yang");
-        final YangContextParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseFiles(testModels).getModules();
+
+        final Set<Module> modules = RetestUtils.parseYangSources(testModels).getModules();
         String packageName = "";
         Module module = null;
         for (Module m : modules) {
@@ -166,12 +171,13 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#packageNameForTypeDefinition()
-     * packageNameForTypeDefinition()}</li>
-     * </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#packageNameForTypeDefinition(String, TypeDefinition)
+     * packageNameForTypeDefinition(String, TypeDefinition)}&lt;/li&gt;
+     * &lt;/ul&gt;
      */
     @Test
+    @Deprecated
     public void testPackageNameForTypeDefinitionNullBasePackageName() {
         expectedEx.expect(IllegalArgumentException.class);
         expectedEx.expectMessage("Base Package Name cannot be NULL!");
@@ -180,12 +186,13 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#packageNameForTypeDefinition()
-     * packageNameForTypeDefinition()}</li>
-     * </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#packageNameForTypeDefinition(String, TypeDefinition)
+     * packageNameForTypeDefinition(String, TypeDefinition)}&lt;/li&gt;
+     * &lt;/ul&gt;
      */
     @Test
+    @Deprecated
     public void testPackageNameForTypeDefinitionNullTypeDefinition() {
         expectedEx.expect(IllegalArgumentException.class);
         expectedEx.expectMessage("Type Definition reference cannot be NULL!");
@@ -194,38 +201,36 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#packageNameForGeneratedType()
-     * packageNameForGeneratedType()}</li>
-     * </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#packageNameForGeneratedType(String, SchemaPath)
+     * packageNameForGeneratedType(String, SchemaPath)}&lt;/li&gt;
+     * &lt;/ul&gt;
      */
     @Test
     public void testPackageNameForGeneratedTypeNullBasePackageName() {
-        expectedEx.expect(IllegalArgumentException.class);
-        expectedEx.expectMessage("Base Package Name cannot be NULL!");
+        expectedEx.expect(NullPointerException.class);
         BindingGeneratorUtil.packageNameForGeneratedType(null, null);
     }
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#packageNameForGeneratedType()
-     * packageNameForGeneratedType()}</li>
-     * </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#packageNameForGeneratedType(String, SchemaPath)
+     * packageNameForGeneratedType(String, SchemaPath)}&lt;/li&gt;
+     * &lt;/ul&gt;
      */
     @Test
     public void testPackageNameForGeneratedTypeNullSchemaPath() {
-        expectedEx.expect(IllegalArgumentException.class);
-        expectedEx.expectMessage("Schema Path cannot be NULL!");
+        expectedEx.expect(NullPointerException.class);
         BindingGeneratorUtil.packageNameForGeneratedType("test.package", null);
     }
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#parseToClassName()
-     * parseToClassName()}</li>
-     * </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#parseToClassName(String)
+     * parseToClassName(String)}&lt;/li&gt;
+     * &lt;/ul&gt;
      */
     @Test
     public void testParseToClassNameNullValue() {
@@ -239,10 +244,10 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#parseToClassName()
-     * parseToClassName()}</li>
-     * </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#parseToClassName(String)
+     * parseToClassName(String)}&lt;/li&gt;
+     * &lt;/ul&gt;
      */
     @Test
     public void testParseToClassNameEmptyValue() {
@@ -256,10 +261,10 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#validateParameterName()
-     * validateParameterName()}</li>
-     * <ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#resolveJavaReservedWordEquivalency(String)
+     * resolveJavaReservedWordEquivalency(String)}&lt;/li&gt;
+     * &lt;ul&gt;
      */
     @Test
     public void testValidateParameterName() {
@@ -272,21 +277,21 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Tests the methods:
-     * <ul>
-     * <li>parseToClassName</li>
-     * <ul>
-     * <li>parseToCamelCase</li>
-     * <ul>
-     * <li>replaceWithCamelCase</li>
-     * </ul>
-     * </ul> <li>parseToValidParamName</li>
-     * <ul>
-     * <li>parseToCamelCase</li>
-     * <ul>
-     * <li>replaceWithCamelCase</li>
-     * </ul>
-     * </ul>
-     * <ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;parseToClassName&lt;/li&gt;
+     * &lt;ul&gt;
+     * &lt;li&gt;parseToCamelCase&lt;/li&gt;
+     * &lt;ul&gt;
+     * &lt;li&gt;replaceWithCamelCase&lt;/li&gt;
+     * &lt;/ul&gt;
+     * &lt;/ul&gt; &lt;li&gt;parseToValidParamName&lt;/li&gt;
+     * &lt;ul&gt;
+     * &lt;li&gt;parseToCamelCase&lt;/li&gt;
+     * &lt;ul&gt;
+     * &lt;li&gt;replaceWithCamelCase&lt;/li&gt;
+     * &lt;/ul&gt;
+     * &lt;/ul&gt;
+     * &lt;ul&gt;
      */
     @Test
     public void testParsingMethods() {