Skip to content

Commit

Permalink
Unhide test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengJie1053 committed Nov 24, 2023
1 parent 8036be6 commit 8181aa1
Show file tree
Hide file tree
Showing 7 changed files with 497 additions and 452 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,141 +17,148 @@

package org.apache.linkis.instance.label.dao;

import org.apache.linkis.common.ServiceInstance;
import org.apache.linkis.instance.label.entity.InsPersistenceLabel;
import org.apache.linkis.instance.label.entity.InstanceInfo;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;

public class InsLabelRelationDaoTest extends BaseDaoTest {

@Autowired InsLabelRelationDao insLabelRelationDao;

// @Test
// public void testSearchInsDirectByValues() {
// Map<String, String> map = new HashMap<>();
// map.put("test", "test1");
// List<Map<String, String>> list = new ArrayList<>();
// list.add(map);
// String relation = "testRelation";
// List<InstanceInfo> instanceInfoList =
// insLabelRelationDao.searchInsDirectByValues(list, relation);
// assertTrue(instanceInfoList.size() <= 0);
// }
//
// @Test
// public void testSearchInsDirectByLabels() {
// List<InsPersistenceLabel> labels = new ArrayList<>();
// InsPersistenceLabel insPersistenceLabel = new InsPersistenceLabel();
// insPersistenceLabel.setLabelKey("testKey");
// insPersistenceLabel.setStringValue("testVa");
// labels.add(insPersistenceLabel);
// List<InstanceInfo> instanceInfoList = insLabelRelationDao.searchInsDirectByLabels(labels);
// assertTrue(instanceInfoList.size() <= 0);
// }
//
// @Test
// public void testSearchInsCascadeByValues() {
// Map<String, String> map = new HashMap<>();
// map.put("test", "test1");
// List<Map<String, String>> valueContent = new ArrayList<>();
// valueContent.add(map);
// String relation = "testRelation";
// List<InstanceInfo> instanceInfoList =
// insLabelRelationDao.searchInsCascadeByValues(valueContent, relation);
// assertTrue(instanceInfoList.size() <= 0);
// }
//
// @Test
// public void testSearchInsCascadeByLabels() {
// List<InsPersistenceLabel> labels = new ArrayList<>();
// InsPersistenceLabel insPersistenceLabel = new InsPersistenceLabel();
// insPersistenceLabel.setLabelKey("testKey");
// insPersistenceLabel.setStringValue("testVa");
// labels.add(insPersistenceLabel);
// List<InstanceInfo> instanceInfoList = insLabelRelationDao.searchInsCascadeByLabels(labels);
// assertTrue(instanceInfoList.size() <= 0);
// }
//
// @Test
// public void testSearchUnRelateInstances() {
// InstanceInfo instanceInfo = new InstanceInfo();
// instanceInfo.setApplicationName("testApplicationName");
// List<InstanceInfo> instanceInfoList =
// insLabelRelationDao.searchUnRelateInstances(instanceInfo);
// assertTrue(instanceInfoList.size() <= 0);
// }
//
// @Test
// public void testSearchLabelRelatedInstances() {
// InstanceInfo instanceInfo = new InstanceInfo();
// instanceInfo.setApplicationName("testApplicationName");
// List<InstanceInfo> instanceInfoList =
// insLabelRelationDao.searchLabelRelatedInstances(instanceInfo);
// assertTrue(instanceInfoList.size() <= 0);
// }
//
// @Test
// public void testSearchLabelsByInstance() {
// String instance = "testInstance";
// List<InsPersistenceLabel> insPersistenceLabelList =
// insLabelRelationDao.searchLabelsByInstance(instance);
// assertTrue(insPersistenceLabelList.size() <= 0);
// }
//
// @Test
// public void testListAllInstanceWithLabel() {
// List<InstanceInfo> instanceInfoList = insLabelRelationDao.listAllInstanceWithLabel();
// assertTrue(instanceInfoList.size() <= 0);
// }
//
// @Test
// public void testGetInstancesByNames() {
// String appName = "testAppName";
// List<ServiceInstance> serviceInstanceList =
// insLabelRelationDao.getInstancesByNames(appName);
// assertTrue(serviceInstanceList.size() <= 0);
// }
//
// @Test
// public void testDropRelationsByInstanceAndLabelIds() {
// String testInstance = "testInstance";
// List<Integer> labelIds = new ArrayList<>();
// labelIds.add(1);
// labelIds.add(2);
// insLabelRelationDao.dropRelationsByInstanceAndLabelIds(testInstance, labelIds);
// }
//
// @Test
// public void testDropRelationsByInstance() {
// String testInstance = "testInstance";
// insLabelRelationDao.dropRelationsByInstance(testInstance);
// }
//
// /**
// * When using the h2 library for testing,if the function(on conflict) is not supported,an
// error
// * will be reported, and the pg physical library will not guarantee an error
// pg使用h2库测试时不支持函数(on
// * conflict)会报错,pg实体库不会报错
// */
// @Test
// public void testInsertRelations() {
// String testInstance = "testInstance";
// List<Integer> labelIds = new ArrayList<>();
// labelIds.add(1);
// labelIds.add(2);
// insLabelRelationDao.insertRelations(testInstance, labelIds);
// }
//
// /**
// * When using the h2 library for testing,if the function(on conflict) is not supported,an
// error
// * will be reported, and the pg physical library will not guarantee an error
// pg使用h2库测试时不支持函数(on
// * conflict)会报错,pg实体库不会报错
// */
// @Test
// public void testExistRelations() {
// testInsertRelations();
// Integer labelId = 1;
// Integer integer = insLabelRelationDao.existRelations(1);
// assertTrue(integer == 1);
// }
@Test
public void testSearchInsDirectByValues() {
Map<String, String> map = new HashMap<>();
map.put("test", "test1");
List<Map<String, String>> list = new ArrayList<>();
list.add(map);
String relation = "testRelation";
List<InstanceInfo> instanceInfoList =
insLabelRelationDao.searchInsDirectByValues(list, relation);
assertTrue(instanceInfoList.size() <= 0);
}

@Test
public void testSearchInsDirectByLabels() {
List<InsPersistenceLabel> labels = new ArrayList<>();
InsPersistenceLabel insPersistenceLabel = new InsPersistenceLabel();
insPersistenceLabel.setLabelKey("testKey");
insPersistenceLabel.setStringValue("testVa");
labels.add(insPersistenceLabel);
List<InstanceInfo> instanceInfoList = insLabelRelationDao.searchInsDirectByLabels(labels);
assertTrue(instanceInfoList.size() <= 0);
}

@Test
public void testSearchInsCascadeByValues() {
Map<String, String> map = new HashMap<>();
map.put("test", "test1");
List<Map<String, String>> valueContent = new ArrayList<>();
valueContent.add(map);
String relation = "testRelation";
List<InstanceInfo> instanceInfoList =
insLabelRelationDao.searchInsCascadeByValues(valueContent, relation);
assertTrue(instanceInfoList.size() <= 0);
}

@Test
public void testSearchInsCascadeByLabels() {
List<InsPersistenceLabel> labels = new ArrayList<>();
InsPersistenceLabel insPersistenceLabel = new InsPersistenceLabel();
insPersistenceLabel.setLabelKey("testKey");
insPersistenceLabel.setStringValue("testVa");
labels.add(insPersistenceLabel);
List<InstanceInfo> instanceInfoList = insLabelRelationDao.searchInsCascadeByLabels(labels);
assertTrue(instanceInfoList.size() <= 0);
}

@Test
public void testSearchUnRelateInstances() {
InstanceInfo instanceInfo = new InstanceInfo();
instanceInfo.setApplicationName("testApplicationName");
List<InstanceInfo> instanceInfoList = insLabelRelationDao.searchUnRelateInstances(instanceInfo);
assertTrue(instanceInfoList.size() <= 0);
}

@Test
public void testSearchLabelRelatedInstances() {
InstanceInfo instanceInfo = new InstanceInfo();
instanceInfo.setApplicationName("testApplicationName");
List<InstanceInfo> instanceInfoList =
insLabelRelationDao.searchLabelRelatedInstances(instanceInfo);
assertTrue(instanceInfoList.size() <= 0);
}

@Test
public void testSearchLabelsByInstance() {
String instance = "testInstance";
List<InsPersistenceLabel> insPersistenceLabelList =
insLabelRelationDao.searchLabelsByInstance(instance);
assertTrue(insPersistenceLabelList.size() <= 0);
}

@Test
public void testListAllInstanceWithLabel() {
List<InstanceInfo> instanceInfoList = insLabelRelationDao.listAllInstanceWithLabel();
assertTrue(instanceInfoList.size() <= 0);
}

@Test
public void testGetInstancesByNames() {
String appName = "testAppName";
List<ServiceInstance> serviceInstanceList = insLabelRelationDao.getInstancesByNames(appName);
assertTrue(serviceInstanceList.size() <= 0);
}

@Test
public void testDropRelationsByInstanceAndLabelIds() {
String testInstance = "testInstance";
List<Integer> labelIds = new ArrayList<>();
labelIds.add(1);
labelIds.add(2);
insLabelRelationDao.dropRelationsByInstanceAndLabelIds(testInstance, labelIds);
}

@Test
public void testDropRelationsByInstance() {
String testInstance = "testInstance";
insLabelRelationDao.dropRelationsByInstance(testInstance);
}

/**
* When using the h2 library for testing,if the function(on conflict) is not supported,an error
* will be reported, and the pg physical library will not guarantee an error pg使用h2库测试时不支持函数(on
* conflict)会报错,pg实体库不会报错
*/
@Test
public void testInsertRelations() {
String testInstance = "testInstance";
List<Integer> labelIds = new ArrayList<>();
labelIds.add(1);
labelIds.add(2);
insLabelRelationDao.insertRelations(testInstance, labelIds);
}

/**
* When using the h2 library for testing,if the function(on conflict) is not supported,an error
* will be reported, and the pg physical library will not guarantee an error pg使用h2库测试时不支持函数(on
* conflict)会报错,pg实体库不会报错
*/
@Test
public void testExistRelations() {
testInsertRelations();
Integer labelId = 1;
Integer integer = insLabelRelationDao.existRelations(1);
assertTrue(integer == 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@

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;

/**
* When using the h2 library for testing,if the function(on conflict) is not supported,an error will
* be reported, and the pg physical library will not guarantee an error pg使用h2库测试时不支持函数(on
Expand All @@ -38,50 +45,47 @@ void insert() {
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"));
// }
@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"));
}
}
Loading

0 comments on commit 8181aa1

Please sign in to comment.