This is an automated email from the ASF dual-hosted git repository.

nic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git


The following commit(s) were added to refs/heads/master by this push:
     new b48de90  Add unit tests (#645)
b48de90 is described below

commit b48de90d046bfbef30917149e9c3426c6a7365cc
Author: Michael Hausegger <hausegger.mich...@googlemail.com>
AuthorDate: Tue May 21 04:18:57 2019 +0200

    Add unit tests (#645)
    
    * Add unit tests
---
 .../apache/kylin/job/engine/JobEngineConfig.java   |  2 +-
 .../apache/kylin/storage/StorageContextTest.java   | 64 ++++++++++++++++
 .../kylin/storage/hybrid/HybridInstanceTest.java   | 86 ++++++++++++++++++++++
 .../translate}/FuzzyValueCombinationTest.java      |  6 +-
 4 files changed, 153 insertions(+), 5 deletions(-)

diff --git 
a/core-job/src/main/java/org/apache/kylin/job/engine/JobEngineConfig.java 
b/core-job/src/main/java/org/apache/kylin/job/engine/JobEngineConfig.java
index 3422fa6..c0892ed 100644
--- a/core-job/src/main/java/org/apache/kylin/job/engine/JobEngineConfig.java
+++ b/core-job/src/main/java/org/apache/kylin/job/engine/JobEngineConfig.java
@@ -72,7 +72,7 @@ public class JobEngineConfig {
 
     /**
      *
-     * @param jobType job config file suffix name; if be null, will use the 
default job conf
+     * @param jobType job config file suffix name; if is null, will use the 
default job conf
      * @return the job config file path
      * @throws IOException
      */
diff --git 
a/core-storage/src/test/java/org/apache/kylin/storage/StorageContextTest.java 
b/core-storage/src/test/java/org/apache/kylin/storage/StorageContextTest.java
new file mode 100644
index 0000000..45ae78e
--- /dev/null
+++ 
b/core-storage/src/test/java/org/apache/kylin/storage/StorageContextTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.kylin.storage;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import org.apache.kylin.gridtable.StorageLimitLevel;
+import org.junit.Test;
+
+/**
+ * Unit tests for class {@link StorageContext}.
+ *
+ * @see StorageContext
+ */
+public class StorageContextTest {
+
+
+    @Test
+    public void testSetLimit() {
+        StorageContext storageContext = new StorageContext();
+        storageContext.setLimit(10);
+
+        assertEquals(StorageLimitLevel.NO_LIMIT, 
storageContext.getStorageLimitLevel());
+        assertFalse(storageContext.isLimitPushDownEnabled());
+        assertEquals(Integer.MAX_VALUE, 
storageContext.getFinalPushDownLimit());
+
+        storageContext.setLimit(0);
+
+        assertEquals(StorageLimitLevel.NO_LIMIT, 
storageContext.getStorageLimitLevel());
+        assertFalse(storageContext.isLimitPushDownEnabled());
+        assertEquals(Integer.MAX_VALUE, 
storageContext.getFinalPushDownLimit());
+    }
+
+
+    @Test
+    public void testApplyLimitPushDownUsingStorageLimitLevelNO_LIMIT() {
+        StorageContext storageContext = new StorageContext();
+        storageContext.setLimit(10);
+        storageContext.applyLimitPushDown(null, StorageLimitLevel.NO_LIMIT);
+
+        assertEquals(StorageLimitLevel.NO_LIMIT, 
storageContext.getStorageLimitLevel());
+        assertFalse(storageContext.isLimitPushDownEnabled());
+        assertEquals(Integer.MAX_VALUE, 
storageContext.getFinalPushDownLimit());
+    }
+
+
+}
diff --git 
a/core-storage/src/test/java/org/apache/kylin/storage/hybrid/HybridInstanceTest.java
 
b/core-storage/src/test/java/org/apache/kylin/storage/hybrid/HybridInstanceTest.java
new file mode 100644
index 0000000..99aede4
--- /dev/null
+++ 
b/core-storage/src/test/java/org/apache/kylin/storage/hybrid/HybridInstanceTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.kylin.storage.hybrid;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.kylin.metadata.model.TblColRef;
+import org.apache.kylin.metadata.realization.CapabilityResult;
+import org.apache.kylin.metadata.realization.SQLDigest;
+import org.apache.kylin.metadata.tuple.Tuple;
+import org.apache.kylin.metadata.tuple.TupleInfo;
+import org.junit.Test;
+
+/**
+ * Unit tests for class {@link HybridInstance}.
+ *
+ * @see HybridInstance
+ */
+public class HybridInstanceTest {
+
+
+    @Test
+    public void testGetCost() {
+        HybridInstance hybridInstance = new HybridInstance();
+
+        assertEquals(Integer.MAX_VALUE, hybridInstance.getCost());
+    }
+
+    @Test
+    public void testIsCapable() {
+        HybridInstance hybridInstance = new HybridInstance();
+        LinkedHashSet<TblColRef> linkedHashSet = new LinkedHashSet<>();
+        TupleInfo tupleInfo = new TupleInfo();
+        Tuple tuple = new Tuple(tupleInfo);
+        SQLDigest sQLDigest = new SQLDigest("6Bw^[(:[hOd",
+                linkedHashSet,
+                new LinkedList<>(),
+                tuple.getAllColumns(),
+                linkedHashSet,
+                new ConcurrentHashMap<>(),
+                false,
+                linkedHashSet,
+                new LinkedList<>(),
+                new LinkedList<>(),
+                new LinkedList<>(),
+                linkedHashSet,
+                linkedHashSet,
+                linkedHashSet,
+                null,
+                null,
+                tuple.getAllColumns(),
+                new LinkedList<>(),
+                true,
+                true,
+                new LinkedHashSet<>());
+        CapabilityResult capabilityResult = 
hybridInstance.isCapable(sQLDigest);
+
+        assertNotNull(capabilityResult);
+        assertFalse(capabilityResult.capable);
+        assertEquals(2147483646, capabilityResult.cost);
+    }
+
+
+}
diff --git 
a/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/common/FuzzyValueCombinationTest.java
 
b/core-storage/src/test/java/org/apache/kylin/storage/translate/FuzzyValueCombinationTest.java
similarity index 97%
rename from 
storage-hbase/src/test/java/org/apache/kylin/storage/hbase/common/FuzzyValueCombinationTest.java
rename to 
core-storage/src/test/java/org/apache/kylin/storage/translate/FuzzyValueCombinationTest.java
index afb0b33..b794450 100644
--- 
a/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/common/FuzzyValueCombinationTest.java
+++ 
b/core-storage/src/test/java/org/apache/kylin/storage/translate/FuzzyValueCombinationTest.java
@@ -16,7 +16,7 @@
  * limitations under the License.
 */
 
-package org.apache.kylin.storage.hbase.common;
+package org.apache.kylin.storage.translate;
 
 import static org.junit.Assert.assertEquals;
 
@@ -26,16 +26,14 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import com.google.common.collect.Maps;
 import org.apache.kylin.common.util.LocalFileMetadataTestCase;
 import org.apache.kylin.metadata.model.TableDesc;
 import org.apache.kylin.metadata.model.TblColRef;
-import org.apache.kylin.storage.translate.FuzzyValueCombination;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import com.google.common.collect.Maps;
-
 /**
  * @author yangli9
  * 

Reply via email to