UT test cases fixes in YANG translator.

Change-Id: I8408280c663dda016956b76db27285f466f24fad
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaAttributeInfo.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaAttributeInfo.java
index 7989255..24a0daa 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaAttributeInfo.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaAttributeInfo.java
@@ -63,6 +63,21 @@
     }
 
     /**
+     * Construct object of java attribute info.
+     *
+     * @param attrType YANG type
+     * @param name attribute name
+     * @param isListAttr is list attribute
+     * @param isQualifiedName is qualified name
+     */
+    public JavaAttributeInfo(YangType<?> attrType, String name, boolean isListAttr, boolean isQualifiedName) {
+        this.attrType = attrType;
+        this.name = name;
+        this.isListAttr = isListAttr;
+        this.isQualifiedName = isQualifiedName;
+    }
+
+    /**
      * Get the data type info of attribute.
      *
      * @return the data type info of attribute
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
index 4a9c4d7..99fadab 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
@@ -176,21 +176,10 @@
     }
 
     /**
-     * Returns backspaced string.
-     *
-     * @param charString char string
-     * @return backspace string
-     */
-    public static String deleteLastChar(String charString) {
-
-        return charString.substring(0, charString.length() - 1);
-    }
-
-    /**
      * Get the directory path of the package in canonical form.
      *
      * @param baseCodeGenPath base path where the generated files needs to be
-     *            put.
+     *            put
      * @param pathOfJavaPkg java package of the file being generated
      * @return absolute path of the package in canonical form
      */
@@ -211,7 +200,7 @@
      * Get the absolute path of the package in canonical form.
      *
      * @param baseCodeGenPath base path where the generated files needs to be
