carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [1/2] incubator-carbondata git commit: Added unit test cases for core.carbon.metadata package
Date Mon, 12 Dec 2016 06:20:17 GMT
Repository: incubator-carbondata
Updated Branches:
  refs/heads/master 9e0982ad0 -> 79c34ee7e


Added unit test cases for core.carbon.metadata package


Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/7ae127f9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/7ae127f9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/7ae127f9

Branch: refs/heads/master
Commit: 7ae127f9f7a78981e74e455a40aa658508e042de
Parents: 9e0982a
Author: Geetika gupta <geetika.gupta@knoldus.in>
Authored: Wed Dec 7 17:42:43 2016 +0530
Committer: ravipesala <ravi.pesala@gmail.com>
Committed: Mon Dec 12 11:49:24 2016 +0530

----------------------------------------------------------------------
 .../carbon/metadata/CarbonMetadataTest.java     |  169 +-
 .../ThriftWrapperSchemaConverterImplTest.java   | 1847 ++++++++++++++++++
 2 files changed, 1991 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7ae127f9/core/src/test/java/org/apache/carbondata/core/carbon/metadata/CarbonMetadataTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/metadata/CarbonMetadataTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/metadata/CarbonMetadataTest.java
index a78a2af..85ae9b4 100644
--- a/core/src/test/java/org/apache/carbondata/core/carbon/metadata/CarbonMetadataTest.java
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/metadata/CarbonMetadataTest.java
@@ -24,84 +24,100 @@ import java.util.UUID;
 
 import org.apache.carbondata.core.carbon.metadata.datatype.DataType;
 import org.apache.carbondata.core.carbon.metadata.encoder.Encoding;
+import org.apache.carbondata.core.carbon.metadata.schema.table.CarbonTable;
 import org.apache.carbondata.core.carbon.metadata.schema.table.TableInfo;
 import org.apache.carbondata.core.carbon.metadata.schema.table.TableSchema;
+import org.apache.carbondata.core.carbon.metadata.schema.table.column.CarbonDimension;
 import org.apache.carbondata.core.carbon.metadata.schema.table.column.ColumnSchema;
 import org.apache.carbondata.core.constants.CarbonCommonConstants;
 
