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: Closed CarbonData-460 Added unit test cases for core.writer.sortindex package
Date Mon, 12 Dec 2016 06:39:53 GMT
Repository: incubator-carbondata
Updated Branches:
  refs/heads/master a13ee2392 -> 0c18f8c59


Closed CarbonData-460
Added unit test cases for core.writer.sortindex package

Removed unused imports and refactored code for test cases

Removed unused code


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

Branch: refs/heads/master
Commit: d828604773c6488b15520c5e042057b0d521e54f
Parents: a13ee23
Author: Geetika gupta <geetika.gupta@knoldus.in>
Authored: Mon Nov 28 17:15:23 2016 +0530
Committer: ravipesala <ravi.pesala@gmail.com>
Committed: Mon Dec 12 12:09:02 2016 +0530

----------------------------------------------------------------------
 ...CarbonDictionarySortIndexWriterImplTest.java |  88 +++-----
 .../CarbonDictionarySortInfoPreparatorTest.java | 105 ++++++++++
 .../CarbonDictionarySortModelTest.java          | 208 +++++++++++++++++++
 3 files changed, 344 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/d8286047/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortIndexWriterImplTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortIndexWriterImplTest.java
b/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortIndexWriterImplTest.java
index 30289e4..0622498 100644
--- a/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortIndexWriterImplTest.java
+++ b/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortIndexWriterImplTest.java
@@ -26,33 +26,41 @@ import java.util.UUID;
 
 import org.apache.carbondata.core.carbon.CarbonTableIdentifier;
 import org.apache.carbondata.core.carbon.ColumnIdentifier;
-import org.apache.carbondata.core.datastorage.store.filesystem.CarbonFile;
-import org.apache.carbondata.core.datastorage.store.impl.FileFactory;
 import org.apache.carbondata.core.reader.sortindex.CarbonDictionarySortIndexReader;
 import org.apache.carbondata.core.reader.sortindex.CarbonDictionarySortIndexReaderImpl;
 import org.apache.carbondata.core.util.CarbonUtil;
 import org.apache.carbondata.core.writer.CarbonDictionaryWriter;
 import org.apache.carbondata.core.writer.CarbonDictionaryWriterImpl;
+
 import org.apache.commons.lang.ArrayUtils;
