You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by ca...@apache.org on 2022/09/08 12:05:08 UTC
[incubator-linkis] branch dev-1.3.1 updated: Add InstanceInfoDao unit test (#3281)
This is an automated email from the ASF dual-hosted git repository.
casion pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
new 4f2a8a82f Add InstanceInfoDao unit test (#3281)
4f2a8a82f is described below
commit 4f2a8a82f1e3a7d3bc4bd56636ffdec05423ac52
Author: 成彬彬 <10...@users.noreply.github.com>
AuthorDate: Thu Sep 8 20:05:01 2022 +0800
Add InstanceInfoDao unit test (#3281)
---
.../instance/label/dao/InstanceInfoDaoTest.java | 86 ++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/java/org/apache/linkis/instance/label/dao/InstanceInfoDaoTest.java b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/java/org/apache/linkis/instance/label/dao/InstanceInfoDaoTest.java
new file mode 100644
index 000000000..13136d5d9
--- /dev/null
+++ b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/java/org/apache/linkis/instance/label/dao/InstanceInfoDaoTest.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.linkis.instance.label.dao;
+
+import org.apache.linkis.common.ServiceInstance;
+import org.apache.linkis.instance.label.entity.InstanceInfo;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class InstanceInfoDaoTest extends BaseDaoTest {
+
+ @Autowired InstanceInfoDao instanceInfoDao;
+
+ void insert() {
+ InstanceInfo instanceInfo = new InstanceInfo();
+ instanceInfo.setId(1);
+ instanceInfo.setInstance("testInstance");
+ instanceInfo.setApplicationName("testApplicationName");
+ instanceInfoDao.insertOne(instanceInfo);
+ }
+
+ @Test
+ public void testInsertOne() {
+ insert();
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setInstance("testInstance");
+ serviceInstance.setApplicationName("testApplicationName");
+ InstanceInfo instanceInfo = instanceInfoDao.getInstanceInfoByServiceInstance(serviceInstance);
+ assertTrue(instanceInfo.getInstance().equals("testInstance"));
+ }
+
+ @Test
+ public void testRemoveInstance() {
+ insert();
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setInstance("testInstance");
+ instanceInfoDao.removeInstance(serviceInstance);
+ ServiceInstance serviceInstances = new ServiceInstance();
+ serviceInstances.setInstance("testInstance");
+ serviceInstances.setApplicationName("testApplicationName");
+ InstanceInfo instanceInfo = instanceInfoDao.getInstanceInfoByServiceInstance(serviceInstances);
+ assertTrue(instanceInfo == null);
+ }
+
+ @Test
+ public void testUpdateInstance() {
+ insert();
+ InstanceInfo instanceInfo = new InstanceInfo();
+ instanceInfo.setId(1);
+ instanceInfo.setInstance("testInstance1");
+ instanceInfo.setApplicationName("testApplicationName1");
+ instanceInfo.setUpdateTime(new Date());
+ instanceInfoDao.updateInstance(instanceInfo);
+ }
+
+ @Test
+ public void testGetInstanceInfoByServiceInstance() {
+ insert();
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setInstance("testInstance");
+ serviceInstance.setApplicationName("testApplicationName");
+ InstanceInfo instanceInfo = instanceInfoDao.getInstanceInfoByServiceInstance(serviceInstance);
+ assertTrue(instanceInfo.getInstance().equals("testInstance"));
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org