-import junit.framework.TestCase;
+import mockit.Mock;
+import mockit.MockUp;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-public class CarbonMetadataTest extends TestCase {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
-  private CarbonMetadata carbonMetadata;
+public class CarbonMetadataTest {
 
-  private String tableUniqueName;
+  private static CarbonMetadata carbonMetadata;
 
-  @BeforeClass public void setUp() {
+  private static String tableUniqueName;
+
+  @BeforeClass public static void setUp() {
     carbonMetadata = CarbonMetadata.getInstance();
     carbonMetadata.loadTableMetadata(getTableInfo(10000));
     tableUniqueName = "carbonTestDatabase_carbonTestTable";
   }
 
-  @AfterClass public void tearDown() {
+  @AfterClass public static void tearDown() {
     carbonMetadata.removeTable(tableUniqueName);
     carbonMetadata = null;
   }
 
   @Test public void testOnlyOneInstanceIsCreatedofCarbonMetadata() {
     CarbonMetadata carbonMetadata1 = CarbonMetadata.getInstance();
-    assertTrue(carbonMetadata == carbonMetadata1);
+    assertEquals(carbonMetadata, carbonMetadata1);
   }
 
   @Test public void testNumberOfTablesPresentInTheMetadata() {
-    assertEquals(1, carbonMetadata.getNumberOfTables());
+    int expectedResult = 1;
+    assertEquals(expectedResult, carbonMetadata.getNumberOfTables());
   }
 
   @Test public void testGetCarbonTableReturingProperCarbonTable() {
-    assertTrue(null != carbonMetadata.getCarbonTable(tableUniqueName));
+    assertNotNull(carbonMetadata.getCarbonTable(tableUniqueName));
   }
 
   @Test public void testGetCarbonTableReturingNullWhenInvalidNameIsPassed() {
-    assertTrue(null == carbonMetadata.getCarbonTable("notpresent"));
+    assertNull(carbonMetadata.getCarbonTable("notpresent"));
   }
 
   @Test public void testGetCarbonTableReturingProperTableWithProperDimensionCount() {
-    assertEquals(1,
+    int expectedResult = 1;
+    assertEquals(expectedResult,
         carbonMetadata.getCarbonTable(tableUniqueName).getNumberOfDimensions("carbonTestTable"));
   }
 
   @Test public void testGetCarbonTableReturingProperTableWithProperMeasureCount() {
-    assertEquals(1,
+    int expectedResult = 1;
+    assertEquals(expectedResult,
         carbonMetadata.getCarbonTable(tableUniqueName).getNumberOfMeasures("carbonTestTable"));
   }
 
   @Test public void testGetCarbonTableReturingProperTableWithProperDatabaseName() {
-    assertEquals("carbonTestDatabase",
-        carbonMetadata.getCarbonTable(tableUniqueName).getDatabaseName());
+    String expectedResult = "carbonTestDatabase";
+    assertEquals(expectedResult, carbonMetadata.getCarbonTable(tableUniqueName).getDatabaseName());
   }
 
   @Test public void testGetCarbonTableReturingProperTableWithProperFactTableName() {
-    assertEquals("carbonTestTable",
-        carbonMetadata.getCarbonTable(tableUniqueName).getFactTableName());
+    String expectedResult = "carbonTestTable";
+    assertEquals(expectedResult, carbonMetadata.getCarbonTable(tableUniqueName).getFactTableName());
   }
 
   @Test public void testGetCarbonTableReturingProperTableWithProperTableUniqueName() {
-    assertEquals("carbonTestDatabase_carbonTestTable",
+    String expectedResult = "carbonTestDatabase_carbonTestTable";
+    assertEquals(expectedResult,
         carbonMetadata.getCarbonTable(tableUniqueName).getTableUniqueName());
   }
 
   @Test public void testloadMetadataTableWhenTableIsAlreadyExistsAndTimeStampIsChanged() {
-    assertEquals(10000, carbonMetadata.getCarbonTable(tableUniqueName).getTableLastUpdatedTime());
+    long expectedLastUpdatedTime = 10000L;
+    assertEquals(expectedLastUpdatedTime,
+        carbonMetadata.getCarbonTable(tableUniqueName).getTableLastUpdatedTime());
     CarbonMetadata carbonMetadata1 = CarbonMetadata.getInstance();
     carbonMetadata1.loadTableMetadata(getTableInfo(100001));
-    assertEquals(100001, carbonMetadata.getCarbonTable(tableUniqueName).getTableLastUpdatedTime());
-    assertEquals(1, carbonMetadata.getNumberOfTables());
+    long expectedTableLastUpdatedTime = 100001L;
+    assertEquals(expectedTableLastUpdatedTime,
+        carbonMetadata.getCarbonTable(tableUniqueName).getTableLastUpdatedTime());
+    long expectedNumberOfTables = 1;
+    assertEquals(expectedNumberOfTables, carbonMetadata.getNumberOfTables());
   }
 
-  private ColumnSchema getColumnarDimensionColumn() {
+  private static ColumnSchema getColumnarDimensionColumn() {
     ColumnSchema dimColumn = new ColumnSchema();
     dimColumn.setColumnar(true);
     dimColumn.setColumnName("IMEI");
@@ -116,7 +132,7 @@ public class CarbonMetadataTest extends TestCase {
     return dimColumn;
   }
 
-  private ColumnSchema getColumnarMeasureColumn() {
+  private static ColumnSchema getColumnarMeasureColumn() {
     ColumnSchema dimColumn = new ColumnSchema();
     dimColumn.setAggregateFunction("SUM");
     dimColumn.setColumnName("IMEI_COUNT");
@@ -125,7 +141,7 @@ public class CarbonMetadataTest extends TestCase {
     return dimColumn;
   }
 
-  private TableSchema getTableSchema() {
+  private static TableSchema getTableSchema() {
     TableSchema tableSchema = new TableSchema();
     List<ColumnSchema> columnSchemaList = new ArrayList<ColumnSchema>();
     columnSchemaList.add(getColumnarDimensionColumn());
@@ -136,7 +152,7 @@ public class CarbonMetadataTest extends TestCase {
     return tableSchema;
   }
 
-  private TableInfo getTableInfo(long timeStamp) {
+  private static TableInfo getTableInfo(long timeStamp) {
     TableInfo info = new TableInfo();
     info.setDatabaseName("carbonTestDatabase");
     info.setLastUpdatedTime(timeStamp);
@@ -145,4 +161,107 @@ public class CarbonMetadataTest extends TestCase {
     info.setStorePath("/test/store");
     return info;
   }
-}
+
+  @Test public void testGetCarbonDimensionBasedOnColIdentifier() {
+    CarbonTable carbonTable = new CarbonTable();
+    String columnIdentifier = "1";
+    final List<CarbonDimension> carbonDimensions = new ArrayList();
+    ColumnSchema colSchema1 = new ColumnSchema();
+    ColumnSchema colSchema2 = new ColumnSchema();
+    colSchema1.setColumnUniqueId("1");
+    colSchema2.setColumnUniqueId("2");
+    carbonDimensions.add(new CarbonDimension(colSchema1, 1, 1, 2, 1));
+    carbonDimensions.add(new CarbonDimension(colSchema2, 2, 2, 2, 2));
+    new MockUp<CarbonTable>() {
+      @Mock public String getFactTableName() {
+        return "carbonTestTable";
+      }
+
+      @Mock public List<CarbonDimension> getDimensionByTableName(String tableName) {
+        return carbonDimensions;
+      }
+    };
+    CarbonDimension expectedResult = carbonDimensions.get(0);
+    CarbonDimension actualResult =
+        carbonMetadata.getCarbonDimensionBasedOnColIdentifier(carbonTable, columnIdentifier);
+    assertEquals(expectedResult, actualResult);
+  }
+
+  @Test
+  public void testGetCarbonDimensionBasedOnColIdentifierWhenChildDimensionColumnEqualsColumnIdentifier() {
+    CarbonTable carbonTable = new CarbonTable();
+    String columnIdentifier = "9";
+    final List<CarbonDimension> carbonDimensions = new ArrayList();
+    ColumnSchema colSchema1 = new ColumnSchema();
+    ColumnSchema colSchema2 = new ColumnSchema();
+    colSchema1.setColumnUniqueId("1");
+    carbonDimensions.add(new CarbonDimension(colSchema1, 1, 1, 2, 1));
+    final List<CarbonDimension> carbonChildDimensions = new ArrayList();
+    ColumnSchema colSchema3 = new ColumnSchema();
+    colSchema3.setColumnUniqueId("9");
+    colSchema2.setColumnUniqueId("2");
+    carbonChildDimensions.add(new CarbonDimension(colSchema3, 1, 1, 2, 1));
+    new MockUp<CarbonTable>() {
+      @Mock public String getFactTableName() {
+        return "carbonTestTable";
+      }
+
+      @Mock public List<CarbonDimension> getDimensionByTableName(String tableName) {
+        return carbonDimensions;
+      }
+    };
+
+    new MockUp<CarbonDimension>() {
+      @Mock public int numberOfChild() {
+        return 1;
+      }
+
+      @Mock public List<CarbonDimension> getListOfChildDimensions() {
+        return carbonChildDimensions;
+      }
+
+    };
+
+    CarbonDimension expectedResult = carbonChildDimensions.get(0);
+    CarbonDimension actualResult =
+        carbonMetadata.getCarbonDimensionBasedOnColIdentifier(carbonTable, columnIdentifier);
+    assertEquals(expectedResult, actualResult);
+  }
+
+  @Test public void testGetCarbonDimensionBasedOnColIdentifierNullCase() {
+    CarbonTable carbonTable = new CarbonTable();
+    String columnIdentifier = "3";
+    final List<CarbonDimension> carbonDimensions = new ArrayList();
+    ColumnSchema colSchema1 = new ColumnSchema();
+    colSchema1.setColumnUniqueId("1");
+    colSchema1.setNumberOfChild(1);
+    CarbonDimension carbonDimension = new CarbonDimension(colSchema1, 1, 1, 2, 1);
+    carbonDimensions.add(carbonDimension);
+    final List<CarbonDimension> carbonChildDimensions = new ArrayList();
+    ColumnSchema colSchema2 = new ColumnSchema();
+    colSchema2.setColumnUniqueId("9");
+    colSchema2.setNumberOfChild(0);
+    carbonChildDimensions.add(new CarbonDimension(colSchema2, 1, 1, 2, 1));
+
+    new MockUp<CarbonTable>() {
+      @Mock public String getFactTableName() {
+        return "carbonTestTable";
+      }
+
+      @Mock public List<CarbonDimension> getDimensionByTableName(String tableName) {
+        return carbonDimensions;
+      }
+    };
+
+    new MockUp<CarbonDimension>() {
+      @Mock public List<CarbonDimension> getListOfChildDimensions() {
+        return carbonChildDimensions;
+      }
+    };
+
+    CarbonDimension result =
+        carbonMetadata.getCarbonDimensionBasedOnColIdentifier(carbonTable, columnIdentifier);
+    assertNull(result);
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7ae127f9/core/src/test/java/org/apache/carbondata/core/carbon/metadata/converter/ThriftWrapperSchemaConverterImplTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/metadata/converter/ThriftWrapperSchemaConverterImplTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/metadata/converter/ThriftWrapperSchemaConverterImplTest.java
new file mode 100644
index 0000000..4022ff4
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/metadata/converter/ThriftWrapperSchemaConverterImplTest.java
@@ -0,0 +1,1847 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.carbondata.core.carbon.metadata.converter;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.carbondata.core.carbon.metadata.datatype.DataType;
+import org.apache.carbondata.core.carbon.metadata.encoder.Encoding;
+import org.apache.carbondata.core.carbon.metadata.schema.SchemaEvolution;
+import org.apache.carbondata.core.carbon.metadata.schema.SchemaEvolutionEntry;
+import org.apache.carbondata.core.carbon.metadata.schema.table.TableInfo;
+import org.apache.carbondata.core.carbon.metadata.schema.table.TableSchema;
+import org.apache.carbondata.core.carbon.metadata.schema.table.column.ColumnSchema;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ThriftWrapperSchemaConverterImplTest {
+
+  private static ThriftWrapperSchemaConverterImpl thriftWrapperSchemaConverter = null;
+  private static org.apache.carbondata.format.SchemaEvolutionEntry schemaEvolEntry = null;
+  private static org.apache.carbondata.format.ColumnSchema thriftColumnSchema = null;
+  private static List<ColumnSchema> columnSchemas = null;
+  private static List<SchemaEvolutionEntry> schemaEvolutionEntries = null;
+  private static List<org.apache.carbondata.format.ColumnSchema> thriftColumnSchemas = null;
+  private static List<org.apache.carbondata.format.SchemaEvolutionEntry>
+      thriftSchemaEvolutionEntries = null;
+  private static org.apache.carbondata.format.SchemaEvolution schemaEvol = null;
+  private static List<org.apache.carbondata.format.Encoding> encoders = null;
+  private static List<Encoding> encodings = null;
+  private static Map columnPropertyMap = null;
+  private static org.apache.carbondata.format.TableSchema tabSchema = null;
+
+  @BeforeClass public static void setUp() {
+
+    thriftWrapperSchemaConverter = new ThriftWrapperSchemaConverterImpl();
+    schemaEvolEntry = new org.apache.carbondata.format.SchemaEvolutionEntry();
+    schemaEvolutionEntries = new ArrayList();
+    schemaEvolutionEntries.add(new SchemaEvolutionEntry());
+    columnSchemas = new ArrayList();
+    columnSchemas.add(new ColumnSchema());
+    encodings = new ArrayList<>();
+    encodings.add(Encoding.INVERTED_INDEX);
+    encodings.add(Encoding.DELTA);
+    encodings.add(Encoding.BIT_PACKED);
+    encodings.add(Encoding.DICTIONARY);
+    encodings.add(Encoding.RLE);
+    encodings.add(Encoding.DIRECT_DICTIONARY);
+    encoders = new ArrayList<org.apache.carbondata.format.Encoding>();
+    encoders.add(org.apache.carbondata.format.Encoding.INVERTED_INDEX);
+    encoders.add(org.apache.carbondata.format.Encoding.DELTA);
+    encoders.add(org.apache.carbondata.format.Encoding.BIT_PACKED);
+    encoders.add(org.apache.carbondata.format.Encoding.DICTIONARY);
+    encoders.add(org.apache.carbondata.format.Encoding.RLE);
+    encoders.add(org.apache.carbondata.format.Encoding.DIRECT_DICTIONARY);
+
+    columnPropertyMap = new HashMap<String, String>();
+    columnPropertyMap.put("property", "value");
+    thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRING,
+            "columnName", "1", true, encoders, true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+    thriftColumnSchemas = new ArrayList<org.apache.carbondata.format.ColumnSchema>();
+    thriftColumnSchemas.add(thriftColumnSchema);
+    thriftSchemaEvolutionEntries = new ArrayList<>();
+    thriftSchemaEvolutionEntries.add(schemaEvolEntry);
+    schemaEvol = new org.apache.carbondata.format.SchemaEvolution(thriftSchemaEvolutionEntries);
+
+    new MockUp<SchemaEvolution>() {
+      @Mock public List<SchemaEvolutionEntry> getSchemaEvolutionEntryList() {
+        return schemaEvolutionEntries;
+      }
+    };
+
+    new MockUp<org.apache.carbondata.format.SchemaEvolutionEntry>() {
+      @Mock public org.apache.carbondata.format.SchemaEvolutionEntry setAdded(
+          List<org.apache.carbondata.format.ColumnSchema> added) {
+        return schemaEvolEntry;
+      }
+
+      @Mock public org.apache.carbondata.format.SchemaEvolutionEntry setRemoved(
+          List<org.apache.carbondata.format.ColumnSchema> removed) {
+        return schemaEvolEntry;
+      }
+
+      @Mock public long getTime_stamp() {
+        long time = 1112745600000L;
+        return time;
+      }
+
+      @Mock public List<org.apache.carbondata.format.ColumnSchema> getAdded() {
+        return thriftColumnSchemas;
+      }
+
+      @Mock public List<org.apache.carbondata.format.ColumnSchema> getRemoved() {
+        return thriftColumnSchemas;
+      }
+
+    };
+
+    new MockUp<org.apache.carbondata.format.ColumnSchema>() {
+      @Mock
+      public org.apache.carbondata.format.ColumnSchema setColumn_group_id(int column_group_id) {
+        return thriftColumnSchema;
+      }
+
+      @Mock public org.apache.carbondata.format.ColumnSchema setScale(int scale) {
+        return thriftColumnSchema;
+      }
+
+      @Mock public org.apache.carbondata.format.ColumnSchema setPrecision(int precision) {
+        return thriftColumnSchema;
+      }
+
+      @Mock public org.apache.carbondata.format.ColumnSchema setNum_child(int num_child) {
+        return thriftColumnSchema;
+      }
+
+      @Mock
+      public org.apache.carbondata.format.ColumnSchema setDefault_value(byte[] default_value) {
+        return thriftColumnSchema;
+      }
+
+      @Mock public org.apache.carbondata.format.ColumnSchema setColumnProperties(
+          Map<String, String> columnProperties) {
+        return thriftColumnSchema;
+      }
+
+      @Mock public org.apache.carbondata.format.ColumnSchema setInvisible(boolean invisible) {
+        return thriftColumnSchema;
+      }
+
+      @Mock public org.apache.carbondata.format.ColumnSchema setColumnReferenceId(
+          String columnReferenceId) {
+        return thriftColumnSchema;
+      }
+
+      @Mock public String getColumn_id() {
+        return "1";
+      }
+
+      @Mock public String getColumn_name() {
+        return "columnName";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimension() {
+        return true;
+      }
+
+      @Mock public List<org.apache.carbondata.format.Encoding> getEncoders() {
+        return encoders;
+      }
+
+      @Mock public int getNum_child() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getColumn_group_id() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefault_value() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public String getAggregate_function() {
+        return "";
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+
+    };
+
+    final Map mapTableProperties = new HashMap<String, String>();
+    tabSchema = new org.apache.carbondata.format.TableSchema();
+
+    new MockUp<org.apache.carbondata.format.TableSchema>() {
+      @Mock public org.apache.carbondata.format.TableSchema setTableProperties(
+          Map<String, String> tableProperties) {
+        return tabSchema;
+      }
+
+      @Mock public String getTable_id() {
+        return "1";
+      }
+
+      @Mock public Map<String, String> getTableProperties() {
+        return mapTableProperties;
+      }
+
+      @Mock public List<org.apache.carbondata.format.ColumnSchema> getTable_columns() {
+        return thriftColumnSchemas;
+      }
+
+      @Mock public org.apache.carbondata.format.SchemaEvolution getSchema_evolution() {
+        return schemaEvol;
+      }
+    };
+    new MockUp<org.apache.carbondata.format.SchemaEvolution>() {
+      @Mock
+      public List<org.apache.carbondata.format.SchemaEvolutionEntry> getSchema_evolution_history() {
+        return thriftSchemaEvolutionEntries;
+      }
+    };
+  }
+
+  @Test public void testFromWrapperToExternalSchemaEvolutionEntry() {
+    final SchemaEvolutionEntry schemaEvolutionEntry = new SchemaEvolutionEntry();
+
+    new MockUp<SchemaEvolutionEntry>() {
+      @Mock public List<ColumnSchema> getAdded() {
+        return columnSchemas;
+      }
+
+      @Mock public List<ColumnSchema> getRemoved() {
+        return columnSchemas;
+      }
+    };
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.BOOLEAN;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+    };
+
+    org.apache.carbondata.format.SchemaEvolutionEntry actualResult = thriftWrapperSchemaConverter
+        .fromWrapperToExternalSchemaEvolutionEntry(schemaEvolutionEntry);
+    assertEquals(schemaEvolEntry, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalSchemaEvolution() {
+    SchemaEvolution schemaEvolution = new SchemaEvolution();
+
+    new MockUp<SchemaEvolutionEntry>() {
+      @Mock public List<ColumnSchema> getAdded() {
+        return columnSchemas;
+      }
+
+      @Mock public List<ColumnSchema> getRemoved() {
+        return columnSchemas;
+      }
+    };
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.BOOLEAN;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    List<org.apache.carbondata.format.SchemaEvolutionEntry> thriftSchemaEvolutionEntries =
+        new ArrayList<>();
+    thriftSchemaEvolutionEntries.add(schemaEvolEntry);
+
+    org.apache.carbondata.format.SchemaEvolution actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalSchemaEvolution(schemaEvolution);
+
+    org.apache.carbondata.format.SchemaEvolution expectedResult =
+        new org.apache.carbondata.format.SchemaEvolution(thriftSchemaEvolutionEntries);
+    assertEquals(expectedResult, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalColumnSchema() {
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.BOOLEAN;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    org.apache.carbondata.format.ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
+    assertEquals(thriftColumnSchema, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalColumnSchemaForStringDatatype() {
+
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRING,
+            "columnName", "1", true, encoders, true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.STRING;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+    org.apache.carbondata.format.ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
+    assertEquals(thriftColumnSchema, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalColumnSchemaForIntDatatype() {
+
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.INT,
+            "columnName", "1", true, encoders, true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.INT;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+    org.apache.carbondata.format.ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
+    assertEquals(thriftColumnSchema, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalColumnSchemaForShortDatatype() {
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.SHORT,
+            "columnName", "1", true, encoders, true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.SHORT;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+    org.apache.carbondata.format.ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
+    assertEquals(thriftColumnSchema, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalColumnSchemaForLongDatatype() {
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.LONG,
+            "columnName", "1", true, encoders, true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.LONG;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+    org.apache.carbondata.format.ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
+    assertEquals(thriftColumnSchema, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalColumnSchemaForDoubleDatatype() {
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.DOUBLE,
+            "columnName", "1", true, encoders, true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.DOUBLE;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+    org.apache.carbondata.format.ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
+    assertEquals(thriftColumnSchema, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalColumnSchemaForDecimalDatatype() {
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.DECIMAL,
+            "columnName", "1", true, encoders, true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.DECIMAL;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+    org.apache.carbondata.format.ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
+    assertEquals(thriftColumnSchema, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalColumnSchemaForTimestampDatatype() {
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(
+            org.apache.carbondata.format.DataType.TIMESTAMP, "columnName", "1", true, encoders,
+            true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.TIMESTAMP;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+    org.apache.carbondata.format.ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
+    assertEquals(thriftColumnSchema, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalColumnSchemaForArrayDatatype() {
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.ARRAY,
+            "columnName", "1", true, encoders, true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.ARRAY;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+    org.apache.carbondata.format.ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
+    assertEquals(thriftColumnSchema, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalColumnSchemaForStructDatatype() {
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRUCT,
+            "columnName", "1", true, encoders, true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.STRUCT;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+    org.apache.carbondata.format.ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
+    assertEquals(thriftColumnSchema, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalColumnSchemaForDatatypeNullCase() {
+
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(null, "columnName", "1", true, encoders,
+            true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return null;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+    org.apache.carbondata.format.ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
+    assertEquals(thriftColumnSchema, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalColumnSchemaWhenEncoderIsNull() {
+
+    final List<Encoding> encoding = new ArrayList<>();
+    encoding.add(Encoding.INVERTED_INDEX);
+    encoding.add(null);
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encoding;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.BOOLEAN;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    List<Encoding> encodings = null;
+    encodings = new ArrayList<>();
+    encodings.add(Encoding.INVERTED_INDEX);
+    encodings.add(null);
+    List<org.apache.carbondata.format.Encoding> encoders = null;
+    encoders = new ArrayList<org.apache.carbondata.format.Encoding>();
+    encoders.add(org.apache.carbondata.format.Encoding.INVERTED_INDEX);
+    encoders.add(null);
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema = null;
+    thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRING,
+            "columnName", "1", true, encoders, true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+    org.apache.carbondata.format.ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
+    assertEquals(thriftColumnSchema, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalTableSchema() {
+    TableSchema wrapperTableSchema = new TableSchema();
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.BOOLEAN;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    new MockUp<SchemaEvolutionEntry>() {
+      @Mock public List<ColumnSchema> getAdded() {
+        return columnSchemas;
+      }
+
+      @Mock public List<ColumnSchema> getRemoved() {
+        return columnSchemas;
+      }
+    };
+
+    final SchemaEvolution schemaEvolution = new SchemaEvolution();
+    final Map mapTableProperties = new HashMap<String, String>();
+
+    new MockUp<TableSchema>() {
+      @Mock public List<ColumnSchema> getListOfColumns() {
+        return columnSchemas;
+      }
+
+      @Mock public SchemaEvolution getSchemaEvalution() {
+        return schemaEvolution;
+      }
+
+      @Mock public String getTableId() {
+        return "tableId";
+      }
+
+      @Mock public Map<String, String> getTableProperties() {
+        return mapTableProperties;
+      }
+
+    };
+    org.apache.carbondata.format.TableSchema expectedResult =
+        new org.apache.carbondata.format.TableSchema("tableId", thriftColumnSchemas, schemaEvol);
+    org.apache.carbondata.format.TableSchema actualResult =
+        thriftWrapperSchemaConverter.fromWrapperToExternalTableSchema(wrapperTableSchema);
+    assertEquals(expectedResult, actualResult);
+  }
+
+  @Test public void testFromWrapperToExternalTableInfo() {
+    TableInfo wrapperTableInfo = new TableInfo();
+    String dbName = "dbName";
+    String tableName = "TableName";
+    final TableSchema wrapperTableSchema = new TableSchema();
+    final List<TableSchema> tableSchemas = new ArrayList<>();
+    tableSchemas.add(wrapperTableSchema);
+
+    new MockUp<SchemaEvolutionEntry>() {
+      @Mock public List<ColumnSchema> getAdded() {
+        return columnSchemas;
+      }
+
+      @Mock public List<ColumnSchema> getRemoved() {
+        return columnSchemas;
+      }
+    };
+
+    new MockUp<ColumnSchema>() {
+      @Mock public List<Encoding> getEncodingList() {
+        return encodings;
+      }
+
+      @Mock public int getSchemaOrdinal() {
+        return 1;
+      }
+
+      @Mock public DataType getDataType() {
+        return DataType.BOOLEAN;
+      }
+
+      @Mock public String getColumnName() {
+        return "columnName";
+      }
+
+      @Mock public String getColumnUniqueId() {
+        return "1";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimensionColumn() {
+        return true;
+      }
+
+      @Mock public int getColumnGroupId() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getNumberOfChild() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefaultValue() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+    };
+
+    new MockUp<TableInfo>() {
+      @Mock public TableSchema getFactTable() {
+        return wrapperTableSchema;
+      }
+
+      @Mock public List<TableSchema> getAggregateTableList() {
+        return tableSchemas;
+      }
+    };
+
+    new MockUp<TableSchema>() {
+      @Mock public List<ColumnSchema> getListOfColumns() {
+        return columnSchemas;
+      }
+
+      final SchemaEvolution schemaEvolution = new SchemaEvolution();
+      final Map mapTableProperties = new HashMap<String, String>();
+
+      @Mock public SchemaEvolution getSchemaEvalution() {
+        return schemaEvolution;
+      }
+
+      @Mock public String getTableId() {
+        return "tableId";
+      }
+
+      @Mock public Map<String, String> getTableProperties() {
+        return mapTableProperties;
+      }
+
+    };
+    org.apache.carbondata.format.TableSchema thriftFactTable =
+        new org.apache.carbondata.format.TableSchema("tableId", thriftColumnSchemas, schemaEvol);
+    List<org.apache.carbondata.format.TableSchema> thriftAggTables = new ArrayList<>();
+    thriftAggTables.add(thriftFactTable);
+    org.apache.carbondata.format.TableInfo actualResult = thriftWrapperSchemaConverter
+        .fromWrapperToExternalTableInfo(wrapperTableInfo, dbName, tableName);
+    org.apache.carbondata.format.TableInfo expectedResult =
+        new org.apache.carbondata.format.TableInfo(thriftFactTable, thriftAggTables);
+    assertEquals(expectedResult, actualResult);
+  }
+
+  @Test public void testFromExternalToWrapperSchemaEvolutionEntry() {
+long time =1112745600000L;
+    ColumnSchema wrapperColumnSchema = new ColumnSchema();
+    wrapperColumnSchema.setColumnUniqueId("1");
+    wrapperColumnSchema.setColumnName("columnName");
+    wrapperColumnSchema.setColumnar(true);
+    wrapperColumnSchema.setDataType(DataType.STRING);
+    wrapperColumnSchema.setDimensionColumn(true);
+    wrapperColumnSchema.setEncodingList(encodings);
+    wrapperColumnSchema.setNumberOfChild(1);
+    wrapperColumnSchema.setPrecision(1);
+    wrapperColumnSchema.setColumnGroup(1);
+    wrapperColumnSchema.setScale(1);
+    wrapperColumnSchema.setDefaultValue(new byte[] { 1, 2 });
+    wrapperColumnSchema.setAggregateFunction("");
+    wrapperColumnSchema.setColumnProperties(columnPropertyMap);
+    wrapperColumnSchema.setInvisible(true);
+    wrapperColumnSchema.setColumnReferenceId("1");
+    List<ColumnSchema> wrapperAddedColumns = new ArrayList<ColumnSchema>();
+    wrapperAddedColumns.add(wrapperColumnSchema);
+    SchemaEvolutionEntry wrapperSchemaEvolutionEntry = new SchemaEvolutionEntry();
+
+    List<ColumnSchema> wrapperRemovedColumns = new ArrayList<ColumnSchema>();
+    wrapperRemovedColumns.add(wrapperColumnSchema);
+
+    wrapperSchemaEvolutionEntry.setTimeStamp(time);
+    wrapperSchemaEvolutionEntry.setAdded(wrapperAddedColumns);
+    wrapperSchemaEvolutionEntry.setRemoved(wrapperRemovedColumns);
+    SchemaEvolutionEntry actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperSchemaEvolutionEntry(schemaEvolEntry);
+    assertEquals(wrapperSchemaEvolutionEntry.getAdded().get(0), actualResult.getAdded().get(0));
+  }
+
+  @Test public void testFromExternalToWrapperSchemaEvolution() {
+
+    new MockUp<SchemaEvolutionEntry>() {
+      @Mock public List<ColumnSchema> getAdded() {
+        return columnSchemas;
+      }
+
+      @Mock public List<ColumnSchema> getRemoved() {
+        return columnSchemas;
+      }
+    };
+
+    SchemaEvolution actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperSchemaEvolution(schemaEvol);
+    assertEquals(columnSchemas, actualResult.getSchemaEvolutionEntryList().get(0).getAdded());
+  }
+
+  @Test public void testFromExternalToWrapperColumnSchema() {
+    ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
+    Boolean expectedResult = true;
+    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
+  }
+
+  @Test public void testFromExternalToWrapperColumnSchemaForIntDatatype() {
+
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.INT,
+            "columnName", "1", true, encoders, true);
+    ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
+    Boolean expectedResult = true;
+    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
+  }
+
+  @Test public void testFromExternalToWrapperColumnSchemaForShortDatatype() {
+
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.SHORT,
+            "columnName", "1", true, encoders, true);
+    ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
+    Boolean expectedResult = true;
+    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
+  }
+
+  @Test public void testFromExternalToWrapperColumnSchemaForLongDatatype() {
+
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.LONG,
+            "columnName", "1", true, encoders, true);
+    ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
+    Boolean expectedResult = true;
+    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
+  }
+
+  @Test public void testFromExternalToWrapperColumnSchemaForDoubleDatatype() {
+
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.DOUBLE,
+            "columnName", "1", true, encoders, true);
+    ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
+    Boolean expectedResult = true;
+    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
+  }
+
+  @Test public void testFromExternalToWrapperColumnSchemaForDecimalDatatype() {
+
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.DECIMAL,
+            "columnName", "1", true, encoders, true);
+    ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
+    Boolean expectedResult = true;
+    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
+  }
+
+  @Test public void testFromExternalToWrapperColumnSchemaForTimestampDatatype() {
+
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(
+            org.apache.carbondata.format.DataType.TIMESTAMP, "columnName", "1", true, encoders,
+            true);
+    ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
+    Boolean expectedResult = true;
+    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
+  }
+
+  @Test public void testFromExternalToWrapperColumnSchemaForArrayDatatype() {
+
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.ARRAY,
+            "columnName", "1", true, encoders, true);
+    ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
+    Boolean expectedResult = true;
+    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
+  }
+
+  @Test public void testFromExternalToWrapperColumnSchemaForStructDatatype() {
+
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRUCT,
+            "columnName", "1", true, encoders, true);
+    ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
+    Boolean expectedResult = true;
+    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
+  }
+
+  @Test public void testFromExternalToWrapperColumnSchemaForDatatypeNullCase() {
+
+    org.apache.carbondata.format.ColumnSchema thriftColumnSchema =
+        new org.apache.carbondata.format.ColumnSchema(null, "columnName", "1", true, encoders,
+            true);
+    ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
+    Boolean expectedResult = true;
+    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
+  }
+
+  @Test public void testFromExternalToWrapperColumnSchemaEncodingNullCase() {
+
+    final List<org.apache.carbondata.format.Encoding> encoders =
+        new ArrayList<org.apache.carbondata.format.Encoding>();
+    encoders.add(org.apache.carbondata.format.Encoding.INVERTED_INDEX);
+    encoders.add(null);
+
+    List<Encoding> encodings = new ArrayList<>();
+    encodings.add(Encoding.INVERTED_INDEX);
+    encodings.add(null);
+
+    final org.apache.carbondata.format.ColumnSchema thriftColSchema =
+        new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRING,
+            "columnName", "1", true, encoders, true);
+    thriftColumnSchema.setSchemaOrdinal(1);
+
+    new MockUp<org.apache.carbondata.format.ColumnSchema>() {
+      @Mock
+      public org.apache.carbondata.format.ColumnSchema setColumn_group_id(int column_group_id) {
+        return thriftColSchema;
+      }
+
+      @Mock public org.apache.carbondata.format.ColumnSchema setScale(int scale) {
+        return thriftColSchema;
+      }
+
+      @Mock public org.apache.carbondata.format.ColumnSchema setPrecision(int precision) {
+        return thriftColSchema;
+      }
+
+      @Mock public org.apache.carbondata.format.ColumnSchema setNum_child(int num_child) {
+        return thriftColSchema;
+      }
+
+      @Mock
+      public org.apache.carbondata.format.ColumnSchema setDefault_value(byte[] default_value) {
+        return thriftColSchema;
+      }
+
+      @Mock public org.apache.carbondata.format.ColumnSchema setColumnProperties(
+          Map<String, String> columnProperties) {
+        return thriftColSchema;
+      }
+
+      @Mock public org.apache.carbondata.format.ColumnSchema setInvisible(boolean invisible) {
+        return thriftColSchema;
+      }
+
+      @Mock public org.apache.carbondata.format.ColumnSchema setColumnReferenceId(
+          String columnReferenceId) {
+        return thriftColSchema;
+      }
+
+      @Mock public String getColumn_id() {
+        return "1";
+      }
+
+      @Mock public String getColumn_name() {
+        return "columnName";
+      }
+
+      @Mock public boolean isColumnar() {
+        return true;
+      }
+
+      @Mock public boolean isDimension() {
+        return true;
+      }
+
+      @Mock public List<org.apache.carbondata.format.Encoding> getEncoders() {
+        return encoders;
+      }
+
+      @Mock public int getNum_child() {
+        return 1;
+      }
+
+      @Mock public int getPrecision() {
+        return 1;
+      }
+
+      @Mock public int getColumn_group_id() {
+        return 1;
+      }
+
+      @Mock public int getScale() {
+        return 1;
+      }
+
+      @Mock public byte[] getDefault_value() {
+        return new byte[] { 1, 2 };
+      }
+
+      @Mock public String getAggregate_function() {
+        return "";
+      }
+
+      @Mock public Map<String, String> getColumnProperties() {
+        return columnPropertyMap;
+      }
+
+      @Mock public boolean isInvisible() {
+        return true;
+      }
+
+      @Mock public String getColumnReferenceId() {
+        return "1";
+      }
+
+    };
+
+    ColumnSchema actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColSchema);
+    assertEquals("columnName", actualResult.getColumnName());
+  }
+
+  @Test public void testFromExternalToWrapperTableSchema() {
+    String tableId = "1";
+    String tableName = "tableName";
+    TableSchema actualResult =
+        thriftWrapperSchemaConverter.fromExternalToWrapperTableSchema(tabSchema, "tableName");
+    assertEquals(tableId, actualResult.getTableId());
+    assertEquals(tableName, actualResult.getTableName());
+  }
+
+  @Test public void testFromExternalToWrapperTableInfo() {
+    final List<org.apache.carbondata.format.TableSchema> tableSchemas = new ArrayList();
+    long time = 1112745600000L;
+    tableSchemas.add(tabSchema);
+    new MockUp<org.apache.carbondata.format.TableInfo>() {
+      @Mock public org.apache.carbondata.format.TableSchema getFact_table() {
+        return tabSchema;
+      }
+
+      @Mock public List<org.apache.carbondata.format.TableSchema> getAggregate_table_list() {
+        return tableSchemas;
+      }
+    };
+    org.apache.carbondata.format.TableInfo externalTableInfo =
+        new org.apache.carbondata.format.TableInfo();
+    TableInfo actualResult = thriftWrapperSchemaConverter
+        .fromExternalToWrapperTableInfo(externalTableInfo, "dbName", "tableName", "/path");
+    assertEquals(time, actualResult.getLastUpdatedTime());
+    assertEquals("dbName_tableName", actualResult.getTableUniqueName());
+  }
+
+}
\ No newline at end of file


Mime
View raw message