-     *            put.
+     *            put
      * @param pathOfJavaPkg java package of the file being generated
      * @return absolute path of the package in canonical form
      */
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java
new file mode 100644
index 0000000..4d62b73
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2016 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.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangType;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.BOOLEAN;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT8;
+import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaDataType;
+import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportClass;
+import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportPackage;
+import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG;
+
+/**
+ * Unit test case for attribute java data type.
+ */
+public class AttributesJavaDataTypeTest {
+
+    private static final YangDataTypes TYPE1 = STRING;
+    private static final YangDataTypes TYPE2 = INT32;
+    private static final YangDataTypes TYPE3 = BOOLEAN;
+    private static final YangDataTypes TYPE4 = UINT8;
+    private static final String CLASS_INFO1 = "String";
+    private static final String CLASS_INFO2 = "int";
+    private static final String CLASS_INFO3 = "boolean";
+    private static final String CLASS_INFO4 = "short";
+    private static final String CLASS_INFO5 = "Integer";
+    private static String test = "";
+
+    /**
+     * Unit test for private constructor.
+     *
+     * @throws SecurityException if any security violation is observed
+     * @throws NoSuchMethodException if when the method is not found
+     * @throws IllegalArgumentException if there is illegal argument found
+     * @throws InstantiationException if instantiation is provoked for the private constructor
+     * @throws IllegalAccessException if instance is provoked or a method is provoked
+     * @throws InvocationTargetException when an exception occurs by the method or constructor
+     */
+    @Test
+    public void callPrivateConstructors() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+            InstantiationException, IllegalAccessException, InvocationTargetException {
+
+        Class<?>[] classesToConstruct = {AttributesJavaDataType.class };
+        for (Class<?> clazz : classesToConstruct) {
+            Constructor<?> constructor = clazz.getDeclaredConstructor();
+            constructor.setAccessible(true);
+            assertNotNull(constructor.newInstance());
+        }
+    }
+
+    /**
+     * Unit test for java class info method test.
+     */
+    @Test
+    public void testgetJavaClassInfo() {
+
+        test = getJavaImportClass(getStubYangType(TYPE1), false);
+        assertThat(true, is(test.equals(CLASS_INFO1)));
+
+        test = getJavaImportClass(getStubYangType(TYPE2), true);
+        assertThat(true, is(test.equals(CLASS_INFO5)));
+
+        test = getJavaImportClass(getStubYangType(TYPE3), false);
+        assertThat(null, is(test));
+
+        test = getJavaImportClass(getStubYangType(TYPE4), false);
+        assertThat(null, is(test));
+    }
+
+    /**
+     * Unit test for java data type method.
+     */
+    @Test
+    public void testgetJavaDataType() {
+
+        test = getJavaDataType(getStubYangType(TYPE1));
+        assertThat(true, is(test.equals(CLASS_INFO1)));
+
+        test = getJavaDataType(getStubYangType(TYPE2));
+        assertThat(true, is(test.equals(CLASS_INFO2)));
+
+        test = getJavaDataType(getStubYangType(TYPE3));
+        assertThat(true, is(test.equals(CLASS_INFO3)));
+
+        test = getJavaDataType(getStubYangType(TYPE4));
+        assertThat(true, is(test.equals(CLASS_INFO4)));
+    }
+
+    /**
+     * Unit test for java package info method.
+     */
+    @Test
+    public void testgetJavaPkgInfo() {
+
+        test = getJavaImportPackage(getStubYangType(TYPE1), false, CLASS_INFO1);
+        assertThat(true, is(test.equals(JAVA_LANG)));
+
+        test = getJavaImportPackage(getStubYangType(TYPE2), true, CLASS_INFO5);
+        assertThat(true, is(test.equals(JAVA_LANG)));
+
+        test = getJavaImportPackage(getStubYangType(TYPE3), false, CLASS_INFO3);
+        assertThat(null, is(test));
+
+        test = getJavaImportPackage(getStubYangType(TYPE4), false, CLASS_INFO4);
+        assertThat(null, is(test));
+    }
+
+    /**
+     * Returns stub YANG type for test.
+     *
+     * @param dataTypes YANG data types
+     * @return YANG type
+     */
+    private YangType<?> getStubYangType(YangDataTypes dataTypes) {
+
+        YangType<?> type = new YangType();
+        type.setDataType(dataTypes);
+        return type;
+    }
+}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGeneratorTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGeneratorTest.java
index 7b3c932..c61a13b 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGeneratorTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGeneratorTest.java
@@ -30,24 +30,19 @@
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
 import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition;