-import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
+
 /**
  * class contains the unit test cases of the dictionary sort index & sort index inverted
writing
  */
 public class CarbonDictionarySortIndexWriterImplTest {
 
   private String storePath;
+  private CarbonTableIdentifier carbonTableIdentifier = null;
+  private ColumnIdentifier columnIdentifier = null;
+  private CarbonDictionaryWriter dictionaryWriter = null;
+  private CarbonDictionarySortIndexWriter dictionarySortIndexWriter = null;
+  private CarbonDictionarySortIndexReader carbonDictionarySortIndexReader = null;
 
   @Before public void setUp() throws Exception {
-      storePath = "target/carbonStore";
-  }
-
-  @After public void tearDown() throws Exception {
-
-    //deleteStorePath();
+    storePath = "target/carbonStore";
+    carbonTableIdentifier =
+        new CarbonTableIdentifier("testSchema", "carbon", UUID.randomUUID().toString());
+    columnIdentifier = new ColumnIdentifier("Name", null, null);
+    dictionaryWriter =
+        new CarbonDictionaryWriterImpl(storePath, carbonTableIdentifier, columnIdentifier);
+    dictionarySortIndexWriter =
+        new CarbonDictionarySortIndexWriterImpl(carbonTableIdentifier, columnIdentifier,
storePath);
+    carbonDictionarySortIndexReader =
+        new CarbonDictionarySortIndexReaderImpl(carbonTableIdentifier, columnIdentifier,
storePath);
   }
 
   /**
@@ -62,35 +70,31 @@ public class CarbonDictionarySortIndexWriterImplTest {
    * @throws Exception
    */
   @Test public void write() throws Exception {
-    CarbonTableIdentifier carbonTableIdentifier = new CarbonTableIdentifier("testSchema",
"carbon", UUID.randomUUID().toString());
-    ColumnIdentifier columnIdentifier = new ColumnIdentifier("Name", null, null);
 
-    String metaFolderPath =storePath+File.separator+carbonTableIdentifier.getDatabaseName()+File.separator+carbonTableIdentifier.getTableName()+File.separator+"Metadata";
+    String metaFolderPath =
+        storePath + File.separator + carbonTableIdentifier.getDatabaseName() + File.separator
+            + carbonTableIdentifier.getTableName() + File.separator + "Metadata";
     CarbonUtil.checkAndCreateFolder(metaFolderPath);
-    CarbonDictionaryWriter dictionaryWriter = new CarbonDictionaryWriterImpl(storePath,
-    	       carbonTableIdentifier, columnIdentifier);
-    CarbonDictionarySortIndexWriter dictionarySortIndexWriter =
-        new CarbonDictionarySortIndexWriterImpl(carbonTableIdentifier, columnIdentifier,
storePath);
+
     List<int[]> indexList = prepareExpectedData();
     int[] data = indexList.get(0);
-    for(int i=0;i<data.length;i++) {
-    	dictionaryWriter.write(String.valueOf(data[i]));
+    for (int i = 0; i < data.length; i++) {
+      dictionaryWriter.write(String.valueOf(data[i]));
     }
     dictionaryWriter.close();
     dictionaryWriter.commit();
-    
+
     List<Integer> sortIndex = Arrays.asList(ArrayUtils.toObject(indexList.get(0)));
     List<Integer> invertedSortIndex = Arrays.asList(ArrayUtils.toObject(indexList.get(1)));
     dictionarySortIndexWriter.writeSortIndex(sortIndex);
     dictionarySortIndexWriter.writeInvertedSortIndex(invertedSortIndex);
     dictionarySortIndexWriter.close();
-    CarbonDictionarySortIndexReader carbonDictionarySortIndexReader =
-        new CarbonDictionarySortIndexReaderImpl(carbonTableIdentifier, columnIdentifier,
storePath);
+
     List<Integer> actualSortIndex = carbonDictionarySortIndexReader.readSortIndex();
     List<Integer> actualInvertedSortIndex = carbonDictionarySortIndexReader.readInvertedSortIndex();
     for (int i = 0; i < actualSortIndex.size(); i++) {
-      Assert.assertEquals(sortIndex.get(i), actualSortIndex.get(i));
-      Assert.assertEquals(invertedSortIndex.get(i), actualInvertedSortIndex.get(i));
+      assertEquals(sortIndex.get(i), actualSortIndex.get(i));
+      assertEquals(invertedSortIndex.get(i), actualInvertedSortIndex.get(i));
     }
 
   }
@@ -99,23 +103,17 @@ public class CarbonDictionarySortIndexWriterImplTest {
    * @throws Exception
    */
   @Test public void writingEmptyValue() throws Exception {
-    CarbonTableIdentifier carbonTableIdentifier = new CarbonTableIdentifier("testSchema",
"carbon", UUID.randomUUID().toString());
-    ColumnIdentifier columnIdentifier = new ColumnIdentifier("Name", null, null);
 
-    CarbonDictionarySortIndexWriter dictionarySortIndexWriter =
-        new CarbonDictionarySortIndexWriterImpl(carbonTableIdentifier, columnIdentifier,
storePath);
     List<Integer> sortIndex = new ArrayList<>();
     List<Integer> invertedSortIndex = new ArrayList<>();
     dictionarySortIndexWriter.writeSortIndex(sortIndex);
     dictionarySortIndexWriter.writeInvertedSortIndex(invertedSortIndex);
     dictionarySortIndexWriter.close();
-    CarbonDictionarySortIndexReader carbonDictionarySortIndexReader =
-        new CarbonDictionarySortIndexReaderImpl(carbonTableIdentifier, columnIdentifier,
storePath);
     List<Integer> actualSortIndex = carbonDictionarySortIndexReader.readSortIndex();
     List<Integer> actualInvertedSortIndex = carbonDictionarySortIndexReader.readInvertedSortIndex();
     for (int i = 0; i < actualSortIndex.size(); i++) {
-      Assert.assertEquals(sortIndex.get(i), actualSortIndex.get(i));
-      Assert.assertEquals(invertedSortIndex.get(i), actualInvertedSortIndex.get(i));
+      assertEquals(sortIndex.get(i), actualSortIndex.get(i));
+      assertEquals(invertedSortIndex.get(i), actualInvertedSortIndex.get(i));
     }
 
   }
@@ -129,28 +127,4 @@ public class CarbonDictionarySortIndexWriterImplTest {
     return indexList;
   }
 
-  /**
-   * this method will delete the store path
-   */
-  private void deleteStorePath() {
-    FileFactory.FileType fileType = FileFactory.getFileType(this.storePath);
-    CarbonFile carbonFile = FileFactory.getCarbonFile(this.storePath, fileType);
-    deleteRecursiveSilent(carbonFile);
-  }
-
-  /**
-   * this method will delete the folders recursively
-   */
-  private static void deleteRecursiveSilent(CarbonFile f) {
-    if (f.isDirectory()) {
-      if (f.listFiles() != null) {
-        for (CarbonFile c : f.listFiles()) {
-          deleteRecursiveSilent(c);
-        }
-      }
-    }
-    if (f.exists() && !f.delete()) {
-      return;
-    }
-  }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/d8286047/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortInfoPreparatorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortInfoPreparatorTest.java
b/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortInfoPreparatorTest.java
new file mode 100644
index 0000000..e0c444b
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortInfoPreparatorTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.writer.sortindex;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.carbondata.core.cache.dictionary.Dictionary;
+import org.apache.carbondata.core.cache.dictionary.DictionaryChunksWrapper;
+import org.apache.carbondata.core.carbon.metadata.datatype.DataType;
+import org.apache.carbondata.core.util.CarbonUtilException;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * The class tests the CarbonDictionarySortInfoPreparator class that prepares the column
sort info ie sortIndex
+ * and inverted sort index info
+ */
+public class CarbonDictionarySortInfoPreparatorTest {
+
+  private static CarbonDictionarySortInfoPreparator carbonDictionarySortInfoPreparator =
null;
+
+  @BeforeClass public static void setUp() {
+    carbonDictionarySortInfoPreparator = new CarbonDictionarySortInfoPreparator();
+  }
+
+  /**
+   * Tests the getDictionarySortInfo method
+   *
+   * @throws CarbonUtilException
+   */
+  @Test public void testGetDictionarySortInfo() throws CarbonUtilException {
+
+    List<String> newDistinctValues = new ArrayList<>();
+    newDistinctValues.add("abc");
+    newDistinctValues.add("xyz");
+    Dictionary dictionary = new MockUp<Dictionary>() {
+      @Mock public DictionaryChunksWrapper getDictionaryChunks() {
+        List<byte[]> data = new ArrayList<>();
+        data.add(new byte[] { 1, 2 });
+        List<List<byte[]>> dictionaryChunks = new ArrayList<>();
+        dictionaryChunks.add(data);
+        return new DictionaryChunksWrapper(dictionaryChunks);
+      }
+    }.getMockInstance();
+
+    new MockUp<DictionaryChunksWrapper>() {
+      @Mock public int getSize() {
+        return 1;
+      }
+    };
+
+    CarbonDictionarySortInfo carbonDictionarySortInfo = carbonDictionarySortInfoPreparator
+        .getDictionarySortInfo(newDistinctValues, dictionary, DataType.ARRAY);
+    int expectedGetSortIndexValue = 1;
+    int expectedGetSortInvertedIndexLength = 3;
+    int actualGetSortIndexValue = carbonDictionarySortInfo.getSortIndex().get(0);
+    int actualGetSortInvertedIndexLength = carbonDictionarySortInfo.getSortIndexInverted().size();
+    assertEquals(actualGetSortIndexValue, expectedGetSortIndexValue);
+    assertEquals(actualGetSortInvertedIndexLength, expectedGetSortInvertedIndexLength);
+  }
+
+  /**
+   * Tests getDictionarySortInfo when dictionary is null
+   *
+   * @throws CarbonUtilException
+   */
+  @Test public void testGetDictionarySortInfoDictionaryNullCase() throws CarbonUtilException
{
+
+    List<String> newDistinctValues = new ArrayList<>();
+    newDistinctValues.add("abc");
+    newDistinctValues.add("xyz");
+    Dictionary dictionary = null;
+    CarbonDictionarySortInfo carbonDictionarySortInfo = carbonDictionarySortInfoPreparator
+        .getDictionarySortInfo(newDistinctValues, dictionary, DataType.ARRAY);
+    int expectedGetSortIndexValue = 1;
+    int expectedGetSortInvertedIndexLength = 2;
+    int actualGetSortIndexValue = carbonDictionarySortInfo.getSortIndex().get(0);
+    int actualGetSortInvertedIndexLength = carbonDictionarySortInfo.getSortIndexInverted().size();
+    assertEquals(actualGetSortIndexValue, expectedGetSortIndexValue);
+    assertEquals(actualGetSortInvertedIndexLength, expectedGetSortInvertedIndexLength);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/d8286047/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortModelTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortModelTest.java
b/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortModelTest.java
new file mode 100644
index 0000000..5c48445
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/writer/sortindex/CarbonDictionarySortModelTest.java
@@ -0,0 +1,208 @@
+/*
+ * 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.writer.sortindex;
+
+import org.apache.carbondata.core.carbon.metadata.datatype.DataType;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * This class tests the Dictionary sort model class that holds the member byte value and
corresponding key value.
+ */
+public class CarbonDictionarySortModelTest {
+
+  private CarbonDictionarySortModel carbonDictionarySortModel = null;
+
+  @Test public void testCompareToForDataTypeDoubleCase() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DOUBLE, "7234");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.DOUBLE, "5678");
+    int expectedResult = 1;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testCompareToForDataTypeDoubleExceptionCase() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DOUBLE, "double");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.DOUBLE, "@NU#LL$!");
+    int expectedResult = -1;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testCompareToForDataTypeDoubleExceptionCaseForOtherObject() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DOUBLE, "1234");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.DOUBLE, "@NU#LL$!");
+    int expectedResult = -1;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testCompareToForDataTypeBooleanCase() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.BOOLEAN, "memberValue");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.DOUBLE, "value");
+    int expectedResult = -9;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testCompareToForDataTypeDecimalCase() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DECIMAL, "72.34");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.DECIMAL, "56.78");
+    int expectedResult = 1;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testCompareToForDataTypeDecimalExceptionCase() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DECIMAL, "decimal");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.DECIMAL, "@NU#LL$!");
+    int expectedResult = -1;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testCompareToForDataTypeDecimalExceptionCaseForOtherObject() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DECIMAL, "15.24");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.DECIMAL, "@NU#LL$!");
+    int expectedResult = -1;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testCompareToForDataTypeTimestampCase() {
+    carbonDictionarySortModel =
+        new CarbonDictionarySortModel(1, DataType.TIMESTAMP, "2014-09-22 12:00:00");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.TIMESTAMP, "2015-09-22 12:08:49");
+    int expectedResult = -1;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testCompareToForDataTypeTimestampExceptionCase() {
+    carbonDictionarySortModel =
+        new CarbonDictionarySortModel(1, DataType.TIMESTAMP, "2014-09 12:00:00");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.TIMESTAMP, "@NU#LL$!");
+    int expectedResult = -1;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testCompareToForDataTypeTimestampExceptionCaseForOtherObject() {
+    carbonDictionarySortModel =
+        new CarbonDictionarySortModel(1, DataType.TIMESTAMP, "2014-09-22 12:00:00");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.TIMESTAMP, "2014-09-22 12");
+    int expectedResult = -1;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testHashCode() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DECIMAL, "15.24");
+    int actualResult = carbonDictionarySortModel.hashCode();
+    int expectedResult = 46877260;
+    assertTrue(actualResult == expectedResult);
+  }
+
+  @Test public void testHashCodeNullCaseForMemberValue() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DECIMAL, null);
+    int actualResult = carbonDictionarySortModel.hashCode();
+    int expectedResult = 0;
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testEquals() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DECIMAL, "15.24");
+    CarbonDictionarySortModel testCarbonDictionarySortModel = carbonDictionarySortModel;
+    boolean result = carbonDictionarySortModel.equals(testCarbonDictionarySortModel);
+    assertTrue(result);
+  }
+
+  @Test public void testEqualsMemberValueNullCase() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DECIMAL, null);
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(1, DataType.BOOLEAN, "false");
+    boolean result = carbonDictionarySortModel.equals(testCarbonDictionarySortModel);
+    assertFalse(result);
+  }
+
+  @Test public void testEqualsWhenMemberValueDiffers() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DECIMAL, "12.45");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(1, DataType.BOOLEAN, "false");
+    boolean result = carbonDictionarySortModel.equals(testCarbonDictionarySortModel);
+    assertFalse(result);
+  }
+
+  @Test public void testEqualsWhenMemberValueIsSame() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DECIMAL, "12.45");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(1, DataType.DECIMAL, "12.45");
+    boolean result = carbonDictionarySortModel.equals(testCarbonDictionarySortModel);
+    assertTrue(result);
+  }
+
+  @Test public void testEqualsForDifferentObjects() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DECIMAL, "12.45");
+    Object testCarbonDictionarySortModel = new Object();
+    boolean result = carbonDictionarySortModel.equals(testCarbonDictionarySortModel);
+    assertFalse(result);
+  }
+
+  @Test public void testCompareToForDataTypeDoubleExceptionCaseForDifferentObject() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DOUBLE, "double");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.DOUBLE, "1234");
+    int expectedResult = 1;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testCompareToForDataTypeDecimalExceptionCaseForDifferentObject() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.DECIMAL, "12.il");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.DECIMAL, "12.89");
+    int expectedResult = 1;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+  @Test public void testCompareToForDataTypeTimestampExceptionCaseForDifferentObject() {
+    carbonDictionarySortModel = new CarbonDictionarySortModel(1, DataType.TIMESTAMP, "2014-09");
+    CarbonDictionarySortModel testCarbonDictionarySortModel =
+        new CarbonDictionarySortModel(2, DataType.TIMESTAMP, "2014-09-22 12:00:00");
+    int expectedResult = 1;
+    int actualResult = carbonDictionarySortModel.compareTo(testCarbonDictionarySortModel);
+    assertEquals(actualResult, expectedResult);
+  }
+
+}


Mime
View raw message