You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by GitBox <gi...@apache.org> on 2022/04/22 01:57:15 UTC

[GitHub] [incubator-linkis] casionone commented on a diff in pull request #2019: Dev 1.1.2 add junit test to linkis-configuration

casionone commented on code in PR #2019:
URL: https://github.com/apache/incubator-linkis/pull/2019#discussion_r855709930


##########
linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/test/java/org/apache/linkis/configuration/dao/ConfigMapperTest.java:
##########
@@ -0,0 +1,182 @@
+package org.apache.linkis.configuration.dao;
+
+/*
+ * 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.
+ */
+
+import org.apache.linkis.configuration.entity.*;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ConfigMapperTest extends BaseDaoTest {
+    @Autowired ConfigMapper configMapper;
+
+    @Test
+    void testGetConfigKeyByLabelIds() {
+        List<ConfigKeyValue> configKeyValueList =
+                configMapper.getConfigKeyByLabelIds(Arrays.asList(1, 2, 3));
+        assertEquals(7, configKeyValueList.size());
+    }
+
+    @Test
+    void testGetConfigKeyValueByLabelId() {
+        List<ConfigKeyValue> configKeyValueList = configMapper.getConfigKeyValueByLabelId(1);
+        assertEquals(7, configKeyValueList.size());
+    }
+
+    @Test
+    void testInsertValue() {
+        ConfigValue configValue = new ConfigValue();
+        configValue.setId(8L);
+        configValue.setConfigKeyId(8L);
+        configValue.setConfigValue("100G");
+        configValue.setConfigLabelId(1);
+        configMapper.insertValue(configValue);
+        ConfigValue result = configMapper.getConfigValueById(8L);
+        assertEquals("100G", result.getConfigValue());
+    }
+
+    @Test
+    void testGetConfigValueById() {
+        ConfigValue configValue = configMapper.getConfigValueById(6L);
+        assertEquals("1", configValue.getConfigValue());
+    }
+
+    @Test
+    void testInsertValueList() throws InterruptedException {
+        ConfigValue configValue = new ConfigValue();
+        configValue.setConfigKeyId(9L);
+        configValue.setConfigValue("100G");
+        configValue.setConfigLabelId(1);
+        List<ConfigValue> configValues = new ArrayList<>();
+        ConfigValue configValue2 = new ConfigValue();
+        configValue2.setConfigKeyId(10L);
+        configValue2.setConfigValue("130G");
+        configValue2.setConfigLabelId(1);
+        configValues.add(configValue);
+        configValues.add(configValue2);
+        configMapper.insertValueList(configValues);
+        assertEquals("130G", configMapper.getConfigValueById(10L).getConfigValue());

Review Comment:
   Whether the database is inserted successfully should be judged by the return value



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org