[ONOS-5142] Defect fix

Change-Id: Id01634505630179aa4605b76c5d2be4b947b5dac
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfoTranslator.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfoTranslator.java
index 27cba78..4ffd942 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfoTranslator.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfoTranslator.java
@@ -28,8 +28,11 @@
 
 import com.google.common.base.MoreObjects;
 
+import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BINARY;
 import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaImportClass;
 import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaImportPackage;
+import static org.onosproject.yangutils.utils.UtilConstants.BASE64;
+import static org.onosproject.yangutils.utils.UtilConstants.COLLECTION_IMPORTS;
 
 /**
  * Represents the information about individual imports in the generated file.
@@ -177,10 +180,15 @@
          */
         JavaQualifiedTypeInfoTranslator qualifiedInfoOfFromString = new JavaQualifiedTypeInfoTranslator();
 
-        qualifiedInfoOfFromString.setClassInfo(
-                getJavaImportClass(referredTypesAttrInfo.getAttributeType(), true, conflictResolver));
-        qualifiedInfoOfFromString.setPkgInfo(
-                getJavaImportPackage(referredTypesAttrInfo.getAttributeType(), true, conflictResolver));
+        if (referredTypesAttrInfo.getAttributeType().getDataType() == BINARY) {
+            qualifiedInfoOfFromString.setClassInfo(BASE64);
+            qualifiedInfoOfFromString.setPkgInfo(COLLECTION_IMPORTS);
+        } else {
+            qualifiedInfoOfFromString.setClassInfo(
+                    getJavaImportClass(referredTypesAttrInfo.getAttributeType(), true, conflictResolver));
+            qualifiedInfoOfFromString.setPkgInfo(
+                    getJavaImportPackage(referredTypesAttrInfo.getAttributeType(), true, conflictResolver));
+        }
         return qualifiedInfoOfFromString;
     }
 
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/UnionTranslatorTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/UnionTranslatorTest.java
index 73f9c0a..11c1818 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/UnionTranslatorTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/UnionTranslatorTest.java
@@ -209,5 +209,28 @@
         deleteDirectory("target/unionTranslator/");
     }
 
+    /**
+     * Unit test case to test Union with binary type.
+     *
+     * @throws IOException when fails to do IO operations
+     * @throws MojoExecutionException when fails to do mojo operations
+     */
+    @Test
+    public void processUnionWithBinaryTypes() throws IOException,
+            MojoExecutionException {
+        String searchDir = "src/test/resources/unionTranslator/unionwithbinary";
+        YangUtilManager utilManager = new YangUtilManager();
+        utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+        utilManager.parseYangFileInfoSet();
+        utilManager.createYangNodeSet();
+        utilManager.resolveDependenciesUsingLinker();
+
+        YangPluginConfig yangPluginConfig = new YangPluginConfig();
+        yangPluginConfig.setCodeGenDir("target/unionTranslator/");
+
+        utilManager.translateToJava(yangPluginConfig);
+        deleteDirectory("target/unionTranslator/");
+    }
+
     // TODO enhance the test cases, after having a framework of translator test.
 }
diff --git a/plugin/src/test/resources/unionTranslator/unionwithbinary/test.yang b/plugin/src/test/resources/unionTranslator/unionwithbinary/test.yang
new file mode 100644
index 0000000..d2c9966
--- /dev/null
+++ b/plugin/src/test/resources/unionTranslator/unionwithbinary/test.yang
@@ -0,0 +1,15 @@
+module moduletest {
+  yang-version 1;
+  namespace "onos-yang-20:level1:newlevel";
+  prefix test;
+  organization "huawei";
+  contact "adarsh.m@huawei.com";
+  description "leaf scenario";
+  revision 2015-02-05;
+  leaf eleven {
+    type union { 
+      type binary;
+      type int8;
+    }
+  }
+}