-import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
-import static org.onosproject.yangutils.utils.UtilConstants.CLASS;
-import static org.onosproject.yangutils.utils.UtilConstants.FINAL;
-import static org.onosproject.yangutils.utils.UtilConstants.IMPL;
-import static org.onosproject.yangutils.utils.UtilConstants.IMPLEMENTS;
-import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE;
-import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
-import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
-import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
-import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
-import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
 
 /**
  * Unit tests for class definition generator for generated files.
  */
 public final class ClassDefinitionGeneratorTest {
 
-    private static final String CLASS_NAME = "testclass";
+    private static final String CLASS_NAME = "TestClass";
+    private static final String INTERFACE_CLASS_DEF = "public interface TestClass {\n";
+    private static final String BULDER_INTERFACE_CLASS_DEF = "interface TestClassBuilder {\n\n";
+    private static final String BUILDER_CLASS_DEF = "public class TestClassBuilder implements "
+            + "TestClass.TestClassBuilder {\n";
+    private static final String IMPL_CLASS_DEF = "public final class TestClassImpl implements TestClass {\n";
+    private static final String TYPE_DEF_CLASS_DEF = "public final class TestClass {\n";
 
     /**
      * Unit test for private constructor.
@@ -78,9 +73,7 @@
     public void generateBuilderClassDefinitionTest() {
 
         String builderClassDefinition = generateClassDefinition(BUILDER_CLASS_MASK, CLASS_NAME);
-        assertThat(true, is(builderClassDefinition.equals(
-                PUBLIC + SPACE + CLASS + SPACE + CLASS_NAME + BUILDER + SPACE + IMPLEMENTS + SPACE + CLASS_NAME + PERIOD
-                        + CLASS_NAME + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE)));
+        assertThat(true, is(builderClassDefinition.equals(BUILDER_CLASS_DEF)));
     }
 
     /**
@@ -90,8 +83,7 @@
     public void generateBuilderInterfaceDefinitionTest() {
 
         String builderInterfaceDefinition = generateClassDefinition(BUILDER_INTERFACE_MASK, CLASS_NAME);
-        assertThat(true, is(builderInterfaceDefinition
-                .equals(INTERFACE + SPACE + CLASS_NAME + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + NEW_LINE)));
+        assertThat(true, is(builderInterfaceDefinition.equals(BULDER_INTERFACE_CLASS_DEF)));
     }
 
     /**
@@ -101,9 +93,7 @@
     public void generateImplDefinitionTest() {
 
         String implDefinition = generateClassDefinition(IMPL_CLASS_MASK, CLASS_NAME);
-        assertThat(true, is(implDefinition.equals(
-                PUBLIC + SPACE + FINAL + SPACE + CLASS + SPACE + CLASS_NAME + IMPL + SPACE + IMPLEMENTS + SPACE
-                        + CLASS_NAME + SPACE + OPEN_CURLY_BRACKET + NEW_LINE)));
+        assertThat(true, is(implDefinition.equals(IMPL_CLASS_DEF)));
     }
 
     /**
@@ -113,8 +103,7 @@
     public void generateinterfaceDefinitionTest() {
 
         String interfaceDefinition = generateClassDefinition(INTERFACE_MASK, CLASS_NAME);
-        assertThat(true, is(interfaceDefinition
-                .equals(PUBLIC + SPACE + INTERFACE + SPACE + CLASS_NAME + SPACE + OPEN_CURLY_BRACKET + NEW_LINE)));
+        assertThat(true, is(interfaceDefinition.equals(INTERFACE_CLASS_DEF)));
     }
 
     /**
@@ -124,7 +113,6 @@
     public void generateTypeDefTest() {
 
         String typeDef = generateClassDefinition(GENERATE_TYPEDEF_CLASS, CLASS_NAME);
-        assertThat(true, is(typeDef.equals(
-                PUBLIC + SPACE + FINAL + SPACE + CLASS + SPACE + CLASS_NAME + SPACE + OPEN_CURLY_BRACKET + NEW_LINE)));
+        assertThat(true, is(typeDef.equals(TYPE_DEF_CLASS_DEF)));
     }
 }
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
new file mode 100644
index 0000000..cf1a110
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
@@ -0,0 +1,328 @@
+/*
+ * Copyright 2016 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.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
+import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuild;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildForInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getCheckNotNull;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructor;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethod;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass;
+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.utils.UtilConstants.ADD_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.BUILD;
+import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
+import static org.onosproject.yangutils.utils.UtilConstants.CHECK_NOT_NULL_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
+import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
+import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
+import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.EQUAL;
+import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX;
+import static org.onosproject.yangutils.utils.UtilConstants.IMPL;
+import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG;
+import static org.onosproject.yangutils.utils.UtilConstants.NEW;
+import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
+import static org.onosproject.yangutils.utils.UtilConstants.OBJECT;
+import static org.onosproject.yangutils.utils.UtilConstants.OBJECT_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.OF;
+import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
+import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
+import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE;
+import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
+import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
+import static org.onosproject.yangutils.utils.UtilConstants.RETURN;
+import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
+import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX;
+import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
+import static org.onosproject.yangutils.utils.UtilConstants.STATIC;
+import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
+import static org.onosproject.yangutils.utils.UtilConstants.SUFFIX_S;
+import static org.onosproject.yangutils.utils.UtilConstants.THIS;
+import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.VALUE;
+import static org.onosproject.yangutils.utils.UtilConstants.VOID;
+
+/**
+ * Unit tests for generated methods from the file type.
+ */
+public final class MethodsGeneratorTest {
+
+    private static final String CLASS_NAME = "testname";
+    private static final String ATTRIBUTE_NAME = "testname";
+
+    /**
+     * Unit test for private constructor.
+     *
+     * @throws SecurityException if any security violation is observed
+     * @throws NoSuchMethodException if when the method is not found
+     * @throws IllegalArgumentException if there is illegal argument found
+     * @throws InstantiationException if instantiation is provoked for the private constructor
+     * @throws IllegalAccessException if instance is provoked or a method is provoked
+     * @throws InvocationTargetException when an exception occurs by the method or constructor
+     */
+    @Test
+    public void callPrivateConstructors() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+            InstantiationException, IllegalAccessException, InvocationTargetException {
+
+        Class<?>[] classesToConstruct = {MethodsGenerator.class };
+        for (Class<?> clazz : classesToConstruct) {
+            Constructor<?> constructor = clazz.getDeclaredConstructor();
+            constructor.setAccessible(true);
+            assertNotNull(constructor.newInstance());
+        }
+    }
+
+    /**
+     * Unit test case for checking the parse builder and typedef constructor.
+     */
+    @Test
+    public void getTypeDefConstructorTest() {
+
+        JavaAttributeInfo testAttr = getTestAttribute();
+        String test = getTypeDefConstructor(testAttr, CLASS_NAME);
+        assertThat(true, is(test.contains(PUBLIC + SPACE + CLASS_NAME + OPEN_PARENTHESIS)));
+    }
+
+    /**
+     * Test for build method for class.
+     */
+    @Test
+    public void getBuildTest() {
+
+        String method = getBuild(CLASS_NAME);
+        assertThat(true, is(method.equals(FOUR_SPACE_INDENTATION + PUBLIC + SPACE + CLASS_NAME + SPACE + BUILD
+                + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION
+                + RETURN + SPACE + NEW + SPACE + CLASS_NAME + IMPL + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS
+                + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET)));
+
+    }
+
+    /**
+     * Test for build method of interface.
+     */
+    @Test
+    public void getBuildForInterfaceTest() {
+
+        String method = getBuildForInterface(CLASS_NAME);
+        assertThat(true, is(method.equals(FOUR_SPACE_INDENTATION + CLASS_NAME + SPACE + BUILD +
+                OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE)));
+    }
+
+    /**
+     * Test for check not null method.
+     */
+    @Test
+    public void getCheckNotNullTest() {
+
+        String method = getCheckNotNull(CLASS_NAME);
+        assertThat(true, is(method.equals(EIGHT_SPACE_INDENTATION + CHECK_NOT_NULL_STRING + OPEN_PARENTHESIS
+                + CLASS_NAME + COMMA + SPACE + CLASS_NAME + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE)));
+    }
+
+    /**
+     * Test case for constructor.
+     */
+    @Test
+    public void getConstructorTest() {
+
+        JavaAttributeInfo testAttr = getTestAttribute();
+        String method = getConstructor(CLASS_NAME, testAttr);
+        assertThat(true, is(method.contains(THIS + PERIOD + CLASS_NAME + SPACE + EQUAL + SPACE + "builder" + OBJECT
+                + PERIOD + GET_METHOD_PREFIX + "Testname" + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN)));
+    }
+
+    /**
+     * Test for constrcutor start method.
+     */
+    @Test
+    public void getConstructorStartTest() {
+
+        String method = getConstructorStart(CLASS_NAME);
+        assertThat(true, is(method.contains(PUBLIC + SPACE + CLASS_NAME + IMPL + OPEN_PARENTHESIS + CLASS_NAME
+                + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT + CLOSE_PARENTHESIS + SPACE
+                + OPEN_CURLY_BRACKET + NEW_LINE)));
+    }
+
+    /**
+     * Test case for quals method.
+     */
+    @Test
+    public void getEqualsMethodTest() {
+
+        JavaAttributeInfo testAttr = getTestAttribute();
+        String method = getEqualsMethod(testAttr);
+        assertThat(true, is(method.contains(SIXTEEN_SPACE_INDENTATION + SPACE + OBJECT_STRING + SUFFIX_S + PERIOD
+                + EQUALS_STRING + OPEN_PARENTHESIS)));
+    }
+
+    /**
+     * Test for to string method.
+     */
+    @Test
+    public void getToStringMethodTest() {
+
+        JavaAttributeInfo testAttr = getTestAttribute();
+        String method = getToStringMethod(testAttr);
+        assertThat(true, is(method.equals(
+                TWELVE_SPACE_INDENTATION + PERIOD + ADD_STRING + OPEN_PARENTHESIS + QUOTES + testAttr.getAttributeName()
+                        + QUOTES + COMMA + SPACE + testAttr.getAttributeName() + CLOSE_PARENTHESIS)));
+    }
+
+    /**
+     * Test for getter method of class.
+     */
+    @Test
+    public void getGetterForClassTest() {
+
+        JavaAttributeInfo testAttr = getTestAttribute();
+        String method = getGetterForClass(testAttr);
+        assertThat(true, is(method.contains(PUBLIC + SPACE + STRING_DATA_TYPE + SPACE + GET_METHOD_PREFIX)));
+    }
+
+    /**
+     * Test for getter of interface.
+     */
+    @Test
+    public void getGetterForInterfaceTest() {
+
+        String method = getGetterForInterface(CLASS_NAME, STRING_DATA_TYPE, false);
+        assertThat(true, is(method.contains(STRING_DATA_TYPE + SPACE + GET_METHOD_PREFIX)));
+    }
+
+    /**
+     * Test case for setter method of class.
+     */
+    @Test
+    public void getSetterForClassTest() {
+
+        JavaAttributeInfo testAttr = getTestAttribute();
+        String method = getSetterForClass(testAttr, CLASS_NAME);
+        assertThat(true, is(
+                method.contains(PUBLIC + SPACE + CLASS_NAME + BUILDER + SPACE + SET_METHOD_PREFIX
+                        + getCaptialCase(ATTRIBUTE_NAME) + OPEN_PARENTHESIS + STRING_DATA_TYPE + SPACE
+                        + ATTRIBUTE_NAME)));
+    }
+
+    /**
+     * Test for setter method of interface.
+     */
+    @Test
+    public void getSetterForInterfaceTest() {
+
+        String method = getSetterForInterface(CLASS_NAME, STRING_DATA_TYPE, CLASS_NAME, false);
+        assertThat(true, is(method.contains(CLASS_NAME + BUILDER + SPACE + SET_METHOD_PREFIX + "Testname")));
+    }
+
+    /**
+     * Test case for of method.
+     */
+    @Test
+    public void getOfMethodest() {
+
+        JavaAttributeInfo testAttr = getTestAttribute();
+        String method = getOfMethod(CLASS_NAME, testAttr);
+        assertThat(true, is(method.contains(PUBLIC + SPACE + STATIC + SPACE + CLASS_NAME + SPACE + OF + OPEN_PARENTHESIS
+                + STRING_DATA_TYPE + SPACE + VALUE + CLOSE_PARENTHESIS)));
+    }
+
+    /**
+     * Test case for setter in type def class.
+     */
+    @Test
+    public void getSetterForTypeDefClassTest() {
+
+        JavaAttributeInfo testAttr = getTestAttribute();
+        String method = getSetterForTypeDefClass(testAttr);
+        assertThat(true, is(method.contains(PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX)));
+    }
+
+    /**
+     * Test case for over ride string.
+     */
+    @Test
+    public void getOverRideStringTest() {
+
+        String method = getOverRideString();
+        assertThat(true, is(method.contains(OVERRIDE)));
+    }
+
+    /**
+     * Returns java attribute.
+     *
+     * @return java attribute
+     */
+    private JavaAttributeInfo getTestAttribute() {
+
+        JavaAttributeInfo testAttr = new JavaAttributeInfo(getTestYangType(), ATTRIBUTE_NAME, false, false);
+        testAttr.setAttributeName(ATTRIBUTE_NAME);
+        testAttr.setAttributeType(getTestYangType());
+        testAttr.setImportInfo(getTestJavaQualifiedTypeInfo());
+        return testAttr;
+    }
+
+    /**
+     * Returns java qualified info.
+     *
+     * @return java qualified info
+     */
+    private JavaQualifiedTypeInfo getTestJavaQualifiedTypeInfo() {
+
+        JavaQualifiedTypeInfo info = new JavaQualifiedTypeInfo();
+        info.setPkgInfo(JAVA_LANG);
+        info.setClassInfo(STRING_DATA_TYPE);
+        return info;
+    }
+
+    /**
+     * Returns stub YANG type.
+     *
+     * @return test YANG type
+     */
+    private YangType<?> getTestYangType() {
+
+        YangType<?> attrType = new YangType<>();
+        attrType.setDataTypeName(STRING_DATA_TYPE);
+        attrType.setDataType(STRING);
+        return attrType;
+    }
+}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java
index 16c8b37..200a448 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java
@@ -1,3 +1,4 @@
+
 /*
  * Copyright 2016 Open Networking Laboratory
  *
@@ -16,70 +17,78 @@
 
 package org.onosproject.yangutils.utils.io.impl;
 
-import org.junit.Test;
-import org.junit.Rule;
-import org.junit.rules.ExpectedException;
-import org.onosproject.yangutils.utils.UtilConstants;
-
 import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 
 import org.apache.maven.project.MavenProject;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.utils.UtilConstants;
 import org.sonatype.plexus.build.incremental.BuildContext;
 import org.sonatype.plexus.build.incremental.DefaultBuildContext;
 
-import org.slf4j.Logger;
-import static org.slf4j.LoggerFactory.getLogger;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertNotNull;
 import static org.hamcrest.core.Is.is;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addPackageInfo;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addToSource;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.clean;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirectories;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast;
 
 /**
  * Unit tests for YANG io utils.
  */
 public final class YangIoUtilsTest {
 
-    public static String baseDir = "target/UnitTestCase";
+    private static final String BASE_DIR = "target/UnitTestCase";
+    private static final String CREATE_PATH = BASE_DIR + File.separator + "dir1/dir2/dir3/dir4/";
+    private static final String CHECK_STRING = "one, two, three, four, five, six";
+    private static final String TRIM_STRING = "one, two, three, four, five, ";
 
-    public static String createPath = baseDir + File.separator + "dir1/dir2/dir3/dir4/";
-
-    private final Logger log = getLogger(getClass());
-
+    /**
+     * Expected exceptions.
+     */
     @Rule
     public ExpectedException thrown = ExpectedException.none();
 
     /**
      * This test case checks whether the package-info file is created.
+     *
+     * @throws IOException when fails to do IO operations for test case
      */
     @Test
     public void addPackageInfoTest() throws IOException {
 
-        File dirPath = new File(createPath);
+        File dirPath = new File(CREATE_PATH);
         dirPath.mkdirs();
-        CopyrightHeader.parseCopyrightHeader();
-        YangIoUtils.addPackageInfo(dirPath, "check1", createPath);
+        addPackageInfo(dirPath, "check1", CREATE_PATH);
         File filePath = new File(dirPath + File.separator + "package-info.java");
         assertThat(filePath.isFile(), is(true));
     }
 
     /**
      * This test case checks with an additional info in the path.
+     *
+     * @throws IOException when fails to do IO operations for test case
      */
     @Test
     public void addPackageInfoWithPathTest() throws IOException {
 
-        File dirPath = new File(createPath);
+        File dirPath = new File(CREATE_PATH);
         dirPath.mkdirs();
-        CopyrightHeader.parseCopyrightHeader();
-        YangIoUtils.addPackageInfo(dirPath, "check1", "src/main/yangmodel/" + createPath);
+        addPackageInfo(dirPath, "check1", "src/main/yangmodel/" + CREATE_PATH);
         File filePath = new File(dirPath + File.separator + "package-info.java");
         assertThat(filePath.isFile(), is(true));
     }
 
     /**
      * This test case checks whether the package-info file is created when invalid path is given.
+     *
+     * @throws IOException when fails to do IO operations for test case
      */
     @Test
     public void addPackageInfoWithEmptyPathTest() throws IOException {
@@ -87,7 +96,7 @@
         File dirPath = new File("invalid/check");
         thrown.expect(IOException.class);
         thrown.expectMessage("Exception occured while creating package info file.");
-        YangIoUtils.addPackageInfo(dirPath, "check1", createPath);
+        addPackageInfo(dirPath, "check1", CREATE_PATH);
         File filePath1 = new File(dirPath + File.separator + "package-info.java");
         assertThat(filePath1.isFile(), is(false));
     }
@@ -116,26 +125,30 @@
 
     /**
      * This test case checks if the directory is cleaned.
+     *
+     * @throws IOException when fails to do IO operations for test case
      */
     @Test
     public void cleanGeneratedDirTest() throws IOException {
 
-        File baseDirPath = new File(baseDir);
-        File createNewDir = new File(baseDir + File.separator + UtilConstants.YANG_GEN_DIR);
+        File baseDirPath = new File(BASE_DIR);
+        File createNewDir = new File(BASE_DIR + File.separator + UtilConstants.YANG_GEN_DIR);
         createNewDir.mkdirs();
         File createFile = new File(createNewDir + File.separator + "check1.java");
         createFile.createNewFile();
-        YangIoUtils.clean(baseDirPath.getAbsolutePath());
+        clean(baseDirPath.getAbsolutePath());
     }
 
     /**
      * This test case checks the cleaning method when an invalid path is provided.
+     *
+     * @throws IOException when fails to do IO operations for test case
      */
     @Test
     public void cleanWithInvalidDirTest() throws IOException {
 
-        File baseDirPath = new File(baseDir + "invalid");
-        YangIoUtils.clean(baseDirPath.getAbsolutePath());
+        File baseDirPath = new File(BASE_DIR + "invalid");
+        clean(baseDirPath.getAbsolutePath());
     }
 
     /**
@@ -144,20 +157,30 @@
     @Test
     public void createDirectoryTest() {
 
-        File dirPath = YangIoUtils.createDirectories(createPath);
+        File dirPath = createDirectories(CREATE_PATH);
         assertThat(dirPath.isDirectory(), is(true));
     }
 
     /**
-     * This testcase checks whether the source is getting added.
+     * This test case checks whether the source is getting added.
      */
     @Test
     public void testForAddSource() {
 
         MavenProject project = new MavenProject();
         BuildContext context = new DefaultBuildContext();
-        File sourceDir = new File(baseDir + File.separator + "yang");
+        File sourceDir = new File(BASE_DIR + File.separator + "yang");
         sourceDir.mkdirs();
-        YangIoUtils.addToSource(sourceDir.toString(), project, context);
+        addToSource(sourceDir.toString(), project, context);
+    }
+
+    /*
+     * Unit test case for trim at last method.
+     */
+    @Test
+    public void testForTrimAtLast() {
+
+        String test = trimAtLast(CHECK_STRING, "six");
+        assertThat(test.contains(TRIM_STRING), is(true));
     }
 }