[ONOS-4070] Translator of YANG union.

Change-Id: I5216687b6ea7cb6baeb3ef8e905719468370a1f4
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
index 74ec489..49421a8 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
@@ -43,7 +43,7 @@
 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForInterface;
 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForTypeDefClass;
 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod;
-import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeDefConstructor;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc;
 import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING;
 import static org.onosproject.yangutils.utils.UtilConstants.BUILD;
 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
@@ -113,12 +113,12 @@
     }
 
     /**
-     * Unit test case for checking the parse builder and typedef constructor.
+     * Unit test case for checking the parse builder and type constructor.
      */
     @Test
-    public void getTypeDefConstructorTest() {
+    public void getTypeConstructorTest() {
         JavaAttributeInfo testAttr = getTestAttribute();
-        String test = getTypeDefConstructor(testAttr, CLASS_NAME);
+        String test = getTypeConstructorStringAndJavaDoc(testAttr, CLASS_NAME);
         assertThat(true, is(test.contains(PUBLIC + SPACE + CLASS_NAME + OPEN_PARENTHESIS)));
     }
 
@@ -178,7 +178,7 @@
     }
 
     /**
-     * Test case for quals method.
+     * Test case for equals method.
      */
     @Test
     public void getEqualsMethodTest() {
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/UnionTranslatorTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/UnionTranslatorTest.java
new file mode 100644
index 0000000..239e86f
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/UnionTranslatorTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.io.IOException;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.clean;
+
+/**
+ * Unit tests for union translator.
+ */
+public final class UnionTranslatorTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks union translation should not result in any exception.
+     */
+    @Test
+    public void processUnionTranslator() throws IOException, ParserException {
+
+        clean("src/test/org/onosproject/yang");
+
+        YangNode node = manager.getDataModel("src/test/resources/UnionTranslator.yang");
+
+        YangPluginConfig yangPluginConfig = new YangPluginConfig();
+        yangPluginConfig.setCodeGenDir("target/UnionTestGenFile");
+
+        generateJavaCode(node, yangPluginConfig);
+
+        clean("target/UnionTestGenFile");
+    }
+
+    // TODO enhance the test cases, after having a framework of translator test.
+}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java
index 93d54fd..92df183 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java
@@ -56,7 +56,7 @@
     @Test
     public void builderClassGenerationTest() {
         String builderClassJavaDoc = getJavaDoc(BUILDER_CLASS, TEST_NAME, false);
-        assertThat(true, is(builderClassJavaDoc.contains("Reperesents the builder implementation of")
+        assertThat(true, is(builderClassJavaDoc.contains("Represents the builder implementation of")
                 && builderClassJavaDoc.contains(END_STRING)));
     }
 
@@ -138,7 +138,7 @@
     public void implClassGenerationTest() {
         String implClassJavaDoc = getJavaDoc(IMPL_CLASS, TEST_NAME, false);
         assertThat(true,
-                is(implClassJavaDoc.contains("Reperesents the implementation of")
+                is(implClassJavaDoc.contains("Represents the implementation of")
                         && implClassJavaDoc.contains(END_STRING)));
     }
 
@@ -149,7 +149,7 @@
     public void interfaceGenerationTest() {
         String interfaceJavaDoc = getJavaDoc(INTERFACE, TEST_NAME, false);
         assertThat(true,
-                is(interfaceJavaDoc.contains("Abstraction of an entity which Reperesents the functionalities of")
+                is(interfaceJavaDoc.contains("Abstraction of an entity which represents the functionality of")
                         && interfaceJavaDoc.contains(END_STRING)));
     }