From ef1ead870ddc908bb801ed7f10ef0ff3587d5752 Mon Sep 17 00:00:00 2001 From: Tangjiafeng <1282141182@qq.com> Date: Fri, 28 Jun 2024 10:47:40 +0800 Subject: [PATCH] Adjust comments --- .../wedatasphere/qualitis/BaseTest.java | 47 ---- ...rmArgumentsExecutionParametersDaoTest.java | 57 ---- .../ExecutionParametersDaoTest.java | 90 ------- .../ExecutionVariableDaoTest.java | 57 ---- .../NoiseEliminationManagementDaoTest.java | 59 ----- .../StaticExecutionParametersDaoTest.java | 57 ---- .../qualitis/filter/OuterSignatureTest.java | 70 ----- .../qualitis/metaclient/MetaClientTest.java | 46 ---- .../qualitis/predicate/PredicateTest.java | 134 ---------- .../project/ProjectRepositoryTest.java | 129 --------- .../project/ProjectUserRepositoryTest.java | 79 ------ .../scheduler/ExecutionManagerTest.java | 250 ------------------ .../qualitis/service/MetaDataServiceTest.java | 60 ----- .../standardValueVersion/StandardTest.java | 7 - .../StandardValueVersionDaoTest.java | 123 --------- .../qualitis/template/RuleTemplateTest.java | 182 ------------- .../qualitis/user/PermissionDaoTest.java | 82 ------ .../qualitis/user/RoleDaoTest.java | 82 ------ .../qualitis/user/RolePermissionDaoTest.java | 129 --------- .../qualitis/user/UserDaoTest.java | 82 ------ .../qualitis/user/UserRoleDaoTest.java | 124 --------- .../user/UserSpecPermissionDaoTest.java | 124 --------- .../impl/LinkisDataSourceServiceImpl.java | 8 +- 23 files changed, 4 insertions(+), 2074 deletions(-) delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/BaseTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/AlarmArgumentsExecutionParametersDaoTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/ExecutionParametersDaoTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/ExecutionVariableDaoTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/NoiseEliminationManagementDaoTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/StaticExecutionParametersDaoTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/filter/OuterSignatureTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/metaclient/MetaClientTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/predicate/PredicateTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/project/ProjectRepositoryTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/project/ProjectUserRepositoryTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/scheduler/ExecutionManagerTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/service/MetaDataServiceTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/standardValueVersion/StandardTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/standardValueVersion/StandardValueVersionDaoTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/template/RuleTemplateTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/user/PermissionDaoTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/user/RoleDaoTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/user/RolePermissionDaoTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/user/UserDaoTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/user/UserRoleDaoTest.java delete mode 100644 web/app/src/test/java/com/webank/wedatasphere/qualitis/user/UserSpecPermissionDaoTest.java diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/BaseTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/BaseTest.java deleted file mode 100644 index 352d3435..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/BaseTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.webank.wedatasphere.qualitis; - -import org.apache.commons.lang3.StringUtils; -import org.junit.Before; -import org.mockito.Spy; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import static org.mockito.Mockito.when; - -/** - * @author v_minminghe@webank.com - * @date 2023-03-23 14:38 - * @description - */ -public class BaseTest { - - @MockBean - @Spy - private HttpSession session; - @MockBean - @Spy - private HttpServletRequest httpServletRequest; - - protected String defaultLoginUserName = "allenzhou"; - protected Long defaultLoginUserId = 2L; - - protected void initLoginUser(String loginUserName, Long loginUserId) { - if (StringUtils.isEmpty(loginUserName)) { - loginUserName = defaultLoginUserName; - } - if (Objects.isNull(defaultLoginUserId)) { - loginUserId = defaultLoginUserId; - } - when(httpServletRequest.getSession()).thenReturn(session); - Map userMap = new HashMap<>(); - userMap.put("username", loginUserName); - userMap.put("userId", loginUserId); - when(session.getAttribute("user")).thenReturn(userMap); - } - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/AlarmArgumentsExecutionParametersDaoTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/AlarmArgumentsExecutionParametersDaoTest.java deleted file mode 100644 index 01c946c0..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/AlarmArgumentsExecutionParametersDaoTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.webank.wedatasphere.qualitis.executionParameters; - -import com.webank.wedatasphere.qualitis.rule.dao.AlarmArgumentsExecutionParametersDao; -import com.webank.wedatasphere.qualitis.rule.dao.repository.AlarmArgumentsExecutionParametersRepository; -import com.webank.wedatasphere.qualitis.rule.entity.AlarmArgumentsExecutionParameters; -import com.webank.wedatasphere.qualitis.rule.entity.ExecutionParameters; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -/** - * @author v_gaojiedeng@webank.com - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class AlarmArgumentsExecutionParametersDaoTest { - - @Autowired - AlarmArgumentsExecutionParametersDao alarmArgumentsExecutionParametersDao; - - @Autowired - AlarmArgumentsExecutionParametersRepository alarmArgumentsExecutionParametersRepository; - - @Test - @Transactional - public void test() { - AlarmArgumentsExecutionParameters alarmArgumentsExecutionParameters = saveAlarmArgumentsExecutionParameters(); - - AlarmArgumentsExecutionParameters execution = alarmArgumentsExecutionParametersDao.findById(alarmArgumentsExecutionParameters.getId()); - //删除后,是否还能找到对象 - alarmArgumentsExecutionParametersRepository.delete(execution); - AlarmArgumentsExecutionParameters deleteEntity = alarmArgumentsExecutionParametersDao.findById(execution.getId()); - assertNull(deleteEntity); - } - - private AlarmArgumentsExecutionParameters saveAlarmArgumentsExecutionParameters() { - //保存是否成功 - AlarmArgumentsExecutionParameters entity = new AlarmArgumentsExecutionParameters(); - entity.setAlarmEvent(4); - entity.setAlarmLevel(1); - entity.setAlarmReceiver("test"); - entity.setExecutionParameters(new ExecutionParameters()); - - AlarmArgumentsExecutionParameters alarmArgumentsExecutionParameters = alarmArgumentsExecutionParametersRepository.save(entity); - assertNotNull(alarmArgumentsExecutionParameters); - - return alarmArgumentsExecutionParameters; - } - - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/ExecutionParametersDaoTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/ExecutionParametersDaoTest.java deleted file mode 100644 index 852be80f..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/ExecutionParametersDaoTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.webank.wedatasphere.qualitis.executionParameters; - -import com.webank.wedatasphere.qualitis.constant.UnionWayEnum; -import com.webank.wedatasphere.qualitis.rule.dao.ExecutionParametersDao; -import com.webank.wedatasphere.qualitis.rule.entity.ExecutionParameters; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -import static org.junit.Assert.*; - -/** - * @author v_gaojiedeng@webank.com - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class ExecutionParametersDaoTest { - - @Autowired - ExecutionParametersDao executionParametersDao; - - @Test - @Transactional - public void test() { - ExecutionParameters saveExecutionParameters = saveExecutionParameters(); - - //总数量大于0 - long size = executionParametersDao.countTotal(3703L); - assertTrue(size > 0); - - //分页查询有结果 - List datas = executionParametersDao.findAll(3703L, 0, 5); - assertTrue(datas.size() > 0); - - //保存到数据库的对象是否和保存的值一致 - ExecutionParameters executionParameters = executionParametersDao.findById(saveExecutionParameters.getId()); - - assertNotNull(executionParameters); - assertEquals(executionParameters.getName(), saveExecutionParameters.getName()); - assertEquals(executionParameters.getConcurrencyGranularity(), saveExecutionParameters.getConcurrencyGranularity()); - - //根据name、projectId查询的数据库对象是否和保存的值一致 - - ExecutionParameters xxx = executionParametersDao.findByNameAndProjectId("xxx", 3703L); - assertNotNull(xxx); - assertEquals(xxx.getName(), saveExecutionParameters.getName()); - - //删除后,是否还能找到对象 - executionParametersDao.deleteExecutionParameters(xxx); - ExecutionParameters deleteEntity = executionParametersDao.findById(saveExecutionParameters.getId()); - assertNull(deleteEntity); - } - - private ExecutionParameters saveExecutionParameters() { - //保存是否成功 - ExecutionParameters entity = new ExecutionParameters(); - entity.setName("xxx"); - entity.setAbortOnFailure(false); - entity.setSpecifyStaticStartupParam(false); - entity.setStaticStartupParam(""); - entity.setAlert(false); - entity.setProjectId(3703L); - - entity.setAbnormalDataStorage(false); - entity.setAbnormalDatabase(""); - entity.setCluster(""); - entity.setAbnormalProxyUser(""); - entity.setSpecifyFilter(false); - entity.setDeleteFailCheckResult(false); - entity.setUploadAbnormalValue(false); - entity.setUploadRuleMetricValue(false); - entity.setUnionWay(UnionWayEnum.NO_COLLECT_CALCULATE.getCode()); - entity.setWhetherNoise(false); - entity.setExecutionVariable(false); - entity.setEngineReuse(true); - entity.setConcurrencyGranularity("split_by:table"); - entity.setDynamicPartitioning(false); - - ExecutionParameters saveEntity = executionParametersDao.saveExecutionParameters(entity); - assertTrue(saveEntity.getId() != 0); - return saveEntity; - } - - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/ExecutionVariableDaoTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/ExecutionVariableDaoTest.java deleted file mode 100644 index 0684117c..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/ExecutionVariableDaoTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.webank.wedatasphere.qualitis.executionParameters; - -import com.webank.wedatasphere.qualitis.rule.dao.ExecutionVariableDao; -import com.webank.wedatasphere.qualitis.rule.dao.repository.ExecutionVariableRepository; -import com.webank.wedatasphere.qualitis.rule.entity.ExecutionParameters; -import com.webank.wedatasphere.qualitis.rule.entity.ExecutionVariable; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -/** - * @author v_gaojiedeng@webank.com - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class ExecutionVariableDaoTest { - - @Autowired - ExecutionVariableDao executionVariableDao; - - @Autowired - ExecutionVariableRepository executionVariableRepository; - - @Test - @Transactional - public void test() { - ExecutionVariable executionVariable = saveExecutionVariable(); - - ExecutionVariable execution = executionVariableDao.findById(executionVariable.getId()); - //删除后,是否还能找到对象 - executionVariableRepository.delete(execution); - ExecutionVariable deleteEntity = executionVariableDao.findById(execution.getId()); - assertNull(deleteEntity); - } - - private ExecutionVariable saveExecutionVariable() { - //保存是否成功 - ExecutionVariable entity = new ExecutionVariable(); - entity.setVariableType(1); - entity.setVariableName("fps_id"); - entity.setVariableValue("2026"); - entity.setExecutionParameters(new ExecutionParameters()); - - ExecutionVariable executionVariable = executionVariableRepository.save(entity); - assertNotNull(executionVariable); - - return executionVariable; - } - - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/NoiseEliminationManagementDaoTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/NoiseEliminationManagementDaoTest.java deleted file mode 100644 index 8048adc4..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/NoiseEliminationManagementDaoTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.webank.wedatasphere.qualitis.executionParameters; - -import com.webank.wedatasphere.qualitis.rule.dao.NoiseEliminationManagementDao; -import com.webank.wedatasphere.qualitis.rule.dao.repository.NoiseEliminationManagementRepository; -import com.webank.wedatasphere.qualitis.rule.entity.ExecutionParameters; -import com.webank.wedatasphere.qualitis.rule.entity.NoiseEliminationManagement; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -/** - * @author v_gaojiedeng@webank.com - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class NoiseEliminationManagementDaoTest { - - @Autowired - NoiseEliminationManagementDao noiseEliminationManagementDao; - - @Autowired - NoiseEliminationManagementRepository noiseEliminationManagementRepository; - - @Test - @Transactional - public void test() { - NoiseEliminationManagement noiseEliminationManagement = saveNoiseEliminationManagement(); - - NoiseEliminationManagement execution = noiseEliminationManagementDao.findById(noiseEliminationManagement.getId()); - //删除后,是否还能找到对象 - noiseEliminationManagementRepository.delete(execution); - NoiseEliminationManagement deleteEntity = noiseEliminationManagementDao.findById(execution.getId()); - assertNull(deleteEntity); - } - - private NoiseEliminationManagement saveNoiseEliminationManagement() { - //保存是否成功 - NoiseEliminationManagement entity = new NoiseEliminationManagement(); - entity.setDateSelectionMethod(1); - entity.setBusinessDate("1673452800000,1674057600000"); - entity.setTemplateId(1L); - entity.setNoiseNormRatio("[{\"output_meta_id\":2,\"output_meta_name\":\"主键重复数目\",\"check_template\":1,\"compare_type\":\"\",\"threshold\":\"1\"},{\"output_meta_id\":2,\"output_meta_name\":\"主键重复数目\",\"check_template\":2,\"compare_type\":\"\",\"threshold\":\"2\"},{\"output_meta_id\":2,\"output_meta_name\":\"主键重复数目\",\"check_template\":8,\"compare_type\":1,\"threshold\":\"33\"}]"); - entity.setEliminateStrategy(1); - entity.setAvailable(true); - entity.setExecutionParameters(new ExecutionParameters()); - - NoiseEliminationManagement noiseEliminationManagement = noiseEliminationManagementRepository.save(entity); - assertNotNull(noiseEliminationManagement); - - return noiseEliminationManagement; - } - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/StaticExecutionParametersDaoTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/StaticExecutionParametersDaoTest.java deleted file mode 100644 index 22268169..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/executionParameters/StaticExecutionParametersDaoTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.webank.wedatasphere.qualitis.executionParameters; - -import com.webank.wedatasphere.qualitis.rule.dao.StaticExecutionParametersDao; -import com.webank.wedatasphere.qualitis.rule.dao.repository.StaticExecutionParametersRepository; -import com.webank.wedatasphere.qualitis.rule.entity.ExecutionParameters; -import com.webank.wedatasphere.qualitis.rule.entity.StaticExecutionParameters; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -/** - * @author v_gaojiedeng@webank.com - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class StaticExecutionParametersDaoTest { - - @Autowired - StaticExecutionParametersDao staticExecutionParametersDao; - - @Autowired - StaticExecutionParametersRepository staticExecutionParametersRepository; - - @Test - @Transactional - public void test() { - StaticExecutionParameters staticExecutionParameters = saveStaticExecutionParameters(); - - StaticExecutionParameters execution = staticExecutionParametersDao.findById(staticExecutionParameters.getId()); - //删除后,是否还能找到对象 - staticExecutionParametersRepository.delete(execution); - StaticExecutionParameters deleteEntity = staticExecutionParametersDao.findById(execution.getId()); - assertNull(deleteEntity); - } - - private StaticExecutionParameters saveStaticExecutionParameters() { - //保存是否成功 - StaticExecutionParameters entity = new StaticExecutionParameters(); - entity.setParameterType(1); - entity.setParameterName("wds.linkis.rm.yarnqueue.instance.max"); - entity.setParameterValue("30"); - entity.setExecutionParameters(new ExecutionParameters()); - - StaticExecutionParameters staticExecutionParameters = staticExecutionParametersRepository.save(entity); - assertNotNull(staticExecutionParameters); - - return staticExecutionParameters; - } - - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/filter/OuterSignatureTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/filter/OuterSignatureTest.java deleted file mode 100644 index b2d6a672..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/filter/OuterSignatureTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.webank.wedatasphere.qualitis.filter; -import cn.hutool.crypto.digest.DigestUtil; -import org.apache.commons.lang3.StringUtils; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.util.Assert; - -import java.io.UnsupportedEncodingException; -import java.math.BigInteger; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * @author v_minminghe@webank.com - * @date 2024-04-10 9:34 - * @description - */ -@RunWith(SpringRunner.class) -public class OuterSignatureTest { - - @Test - public void generateSign() { - String nonce = "16895"; - String timeStamp = String.valueOf(System.currentTimeMillis()); - MessageDigest hash; - - StringBuilder resultInner = new StringBuilder(); - StringBuilder resultOuter = new StringBuilder(); - //app_id: linkis_id - String plain = "linkis_id" + nonce + timeStamp; - - try { - hash = MessageDigest.getInstance("SHA-256"); - hash.update(plain.getBytes("UTF-8")); - resultInner.append(new BigInteger(1, hash.digest()).toString(16)); - String inner = StringUtils.leftPad(resultInner.toString(), 32, '0'); - - hash.reset(); - //app_token :***REMOVED*** - hash.update(inner.concat("***REMOVED***").getBytes("UTF-8")); - resultOuter.append(new BigInteger(1, hash.digest()).toString(16)); - String signature = StringUtils.leftPad(resultOuter.toString(), 32, '0'); - Assert.hasText(signature, "empty string"); - - //加密签名方式1 - //System.out.println(getSignature(nonce, timeStamp, "***REMOVED***", "linkis_id")); - //加密签名方式2 -// System.out.println("timeStamp: " + timeStamp); -// System.out.println("signature: " + signature); - - } catch (NoSuchAlgorithmException e) { -// doing nothing - } catch (UnsupportedEncodingException e) { -// doing nothing - } - } - - @Test - public void generateItsmSign() { -// uat - String secretKey = "4b968eca0ab8302d9bcd711e7177769c880ad28588d75db101657a7b665d2807"; - long timeStamp = System.currentTimeMillis(); - String signature = DigestUtil.sha256Hex(secretKey + timeStamp); - Assert.hasText(signature, "empty string"); -// System.out.println("timeStamp: " + timeStamp); -// System.out.println("signature: " + signature); - } - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/metaclient/MetaClientTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/metaclient/MetaClientTest.java deleted file mode 100644 index e889277b..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/metaclient/MetaClientTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.webank.wedatasphere.qualitis.metaclient; - -import com.webank.wedatasphere.qualitis.config.DpmConfig; -import com.webank.wedatasphere.qualitis.metadata.client.MetaDataClient; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.web.client.RestTemplate; - -import java.util.Map; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class MetaClientTest { - @Autowired - private MetaDataClient metaDataClient; - - @Autowired - private RestTemplate restTemplate; - - @Autowired - private DpmConfig dpmConfig; - - private static final Logger logger = LoggerFactory.getLogger(MetaClientTest.class); - - @Test - public void testPartitionStatisticInfo() { - String url = "http://10.107.116.91:8088/api/rest_j/v1/datasource/getPartitionStatisticInfo?database=bdp_test_ods_mask&tableName=100threepartiontest&partitionPath=/ds=20180830"; - - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - headers.add("Token-User", "neiljianliu"); - headers.add("Token-Code", "QUALITIS-AUTH"); - - HttpEntity entity = new HttpEntity<>(headers); - restTemplate.exchange(url, HttpMethod.GET, entity, Map.class).getBody(); - } -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/predicate/PredicateTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/predicate/PredicateTest.java deleted file mode 100644 index ad1ae977..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/predicate/PredicateTest.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2019 WeBank - * - * Licensed 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 com.webank.wedatasphere.qualitis.predicate; - -import com.webank.wedatasphere.qualitis.dao.TaskDataSourceDao; -import com.webank.wedatasphere.qualitis.entity.TaskDataSource; -import com.webank.wedatasphere.qualitis.project.constant.ProjectUserPermissionEnum; -import com.webank.wedatasphere.qualitis.project.dao.ProjectUserDao; -import com.webank.wedatasphere.qualitis.project.entity.ProjectUser; -import com.webank.wedatasphere.qualitis.project.queryqo.DataSourceQo; -import com.webank.wedatasphere.qualitis.rule.dao.RuleDataSourceDao; -import com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * 在DaoImpl中使用了Predicate动态查询的做单元测试 - * @author v_wblwyan - * @date 2018-11-29 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class PredicateTest { - - @Autowired - ProjectUserDao dao; - - @Autowired - TaskDataSourceDao taskDataSourceDao; - - @Autowired - RuleDataSourceDao ruleDataSourceDao; - - @Test - @Transactional - public void test() { - String user = "v_wblwyan_test1"; - - /* - * ProjectUserDao测试 - */ - DataSourceQo param = new DataSourceQo(); - param.setUser(user); - param.setUserType(new Integer[] { - ProjectUserPermissionEnum.CREATOR.getCode()}); - - List projectUsers = dao.findByUsernameAndPermissionsIn(param); - assertTrue(projectUsers.isEmpty()); - - param.setUserType(new Integer[] {ProjectUserPermissionEnum.CREATOR.getCode()}); - projectUsers = dao.findByUsernameAndPermissionsIn(param); - assertTrue(projectUsers.isEmpty()); - - param.setUserType(null); - projectUsers = dao.findByUsernameAndPermissionsIn(param); - assertTrue(projectUsers.isEmpty()); - - param.setUserType(new Integer[] {}); - projectUsers = dao.findByUsernameAndPermissionsIn(param); - assertTrue(projectUsers.isEmpty()); - - /* - *TaskDataSourceDao 测试 - */ - List taskDataSources = taskDataSourceDao.findByUserAndDataSource(user, null, - null, null, 0, - 5); - assertTrue(taskDataSources.isEmpty()); - - taskDataSources = taskDataSourceDao.findByUserAndDataSource(user, "clusterName_test", null, - null, 0, 5); - assertTrue(taskDataSources.isEmpty()); - - taskDataSources = taskDataSourceDao.findByUserAndDataSource(user, "clusterName_test", - "databaseName_test", null, 0, 5); - assertTrue(taskDataSources.isEmpty()); - - taskDataSources = taskDataSourceDao.findByUserAndDataSource(user, "clusterName_test", - "databaseName_test", - "tableName_test", 0, 5); - assertTrue(taskDataSources.isEmpty()); - - long count = taskDataSourceDao.countByUserAndDataSource(user, "clusterName_test", - "databaseName_test", null); - assertEquals(0, count); - - - /* - *RuleDataSourceDao 测试 - */ - List ruleDataSources = ruleDataSourceDao.findByProjectUser( - (long) Integer.MAX_VALUE, null, null, null); - assertTrue(ruleDataSources.isEmpty()); - - ruleDataSources = ruleDataSourceDao.findByProjectUser((long) Integer.MAX_VALUE, - "clusterName_test", null, null); - assertTrue(ruleDataSources.isEmpty()); - - ruleDataSources = ruleDataSourceDao.findByProjectUser((long) Integer.MAX_VALUE, - "clusterName_test", "databaseName_test", - null); - assertTrue(ruleDataSources.isEmpty()); - - ruleDataSources = ruleDataSourceDao.findByProjectUser((long) Integer.MAX_VALUE, - "clusterName_test", "databaseName_test", - "tableName_test"); - assertTrue(ruleDataSources.isEmpty()); - } - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/project/ProjectRepositoryTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/project/ProjectRepositoryTest.java deleted file mode 100644 index b175f944..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/project/ProjectRepositoryTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2019 WeBank - * - * Licensed 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 com.webank.wedatasphere.qualitis.project; - -import com.webank.wedatasphere.qualitis.project.dao.repository.ProjectRepository; -import com.webank.wedatasphere.qualitis.project.entity.Project; -import java.nio.charset.Charset; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.List; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import static org.junit.Assert.*; - -/** - * @author v_wblwyan - * @date 2018-11-20 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class ProjectRepositoryTest { - - private static final Logger LOGGER = LoggerFactory.getLogger(ProjectRepositoryTest.class); - @Autowired - ProjectRepository repository; - - public void extract(String zipFilePath, String destDirectory) throws IOException { - File destDir = new File(destDirectory); - if (!destDir.exists()) { - destDir.mkdir(); - } - try (ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath), Charset.forName("UTF-8"))) { - ZipEntry entry = zipIn.getNextEntry(); - while (entry != null) { - String filePath = destDirectory + File.separator + entry.getName(); - if (!entry.isDirectory()) { - extractFile(zipIn, filePath); - } else { - File dir = new File(filePath); - dir.mkdir(); - } - zipIn.closeEntry(); - entry = zipIn.getNextEntry(); - } - }catch (Exception e) { - LOGGER.error(e.getMessage(), e); - } - - } - - private void extractFile(ZipInputStream zipIn, String filePath) throws IOException { - try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath))) { - byte[] bytesIn = new byte[4096]; - int read = 0; - while ((read = zipIn.read(bytesIn)) != -1) { - bos.write(bytesIn, 0, read); - } - } - - } - - @Test - public void testUnzipFiles() throws IOException { - File zipFile = new File("D:\\share\\merge\\qualitis\\tmp\\allenzhou\\f136beeaf8314f4e8d5bcb016d45c152.zip"); - extract(zipFile.getPath(), zipFile.getParentFile().getPath()); -// // First, create zip file that points to the disk. -// ZipFile zFile = new ZipFile(zipFile); -// // Extract the file to the unzip directory -// zFile.extractAll(zipFile.getParentFile().getPath()); -// List headerList = zFile.getFileHeaders(); -// for (FileHeader fileHeader : headerList) { -// if (!fileHeader.isDirectory()) { -// } -// } - } - - @Test - @Transactional - public void test() { - //保存是否成功 - Project entity = new Project(); - entity.setName("junitProject"); - entity.setCreateUser("setCreateUser"); - entity.setCreateUserFullName("setCreateUserFullName"); - entity.setDescription("setDescription"); - entity.setDepartment("setUserDepartment"); - Project saveEntity = repository.save(entity); - assertTrue(saveEntity.getId() != 0); - - - //保存到数据库的对象是否和保存的值一致 - List findByCreateUserList = repository.findByCreateUser(saveEntity.getCreateUser()); - assertTrue(findByCreateUserList.size() > 0); - assertEquals(findByCreateUserList.get(0).getName(), saveEntity.getName()); - - //根据username查询的数据库对象是否和保存的值一致 - Project findByNameUser = repository.findByName(saveEntity.getName()); - assertNotNull(findByNameUser); - assertEquals(findByNameUser.getName(), saveEntity.getName()); - } - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/project/ProjectUserRepositoryTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/project/ProjectUserRepositoryTest.java deleted file mode 100644 index 05a10c6f..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/project/ProjectUserRepositoryTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2019 WeBank - * - * Licensed 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 com.webank.wedatasphere.qualitis.project; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import com.webank.wedatasphere.qualitis.project.constant.ProjectUserPermissionEnum; -import com.webank.wedatasphere.qualitis.project.dao.repository.ProjectRepository; -import com.webank.wedatasphere.qualitis.project.dao.repository.ProjectUserRepository; -import com.webank.wedatasphere.qualitis.project.entity.Project; -import com.webank.wedatasphere.qualitis.project.entity.ProjectUser; -import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author v_wblwyan - * @date 2018-11-20 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class ProjectUserRepositoryTest { - - @Autowired - ProjectUserRepository repository; - - @Autowired - ProjectRepository projectRepository; - - @Test - @Transactional - public void test() { - //保存是否成功 - Project project = new Project(); - project.setName("junitProject"); - project.setCreateUser("setCreateUser"); - project.setCreateUserFullName("setCreateUserFullName"); - project.setDescription("setDescription"); - project.setDepartment("setUserDepartment"); - Project saveProject = projectRepository.save(project); - assertTrue(saveProject.getId() != 0); - - ProjectUser saveEntity = new ProjectUser(ProjectUserPermissionEnum.CREATOR.getCode(), project, - "v_wblwyan_test", false); - ProjectUser entity = repository.save(saveEntity); - - //根据username查询的数据库对象是否和保存的值一致 - List findByUserNameList = repository.findByUserName(entity.getUserName()); - assertTrue(findByUserNameList.size() > 0); - assertEquals(findByUserNameList.get(0).getUserName(), entity.getUserName()); - - //删除后,是否还能找到对象 - repository.deleteByProject(project); - List deleteEntity = repository.findByUserName(entity.getUserName()); - assertTrue(deleteEntity.isEmpty()); - - } - - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/scheduler/ExecutionManagerTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/scheduler/ExecutionManagerTest.java deleted file mode 100644 index e9393252..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/scheduler/ExecutionManagerTest.java +++ /dev/null @@ -1,250 +0,0 @@ -package com.webank.wedatasphere.qualitis.scheduler; - -import cn.hutool.core.date.DateUnit; -import cn.hutool.core.date.DateUtil; -import com.google.common.base.Joiner; -import com.google.common.base.Splitter; -import com.google.common.collect.Maps; -import com.webank.wedatasphere.qualitis.bean.DataQualityJob; -import com.webank.wedatasphere.qualitis.checkalert.entity.CheckAlert; -import com.webank.wedatasphere.qualitis.config.ImsConfig; -import com.webank.wedatasphere.qualitis.config.LinkisConfig; -import com.webank.wedatasphere.qualitis.constant.SpecCharEnum; -import com.webank.wedatasphere.qualitis.dto.ItsmUserDto; -import com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException; -import com.webank.wedatasphere.qualitis.project.entity.Project; -import com.webank.wedatasphere.qualitis.request.AddUserProxyUserRequest; -import com.webank.wedatasphere.qualitis.service.UserProxyUserService; -import com.webank.wedatasphere.qualitis.submitter.ExecutionManager; -import com.webank.wedatasphere.qualitis.util.DateExprReplaceUtil; -import net.sf.jsqlparser.JSQLParserException; -import net.sf.jsqlparser.parser.CCJSqlParserUtil; -import net.sf.jsqlparser.schema.Table; -import net.sf.jsqlparser.statement.Statement; -import net.sf.jsqlparser.statement.StatementVisitorAdapter; -import net.sf.jsqlparser.statement.select.PlainSelect; -import net.sf.jsqlparser.statement.select.Select; -import net.sf.jsqlparser.statement.select.SelectVisitorAdapter; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.Assert; - -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -/** - * @author v_minminghe@webank.com - * @date 2024-03-12 10:58 - * @description - */ -//@RunWith(SpringRunner.class) -//@SpringBootTest -public class ExecutionManagerTest { - - @Autowired - private ExecutionManager executionManager; - @Autowired - private ImsConfig imsConfig; - @Autowired - private LinkisConfig linkisConfig; - @Autowired - private UserProxyUserService userProxyUserService; - private static final Logger LOGGER = LoggerFactory.getLogger(ExecutionManagerTest.class); - - - public static String addHivePrefixToTables(String sql) { - try { - Statement statement = CCJSqlParserUtil.parse(sql); - statement.accept(new StatementVisitorAdapter() { - @Override - public void visit(Select select) { - select.getSelectBody().accept(new SelectVisitorAdapter() { - @Override - public void visit(PlainSelect plainSelect) { - if (plainSelect.getFromItem() instanceof Table) { - Table table = (Table) plainSelect.getFromItem(); - modifyTable(table); - } - if (plainSelect.getJoins() != null) { - plainSelect.getJoins().forEach(join -> { - if (join.getRightItem() instanceof Table) { - Table table = (Table) join.getRightItem(); - modifyTable(table); - } - }); - } - } - }); - } - }); - return statement.toString(); - } catch (JSQLParserException e) { - e.printStackTrace(); - return null; - } - } - - private static void modifyTable(Table table) { - String originalTableName = table.getFullyQualifiedName(); - if (originalTableName.contains(".")) { - String[] parts = originalTableName.split("\\.", 2); - String dbName = parts[0]; - String tableName = parts[1]; - table.setSchemaName("hive." + dbName); - table.setName(tableName); - } else { - // 如果只有表名没有库名,也可以在这里添加默认库前缀 - // table.setSchemaName("hive"); // 可选 - } - } - - @Test - public void addMultiProxyUser() { - String proxyUsers = "hduser02,hduser0201,hduser0203,hduser0204,hduser0205,hduser0206,hduser0207,hduser0208,hduser0209,hduser0210,hduser0211,hduser0212,hduser0213,hduser0214,hduser0215,hduser0216,hduser0217,hduser0218,hduser0219,hduser0220,hduser0221,hduser0222,hduser0223,hduser0224,hduser0225,hduser0226,hduser0227,hduser0232,hduser0233,hduser0234,hduser0295,hduser1001,hduser1002,hduser1003,hduser1004,hduser1005,hduser1006,hduser1007,hduser1008,hduser1009,hduser1010,hduser1011,hduser1015,hduser1016,hduser1017,hduser1021,hduser1030,hduser1038,hduser1040,hduser1050,hduser1051,hduser1052,hduser1053,hduser1059,hduser1061,hduser1080,hduser1088,hduser1089,hduser1091"; - - ItsmUserDto itsmUserDto = new ItsmUserDto(); - itsmUserDto.setUsername("v_minminghe"); - itsmUserDto.setProxyUser(proxyUsers); - if (org.apache.commons.lang3.StringUtils.isNotBlank(itsmUserDto.getProxyUser())) { - Iterable proxyUserIterable = Splitter.on(SpecCharEnum.COMMA.getValue()).omitEmptyStrings().trimResults().split(itsmUserDto.getProxyUser()); - proxyUserIterable.forEach(proxyUser -> { - AddUserProxyUserRequest addUserProxyUserRequest = new AddUserProxyUserRequest(); - addUserProxyUserRequest.setUsername(itsmUserDto.getUsername()); - addUserProxyUserRequest.setProxyUserName(proxyUser); - try { - userProxyUserService.addUserProxyUser(addUserProxyUserRequest); - } catch (UnExpectedRequestException e) { - LOGGER.warn("Failed to add proxyUser: {}, username: {}, reason: {}", proxyUser, itsmUserDto.getUsername(), e.getMessage()); - } - }); - } - - } - - - private Map extractAlertReceivers(List alertReceivers) { - AtomicReference erpGroupId = new AtomicReference<>(); - List defaultReceivers = new ArrayList<>(); - alertReceivers.forEach(item -> { - if (item.startsWith(SpecCharEnum.LEFT_BRACKET.getValue()) && item.endsWith(SpecCharEnum.RIGHT_BRACKET.getValue())) { - erpGroupId.set(item.substring(1, item.length() - 1)); - } else { - defaultReceivers.add(item); - } - }); - Map resultMap = Maps.newHashMapWithExpectedSize(2); - if (erpGroupId.get() != null) { - resultMap.put("erp_group_id", erpGroupId.get()); - } - if (CollectionUtils.isNotEmpty(defaultReceivers)) { - resultMap.put("alert_reciver", Joiner.on(SpecCharEnum.COMMA.getValue()).join(defaultReceivers)); - } - return resultMap; - } - - private CheckAlert getCheckAlert() { - CheckAlert checkAlert = new CheckAlert(); - checkAlert.setTopic("test_topic"); - checkAlert.setDefaultReceiver("v_minminghe"); - checkAlert.setDefaultAlertLevel(2); - checkAlert.setDefaultAlertWays("2,3"); - checkAlert.setAdvancedReceiver("allenzhou"); - checkAlert.setAdvancedAlertLevel(3); - checkAlert.setAdvancedAlertWays("1,4"); - checkAlert.setAdvancedAlertCol("major_col"); - checkAlert.setWorkFlowName("wf_rule"); - checkAlert.setNodeName("node_alert"); - Project project = new Project(); - project.setName("ces_pro"); - checkAlert.setProject(project); - return checkAlert; - } - - @Test - public void composeJobCodesTest() throws UnExpectedRequestException { - DataQualityJob job = new DataQualityJob(); - List jobCodes = job.getJobCode(); - List selectPart = new ArrayList<>(); - List contentTitle = new ArrayList<>(); - - jobCodes.add("import sys.process._"); - jobCodes.add("import scala.util.parsing.json._"); - - CheckAlert currentCheckAlert = getCheckAlert(); - - String realContent = "\"" + linkisConfig.getCheckAlertTemplate().replace("qualitis_check_alert_topic", currentCheckAlert.getTopic()).replace("qualitis_check_alert_time", "2024/03/12").replace("qualitis_check_alert_project_info", currentCheckAlert.getProject().getName() + SpecCharEnum.COLON.getValue() + currentCheckAlert.getWorkFlowName() + SpecCharEnum.COLON.getValue() + currentCheckAlert.getNodeName()) + "\""; - - jobCodes.add("var alertContent = " + realContent); - String filter = StringUtils.isNotEmpty(currentCheckAlert.getFilter()) ? currentCheckAlert.getFilter() : "true"; - - filter = DateExprReplaceUtil.replaceFilter(new Date(), filter); - jobCodes.add("val alertTableArr = spark.sql(\"SELECT " + StringUtils.join(selectPart, SpecCharEnum.COMMA.getValue()) - + " FROM " + currentCheckAlert.getAlertTable() + " WHERE " + currentCheckAlert.getAlertCol() + " = 1 AND " + filter + "\").collect()"); - jobCodes.add("var alertTableContent = \"\""); - jobCodes.add("for(ele <- alertTableArr) {alertTableContent = alertTableContent.concat(ele.mkString(\" | \")).concat(\"\\n\")}"); - jobCodes.add("if (alertTableContent.length > 0) {"); - jobCodes.add("alertContent = alertContent.replaceAll(\"qualitis_check_alert_default_content\", alertTableContent)"); - jobCodes.add("alertContent = alertContent.replaceAll(\"qualitis_check_alert_default_receiver\", \"" + currentCheckAlert.getDefaultReceiver() + "\")"); - jobCodes.add("alertContent = alertContent.replaceAll(\"qualitis_check_alert_default_title\", \"" + StringUtils.join(contentTitle, "|") + "\")"); - jobCodes.add("} else {"); - jobCodes.add("alertContent = alertContent.replaceAll(\"qualitis_check_alert_default_content\", \"\")"); - jobCodes.add("alertContent = alertContent.replaceAll(\"\\\\[告警人\\\\] qualitis_check_alert_default_receiver\", \"\")"); - - jobCodes.add("alertContent = alertContent.replaceAll(\"qualitis_check_alert_default_title\", \"\")"); - jobCodes.add("}"); - - if (StringUtils.isNotEmpty(currentCheckAlert.getAdvancedAlertCol())) { - jobCodes.add("val majorAlertTableArr = spark.sql(\"SELECT " + StringUtils.join(selectPart, SpecCharEnum.COMMA.getValue()) - + " FROM " + currentCheckAlert.getAlertTable() + " WHERE " + currentCheckAlert.getAdvancedAlertCol() + " = 1 AND " + filter + "\").collect()"); - jobCodes.add("var majorAlertTableContent = \"\""); - jobCodes.add("for(ele <- majorAlertTableArr) {majorAlertTableContent = majorAlertTableContent.concat(ele.mkString(\" | \")).concat(\"\\n\")}"); - jobCodes.add("if (majorAlertTableContent.length > 0) {"); - jobCodes.add("alertContent = alertContent.replaceAll(\"qualitis_check_alert_advanced_content\", majorAlertTableContent)"); - jobCodes.add("alertContent = alertContent.replaceAll(\"qualitis_check_alert_advanced_receiver\", \"" + (StringUtils.isNotEmpty(currentCheckAlert.getAdvancedReceiver()) ? currentCheckAlert.getAdvancedReceiver() : "") + "\")"); - jobCodes.add("alertContent = alertContent.replaceAll(\"qualitis_check_alert_advanced_title\", \"" + StringUtils.join(contentTitle, "|") + "\")"); - // CURL IMS - if (StringUtils.isNotEmpty(currentCheckAlert.getAdvancedReceiver())) { - jobCodes.add("val jsonAdvancedValue = " + "\"{\\\"userAuthKey\\\":\\\"" + imsConfig.getUserAuthKey() + "\\\",\\\"alertList\\\":[{\\\"alert_way\\\":\\\"" + currentCheckAlert.getAdvancedAlertWays() + "\\\",\\\"alert_title\\\":\\\"【业务运维关注】Qualitis Check Alert\\\",\\\"ci_type_id\\\":55,\\\"sub_system_id\\\":" + imsConfig.getSystemId() + ",\\\"alert_reciver\\\":\\\"" + currentCheckAlert.getAdvancedReceiver() + "\\\",\\\"alert_level\\\":\\\"" + currentCheckAlert.getAdvancedAlertLevel() + "\\\",\\\"alert_obj\\\":\\\"" + "dbAndTables[0]" + "[" + "dbAndTables[1]" + "]" + "\\\",\\\"alert_info\\\":\\\"qualitis_check_alert_Advanced\\\"}]}\""); - jobCodes.add("val realJsonAdvancedValue = jsonAdvancedValue.replaceAll(\"qualitis_check_alert_Advanced\", alertContent)"); - jobCodes.add("val jsonAdvancedCmd = Seq(\"curl\", \"-H\", \"'Content-Type: application/json'\",\"-d\", s\"$realJsonAdvancedValue\",\"" + imsConfig.getUrl() + imsConfig.getSendAlarmPath() + "\")"); - jobCodes.add("val advancedResponse = jsonAdvancedCmd.!!"); - jobCodes.add("val code = JSON.parseFull(advancedResponse).get.asInstanceOf[Map[String, Object]].get(\"resultCode\").get.toString"); - jobCodes.add("if (! \"0.0\".equals(code)) throw new RuntimeException(\"Failed to send ims alarm. Return non-zero code from IMS.\")"); - } - jobCodes.add("} else {"); - jobCodes.add("alertContent = alertContent.replaceAll(\"qualitis_check_alert_advanced_content\", \"\")"); - jobCodes.add("alertContent = alertContent.replaceAll(\"\\\\[高等级告警人\\\\] qualitis_check_alert_advanced_receiver\", \"\")"); - - jobCodes.add("alertContent = alertContent.replaceAll(\"qualitis_check_alert_advanced_title\", \"\")"); - jobCodes.add("}"); - } else { - jobCodes.add("alertContent = alertContent.replaceAll(\"qualitis_check_alert_advanced_content\", \"\")"); - jobCodes.add("alertContent = alertContent.replaceAll(\"\\\\[高等级告警人\\\\] qualitis_check_alert_advanced_receiver\", \"\")"); - - jobCodes.add("alertContent = alertContent.replaceAll(\"qualitis_check_alert_advanced_title\", \"\")"); - } - // CURL IMS - jobCodes.add("if (alertTableContent.length > 0) {"); - jobCodes.add("val jsonDefaultValue = " + "\"{\\\"userAuthKey\\\":\\\"" + imsConfig.getUserAuthKey() + "\\\",\\\"alertList\\\":[{\\\"alert_way\\\":\\\"" + currentCheckAlert.getDefaultAlertWays() + "\\\",\\\"alert_title\\\":\\\"【业务运维关注】Qualitis Check Alert\\\",\\\"ci_type_id\\\":55,\\\"sub_system_id\\\":" + imsConfig.getSystemId() + ",\\\"alert_reciver\\\":\\\"" + currentCheckAlert.getDefaultReceiver() + "\\\",\\\"alert_level\\\":\\\"" + currentCheckAlert.getDefaultAlertLevel() + "\\\",\\\"alert_obj\\\":\\\"" + "dbAndTables[0]" + "[" + "dbAndTables[1]" + "]" + "\\\",\\\"alert_info\\\":\\\"qualitis_check_alert_info\\\"}]}\""); - jobCodes.add("val realJsonDefaultValue = jsonDefaultValue.replaceAll(\"qualitis_check_alert_info\", alertContent)"); - jobCodes.add("val jsonDefaultCmd = Seq(\"curl\", \"-H\", \"'Content-Type: application/json'\",\"-d\", s\"$realJsonDefaultValue\",\"" + imsConfig.getUrl() + imsConfig.getSendAlarmPath() + "\")"); - jobCodes.add("val defaultResponse = jsonDefaultCmd.!!"); - jobCodes.add("val code = JSON.parseFull(defaultResponse).get.asInstanceOf[Map[String, Object]].get(\"resultCode\").get.toString"); - jobCodes.add("if (! \"0.0\".equals(code)) throw new RuntimeException(\"Failed to send ims alarm. Return non-zero code from IMS.\")"); - jobCodes.add("}"); - - String code = String.join("\n", job.getJobCode()); - Assert.hasText(code, "empty string"); -// System.out.println("result: " + code); - } - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/service/MetaDataServiceTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/service/MetaDataServiceTest.java deleted file mode 100644 index a8fdbc09..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/service/MetaDataServiceTest.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.webank.wedatasphere.qualitis.service; - -import com.webank.wedatasphere.qualitis.BaseTest; -import com.webank.wedatasphere.qualitis.client.impl.MetaDataClientImpl; -import com.webank.wedatasphere.qualitis.constants.ResponseStatusConstants; -import com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException; -import com.webank.wedatasphere.qualitis.metadata.client.MetaDataClient; -import com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException; -import com.webank.wedatasphere.qualitis.response.GeneralResponse; -import com.webank.wedatasphere.qualitis.service.impl.MetaDataServiceImpl; -import com.webank.wedatasphere.qualitis.util.HttpUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import java.util.HashMap; -import java.util.Map; - -import static org.mockito.Mockito.when; - -/** - * @author v_minminghe@webank.com - * @date 2023-03-21 9:47 - * @description - */ -@RunWith(MockitoJUnitRunner.class) -//@SpringBootTest -public class MetaDataServiceTest extends BaseTest { - -// 注入测试目标类 - @InjectMocks - private MetaDataServiceImpl metaDataService; -// 模拟目标类中的依赖类 - @MockBean - @Spy - private MetaDataClient metaDataClient; - - @Before - public void setup() { - super.initLoginUser(null, null); - } - - @Test - public void testGetAllDataSourceTypes() throws UnExpectedRequestException, MetaDataAcquireFailedException { - String clusterName = "BDP-CLIENT"; - GeneralResponse> mockGeneralResponse = new GeneralResponse<>(); - mockGeneralResponse.setCode("200"); - when(metaDataClient.getAllDataSourceTypes(clusterName, super.defaultLoginUserName)).thenReturn(mockGeneralResponse); - GeneralResponse> generalResponse = metaDataService.getAllDataSourceTypes(clusterName, null); - Assert.assertEquals(ResponseStatusConstants.OK, generalResponse.getCode()); - } -} \ No newline at end of file diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/standardValueVersion/StandardTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/standardValueVersion/StandardTest.java deleted file mode 100644 index dde4b7d0..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/standardValueVersion/StandardTest.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.webank.wedatasphere.qualitis.standardValueVersion; - -/** - * @author v_gaojiedeng@webank.com - */ -public class StandardTest { -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/standardValueVersion/StandardValueVersionDaoTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/standardValueVersion/StandardValueVersionDaoTest.java deleted file mode 100644 index d0844e05..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/standardValueVersion/StandardValueVersionDaoTest.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.webank.wedatasphere.qualitis.standardValueVersion; - -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import com.webank.wedatasphere.qualitis.BaseTest; -import com.webank.wedatasphere.qualitis.exception.PermissionDeniedRequestException; -import com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException; -import com.webank.wedatasphere.qualitis.rule.dao.StandardValueDao; -import com.webank.wedatasphere.qualitis.rule.dao.StandardValueVersionDao; -import com.webank.wedatasphere.qualitis.rule.entity.StandardValue; -import com.webank.wedatasphere.qualitis.rule.entity.StandardValueVersion; -import com.webank.wedatasphere.qualitis.rule.request.AddStandardValueRequest; -import com.webank.wedatasphere.qualitis.rule.service.StandardValueService; -import org.apache.commons.lang.time.FastDateFormat; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Date; - -import static org.junit.Assert.assertNotNull; - -/** - * @author v_gaojiedeng@webank.com - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class StandardValueVersionDaoTest extends BaseTest { - - @Autowired - StandardValueDao standardValueDao; - - @Autowired - StandardValueVersionDao standardValueVersionDao; - - @Autowired - StandardValueService standardValueService; - - @Test - @Transactional - public void test() throws UnExpectedRequestException, PermissionDeniedRequestException { - -// { -// "cn_name": "久久", -// "content": "啊啊啊啊啊啊", -// "dev_department_id": "210100", -// "dev_department_name": "零售信贷部/需求与系统管理室", -// "en_name": "jiujiu", -// "ops_department_id": "210100", -// "ops_department_name": "零售信贷部/需求与系统管理室", -// "source": "aaaa", -// } - - - AddStandardValueRequest addStandardValueRequest = new AddStandardValueRequest(); - addStandardValueRequest.setCnName("测试"); - addStandardValueRequest.setEnName("oye"); - addStandardValueRequest.setDevDepartmentId(210100L); - addStandardValueRequest.setDevDepartmentName("零售信贷部/需求与系统管理室"); - addStandardValueRequest.setOpsDepartmentId(210100L); - addStandardValueRequest.setOpsDepartmentName("零售信贷部/需求与系统管理室"); - addStandardValueRequest.setContent("啊啊啊啊啊啊"); - - addStandardValueRequest.setSourceValue(1); - addStandardValueRequest.setSource("jwjw"); - addStandardValueRequest.setVisibilityDepartmentList(Lists.newArrayList()); - - standardValueService.addStandardValue(addStandardValueRequest); - -// StandardValueVersion standardValueVersion = saveStandardValueVersion(); -// StandardValueVersion execution = standardValueVersionDao.findById(standardValueVersion.getId()); -// -// //分页查询有结果 -// List list = standardValueVersionDao.findAllStandardValue("", "test", "", "", "", null, 0, 5); -// assertTrue(list.size() > 0); -// -// //多版本标准值 -// List collect = standardValueVersionDao.findByStandardValueVersion(standardValueVersion.getStandardValue().getId()); -// assertTrue(collect.size() > 0); -// -// //删除后,是否还能找到对象 -// standardValueDao.deleteStandardValue(execution.getStandardValue()); -// standardValueVersionDao.deleteStandardValueVersion(execution); -// StandardValueVersion deleteEntity = standardValueVersionDao.findById(standardValueVersion.getId()); -// assertNull(deleteEntity); - } - - private StandardValueVersion saveStandardValueVersion() { - //保存是否成功 - StandardValue standardValue = new StandardValue(); - StandardValue newStandardValue = standardValueDao.saveStandardValue(standardValue); - - StandardValueVersion entity = new StandardValueVersion(); - entity.setCnName("测试"); - entity.setEnName("test"); - entity.setVersion(1L); - entity.setStandardValueLabelVersion(Sets.newHashSet()); - entity.setStandardValueActionVersion(Sets.newHashSet()); - entity.setStandardValue(newStandardValue); - entity.setContent("test"); - entity.setSource("test"); - entity.setApproveSystem("test"); - entity.setApproveNumber("test"); - entity.setStandardValueType(1); - entity.setDevDepartmentName("基础科技产品部/大数据平台室"); - entity.setOpsDepartmentName("零售互联网产品部/开发室"); - entity.setDevDepartmentId(410140L); - entity.setOpsDepartmentId(230300L); - entity.setCreateUser("test"); - entity.setCreateTime(FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss").format(new Date())); - entity.setAvailable(true); - - StandardValueVersion standardValueVersion = standardValueVersionDao.saveStandardValueVersion(entity); - assertNotNull(standardValueVersion); - - return standardValueVersion; - } - - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/template/RuleTemplateTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/template/RuleTemplateTest.java deleted file mode 100644 index 435257a0..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/template/RuleTemplateTest.java +++ /dev/null @@ -1,182 +0,0 @@ -package com.webank.wedatasphere.qualitis.template; - -import com.webank.wedatasphere.qualitis.parser.LocaleParser; -import com.webank.wedatasphere.qualitis.project.dao.ProjectDao; -import com.webank.wedatasphere.qualitis.rule.dao.DataVisibilityDao; -import com.webank.wedatasphere.qualitis.rule.dao.RuleDao; -import com.webank.wedatasphere.qualitis.rule.dao.RuleTemplateDao; -import com.webank.wedatasphere.qualitis.rule.dao.TemplateDataSourceTypeDao; -import com.webank.wedatasphere.qualitis.rule.dao.TemplateOutputMetaDao; -import com.webank.wedatasphere.qualitis.rule.dao.TemplateUserDao; -import com.webank.wedatasphere.qualitis.rule.service.TemplateMidTableInputMetaService; -import com.webank.wedatasphere.qualitis.rule.service.TemplateStatisticsInputMetaService; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author v_gaojiedeng@webank.com - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class RuleTemplateTest { - - @Autowired - RuleTemplateDao ruleTemplateDao; - - @Autowired - TemplateDataSourceTypeDao templateDataSourceTypeDao; - - @Autowired - TemplateOutputMetaDao templateOutputMetaDao; - - @Autowired - TemplateStatisticsInputMetaService templateStatisticsInputMetaService; - - @Autowired - private TemplateMidTableInputMetaService templateMidTableInputMetaService; - - @Autowired - DataVisibilityDao dataVisibilityDao; - - @Autowired - TemplateUserDao templateUserDao; - - @Autowired - RuleDao ruleDao; - - @Autowired - ProjectDao projectDao; - - @Autowired - private LocaleParser localeParser; - - @Test - public void test() { -// UnExpectedRequestException unExpectedRequestException = new UnExpectedRequestException("Rule name {&ALREADY_EXIST}", 400); -// -// String message = localeParser.replacePlaceHolderByLocale(unExpectedRequestException.getMessage(), "en_US"); -// -// Response build = Response.ok(StringUtils.isNotEmpty(message) ? unExpectedRequestException.getResponse(message) : unExpectedRequestException.getResponse()).status(unExpectedRequestException.getStatus()).build(); - - //System.out.println(build); -// Rule ces_sync_metadate = ruleDao.findByProjectAndRuleName(project, "ces_sync_metadate"); -// -// ruleDao.saveRule(rule); - - //保存是否成功 -// Template newTemplate = new Template(); -// -// newTemplate.setName("testTemplate"); -// newTemplate.setClusterNum(-1); -// newTemplate.setDbNum(-1); -// newTemplate.setTableNum(-1); -// newTemplate.setFieldNum(-1); -// newTemplate.setActionType(1); -// newTemplate.setMidTableAction("select * from test"); -// newTemplate.setShowSql("select count(*) from test"); -// newTemplate.setTemplateType(1); -// newTemplate.setImportExportName(UuidGenerator.generate()); -// newTemplate.setDevDepartmentName("基础科技产品部/大数据平台室"); -// newTemplate.setOpsDepartmentName("基础科技产品部/大数据平台室"); -// newTemplate.setDevDepartmentId(410140L); -// newTemplate.setOpsDepartmentId(410140L); -// newTemplate.setCreateUser(new User()); -// newTemplate.setCreateTime(FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss").format(new Date())); -// newTemplate.setEnName("test"); -// newTemplate.setDescription("test"); -// newTemplate.setVerificationLevel(1); -// newTemplate.setVerificationType(1); -// newTemplate.setSaveMidTable(false); -// newTemplate.setFilterFields(false); -// newTemplate.setWhetherUsingFunctions(false); -// newTemplate.setVerificationCnName("test"); -// newTemplate.setVerificationEnName("test"); -// newTemplate.setNamingMethod(1); -// newTemplate.setWhetherSolidification(false); -// newTemplate.setCheckTemplate(null); -// newTemplate.setMajorType("general_knowledge,Anti"); -// newTemplate.setTemplateNumber("20230323_001"); -// newTemplate.setCustomZhCode("測試"); -// -// Template template = ruleTemplateDao.saveTemplate(newTemplate); -// //校验对象是否存在 -// assertTrue(template.getId() != 0); -// -// TemplateDataSourceType templateDataSourceType = new TemplateDataSourceType(); -// templateDataSourceType.setTemplate(template); -// templateDataSourceType.setDataSourceTypeId(1); -// TemplateDataSourceType dataSourceType = templateDataSourceTypeDao.save(templateDataSourceType); -// //校验对象是否存在 -// assertTrue(dataSourceType.getId() != 0); -// -// TemplateOutputMeta templateOutputMeta = new TemplateOutputMeta(); -// templateOutputMeta.setFieldName("count"); -// templateOutputMeta.setOutputName("不满足test的数量"); -// templateOutputMeta.setOutputEnName(null); -// templateOutputMeta.setFieldType(1); -// templateOutputMeta.setTemplate(template); -// TemplateOutputMeta outputMeta = templateOutputMetaDao.saveTemplateOutputMeta(templateOutputMeta); -// //校验对象是否存在 -// assertTrue(outputMeta.getId() != 0); -// -// TemplateMidTableInputMeta templateMidTableInputMeta = new TemplateMidTableInputMeta(); -// templateMidTableInputMeta.setName("数据库"); -// templateMidTableInputMeta.setCnName("数据库"); -// templateMidTableInputMeta.setEnName("database"); -// templateMidTableInputMeta.setCnDescription("数据库元信息"); -// templateMidTableInputMeta.setEnDescription("Database meta info"); -// templateMidTableInputMeta.setFieldMultipleChoice(false); -// templateMidTableInputMeta.setWhetherStandardValue(false); -// templateMidTableInputMeta.setWhetherNewValue(false); -// templateMidTableInputMeta.setFieldType(null); -// templateMidTableInputMeta.setInputType(5); -// templateMidTableInputMeta.setPlaceholder("database"); -// templateMidTableInputMeta.setPlaceholderDescription(null); -// templateMidTableInputMeta.setRegexpType(null); -// templateMidTableInputMeta.setReplaceByRequest(null); -// templateMidTableInputMeta.setTemplate(template); -// -// List list = Lists.newArrayList(); -// list.add(templateMidTableInputMeta); -// Set templateMidTableInputMetas = templateMidTableInputMetaService.saveAll(list); -// assertTrue(templateMidTableInputMetas.size() > 0); -// -// TemplateStatisticsInputMeta templateStatisticsInputMeta = new TemplateStatisticsInputMeta(); -// templateStatisticsInputMeta.setName("測試"); -// templateStatisticsInputMeta.setFuncName("count"); -// templateStatisticsInputMeta.setResultType(QualitisConstants.DATA_TYPE_LONG); -// templateStatisticsInputMeta.setValue("*"); -// templateStatisticsInputMeta.setValueType(FieldTypeEnum.NUMBER.getCode()); -// templateStatisticsInputMeta.setTemplate(template); -// -// List collect = Lists.newArrayList(); -// collect.add(templateStatisticsInputMeta); -// Set templateStatisticsInputMetas = templateStatisticsInputMetaService.saveAll(collect); -// assertTrue(templateStatisticsInputMetas.size() > 0); -// -// DataVisibility dataVisibility = new DataVisibility(); -// dataVisibility.setTableDataId(1L); -// dataVisibility.setTableDataType(TableDataTypeEnum.RULE_TEMPLATE.getCode()); -// dataVisibility.setDepartmentSubId(410140L); -// dataVisibility.setDepartmentSubName("基础科技产品部/大数据平台室"); -// -// List dataVisibilityList = Lists.newArrayList(); -// dataVisibilityDao.saveAll(dataVisibilityList); -// -// // -// ruleTemplateDao.deleteTemplate(template); -// Template currentTemplate = ruleTemplateDao.findById(template.getId()); -// assertNull(currentTemplate); -// -// templateDataSourceTypeDao.delete(dataSourceType); -// -// dataVisibilityDao.delete(template.getId(), TableDataTypeEnum.RULE_TEMPLATE.getCode()); -// List dataVisibilityLists = dataVisibilityDao.findByTableDataIdAndTableDataType(template.getId(), TableDataTypeEnum.RULE_TEMPLATE.getCode()); -// assertTrue(dataVisibilityLists.size() == 0); - } - - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/PermissionDaoTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/PermissionDaoTest.java deleted file mode 100644 index 212646ad..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/PermissionDaoTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2019 WeBank - * - * Licensed 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 com.webank.wedatasphere.qualitis.user; - -import com.webank.wedatasphere.qualitis.dao.PermissionDao; -import com.webank.wedatasphere.qualitis.entity.Permission; -import com.webank.wedatasphere.qualitis.dao.PermissionDao; -import com.webank.wedatasphere.qualitis.entity.Permission; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -/** - * @author v_wblwyan - * @date 2018-11-20 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class PermissionDaoTest { - - @Autowired - PermissionDao dao; - - @Test - @Transactional - public void test() { - //保存是否成功 - Permission entity = new Permission(); - entity.setUrl("/junit/**"); - entity.setMethod("GET"); - Permission saveEntity = dao.savePermission(entity); - assertTrue(saveEntity.getId() != 0); - - //总数量大于0 - long size = dao.countAll(); - assertTrue(size > 0); - - //分页查询有结果 - List datas = dao.findAllPermission(0, 5); - assertTrue(datas.size() > 0); - - //保存到数据库的对象是否和保存的值一致 - Permission findByIdEntity = dao.findById(saveEntity.getId()); - assertNotNull(findByIdEntity); - assertEquals(findByIdEntity.getUrl(), saveEntity.getUrl()); - - //根据username查询的数据库对象是否和保存的值一致 - Permission findByFieldsEntity = dao.findByMethodAndUrl(saveEntity.getMethod(), saveEntity.getUrl()); - assertNotNull(findByFieldsEntity); - assertEquals(findByFieldsEntity.getMethod(), saveEntity.getMethod()); - - //删除后,是否还能找到对象 - dao.deletePermission(saveEntity); - Permission deleteEntity = dao.findById(saveEntity.getId()); - assertNull(deleteEntity); - } - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/RoleDaoTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/RoleDaoTest.java deleted file mode 100644 index 16fc8136..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/RoleDaoTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2019 WeBank - * - * Licensed 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 com.webank.wedatasphere.qualitis.user; - -import com.webank.wedatasphere.qualitis.dao.RoleDao; -import com.webank.wedatasphere.qualitis.entity.Role; -import com.webank.wedatasphere.qualitis.dao.RoleDao; -import com.webank.wedatasphere.qualitis.entity.Role; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -/** - * @author v_wblwyan - * @date 2018-11-20 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class RoleDaoTest { - - @Autowired - RoleDao dao; - - @Test - @Transactional - public void test() { - //保存是否成功 - Role entity = new Role(); - entity.setName("junitRole"); - Role saveEntity = dao.saveRole(entity); - assertTrue(saveEntity.getId() != 0); - - //总数量大于0 - long size = dao.countAll(); - assertTrue(size > 0); - - //分页查询有结果 - List datas = dao.findAllRole(0, 5); - assertTrue(datas.size() > 0); - - //保存到数据库的对象是否和保存的值一致 - Role findEntity = dao.findById(saveEntity.getId()); - assertNotNull(findEntity); - assertEquals(findEntity.getName(), saveEntity.getName()); - - //根据username查询的数据库对象是否和保存的值一致 - Role findByRoleNameUser = dao.findByRoleName(saveEntity.getName()); - assertNotNull(findByRoleNameUser); - assertEquals(findByRoleNameUser.getName(), saveEntity.getName()); - - //删除后,是否还能找到对象 - dao.deleteRole(saveEntity); - Role findDelEntity = dao.findById(saveEntity.getId()); - assertNull(findDelEntity); - } - - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/RolePermissionDaoTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/RolePermissionDaoTest.java deleted file mode 100644 index fa1cffa9..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/RolePermissionDaoTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2019 WeBank - * - * Licensed 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 com.webank.wedatasphere.qualitis.user; - -import com.webank.wedatasphere.qualitis.dao.PermissionDao; -import com.webank.wedatasphere.qualitis.dao.RoleDao; -import com.webank.wedatasphere.qualitis.dao.RolePermissionDao; -import com.webank.wedatasphere.qualitis.entity.Permission; -import com.webank.wedatasphere.qualitis.entity.Role; -import com.webank.wedatasphere.qualitis.entity.RolePermission; -import com.webank.wedatasphere.qualitis.util.UuidGenerator; -import com.webank.wedatasphere.qualitis.dao.PermissionDao; -import com.webank.wedatasphere.qualitis.dao.RoleDao; -import com.webank.wedatasphere.qualitis.dao.RolePermissionDao; -import com.webank.wedatasphere.qualitis.entity.Permission; -import com.webank.wedatasphere.qualitis.entity.Role; -import com.webank.wedatasphere.qualitis.entity.RolePermission; -import com.webank.wedatasphere.qualitis.util.UuidGenerator; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -/** - * @author v_wblwyan - * @date 2018-11-20 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class RolePermissionDaoTest { - - @Autowired - RolePermissionDao dao; - @Autowired - PermissionDao permissionDao; - @Autowired - RoleDao roleDao; - - @Test - @Transactional - public void test() { - Permission savePermission = savePermission(); - Role saveRole = saveRole(); - //保存是否成功 - RolePermission entity = new RolePermission(); - entity.setId(UuidGenerator.generate()); - entity.setPermission(savePermission); - entity.setRole(saveRole); - RolePermission saveEntity = dao.saveRolePermission(entity); - assertNotNull(saveEntity.getId()); - - //总数量大于0 - long size = dao.countAll(); - assertTrue(size > 0); - - //分页查询有结果 - List datas = dao.findAllRolePermission(0, 5); - assertTrue(datas.size() > 0); - - //保存到数据库的对象是否和保存的值一致 - RolePermission findByIdEntity = dao.findByUuid(saveEntity.getId()); - assertNotNull(findByIdEntity); - assertEquals(findByIdEntity.getPermission().getUrl(), saveEntity.getPermission().getUrl()); - assertEquals(findByIdEntity.getRole().getName(), saveEntity.getRole().getName()); - - RolePermission findByRoleAndPermissionEntity = dao.findByRoleAndPermission(saveRole, savePermission); - assertNotNull(findByRoleAndPermissionEntity); - assertEquals(findByRoleAndPermissionEntity.getPermission().getUrl(), saveEntity.getPermission().getUrl()); - assertEquals(findByRoleAndPermissionEntity.getRole().getName(), saveEntity.getRole().getName()); - - //根据username查询的数据库对象是否和保存的值一致 - List findByRoleEntity = dao.findByRole(saveRole); - assertTrue(findByRoleEntity.size() > 0); - assertEquals(findByRoleEntity.get(0).getPermission().getUrl(), saveEntity.getPermission().getUrl()); - - //根据username查询的数据库对象是否和保存的值一致 - List findByPermissionEntity = dao.findByPermission(savePermission); - assertTrue(findByPermissionEntity.size() > 0); - assertEquals(findByPermissionEntity.get(0).getRole().getName(), saveEntity.getRole().getName()); - - //删除后,是否还能找到对象 - dao.deleteRolePermission(saveEntity); - RolePermission deleteEntity = dao.findByUuid(saveEntity.getId()); - assertNull(deleteEntity); - } - - private Role saveRole() { - //保存是否成功 - Role entity = new Role(); - entity.setName("junitRole"); - Role saveEntity = roleDao.saveRole(entity); - assertTrue(saveEntity.getId() != 0); - return saveEntity; - } - - private Permission savePermission() { - //保存是否成功 - Permission entity = new Permission(); - entity.setUrl("/junit/**"); - entity.setMethod("GET"); - Permission saveEntity = permissionDao.savePermission(entity); - assertTrue(saveEntity.getId() != 0); - return saveEntity; - } - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/UserDaoTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/UserDaoTest.java deleted file mode 100644 index 95d0799a..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/UserDaoTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2019 WeBank - * - * Licensed 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 com.webank.wedatasphere.qualitis.user; - - -import com.webank.wedatasphere.qualitis.dao.UserDao; -import com.webank.wedatasphere.qualitis.entity.User; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.domain.Page; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -/** - * @author v_wblwyan - * @date 2018-11-20 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class UserDaoTest { - - @Autowired - UserDao userDao; - - @Test - @Transactional - public void testUser() { - //保存是否成功 - User user = new User(); - user.setChineseName("xxx"); - user.setUsername("xxx"); - user.setPassword("xxx"); - User saveUser = userDao.saveUser(user); - assertTrue(saveUser.getId() != 0); - - - //分页查询有结果 - Page users = userDao.findAllUser("allenzhou",null,null, 0, 5); - assertTrue(users.getTotalElements() > 0); - - //保存到数据库的对象是否和保存的值一致 - User findUser = userDao.findById(saveUser.getId()); - assertNotNull(findUser); - assertEquals(findUser.getChineseName(), saveUser.getChineseName()); - assertEquals(findUser.getDepartment(), saveUser.getDepartment()); - assertEquals(findUser.getUsername(), saveUser.getUsername()); - - //根据username查询的数据库对象是否和保存的值一致 - User findByUsernameUser = userDao.findByUsername(saveUser.getUsername()); - assertNotNull(findByUsernameUser); - assertEquals(findByUsernameUser.getUsername(), saveUser.getUsername()); - - //删除后,是否还能找到对象 - userDao.deleteUser(saveUser); - User findDelUser = userDao.findById(saveUser.getId()); - assertNull(findDelUser); - } - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/UserRoleDaoTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/UserRoleDaoTest.java deleted file mode 100644 index c000a0e8..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/UserRoleDaoTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2019 WeBank - * - * Licensed 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 com.webank.wedatasphere.qualitis.user; - - -import com.webank.wedatasphere.qualitis.dao.RoleDao; -import com.webank.wedatasphere.qualitis.dao.UserDao; -import com.webank.wedatasphere.qualitis.dao.UserRoleDao; -import com.webank.wedatasphere.qualitis.entity.Role; -import com.webank.wedatasphere.qualitis.entity.User; -import com.webank.wedatasphere.qualitis.entity.UserRole; -import com.webank.wedatasphere.qualitis.util.UuidGenerator; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -/** - * @author v_wblwyan - * @date 2018-11-20 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class UserRoleDaoTest { - - @Autowired - UserRoleDao dao; - @Autowired - UserDao userDao; - @Autowired - RoleDao roleDao; - - @Test - @Transactional - public void test() { - User saveUser = saveUser(); - Role saveRole = saveRole(); - //保存是否成功 - UserRole entity = new UserRole(); - entity.setId(UuidGenerator.generate()); - entity.setUser(saveUser); - entity.setRole(saveRole); - UserRole saveEntity = dao.saveUserRole(entity); - assertNotNull(saveEntity.getId()); - - //总数量大于0 - long size = dao.countAllUserRole("allenzhou"); - assertTrue(size > 0); - - //分页查询有结果 - List datas = dao.findAllUserRole("allenzhou",0, 5); - assertTrue(datas.size() > 0); - - //保存到数据库的对象是否和保存的值一致 - UserRole findByIdEntity = dao.findByUuid(saveEntity.getId()); - assertNotNull(findByIdEntity); - assertEquals(findByIdEntity.getUser().getUsername(), saveEntity.getUser().getUsername()); - assertEquals(findByIdEntity.getRole().getName(), saveEntity.getRole().getName()); - - UserRole findByUserAndRoleEntity = dao.findByUserAndRole(saveUser, saveRole); - assertNotNull(findByUserAndRoleEntity); - assertEquals(findByUserAndRoleEntity.getUser().getUsername(), saveEntity.getUser().getUsername()); - assertEquals(findByUserAndRoleEntity.getRole().getName(), saveEntity.getRole().getName()); - - //根据username查询的数据库对象是否和保存的值一致 - List findByRoleEntity = dao.findByRole(saveRole); - assertTrue(findByRoleEntity.size() > 0); - assertEquals(findByRoleEntity.get(0).getUser().getUsername(), saveEntity.getUser().getUsername()); - - //根据username查询的数据库对象是否和保存的值一致 - List findByUserEntity = dao.findByUser(saveUser); - assertTrue(findByUserEntity.size() > 0); - assertEquals(findByUserEntity.get(0).getRole().getName(), saveEntity.getRole().getName()); - - //删除后,是否还能找到对象 - dao.deleteUserRole(saveEntity); - UserRole deleteEntity = dao.findByUuid(saveEntity.getId()); - assertNull(deleteEntity); - } - - private Role saveRole() { - //保存是否成功 - Role entity = new Role(); - entity.setName("junitRole"); - Role saveEntity = roleDao.saveRole(entity); - assertTrue(saveEntity.getId() != 0); - return saveEntity; - } - - private User saveUser() { - //保存是否成功 - User user = new User(); - user.setChineseName("xxx"); - user.setUsername("xxx"); - user.setPassword("xxx"); - User saveUser = userDao.saveUser(user); - assertTrue(saveUser.getId() != 0); - return saveUser; - } - -} diff --git a/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/UserSpecPermissionDaoTest.java b/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/UserSpecPermissionDaoTest.java deleted file mode 100644 index 2b97e8ee..00000000 --- a/web/app/src/test/java/com/webank/wedatasphere/qualitis/user/UserSpecPermissionDaoTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2019 WeBank - * - * Licensed 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 com.webank.wedatasphere.qualitis.user; - - -import com.webank.wedatasphere.qualitis.dao.PermissionDao; -import com.webank.wedatasphere.qualitis.dao.UserDao; -import com.webank.wedatasphere.qualitis.dao.UserSpecPermissionDao; -import com.webank.wedatasphere.qualitis.entity.Permission; -import com.webank.wedatasphere.qualitis.entity.User; -import com.webank.wedatasphere.qualitis.entity.UserSpecPermission; -import com.webank.wedatasphere.qualitis.util.UuidGenerator; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -import static org.junit.Assert.*; - -/** - * @author v_wblwyan - * @date 2018-11-20 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class UserSpecPermissionDaoTest { - - @Autowired - UserSpecPermissionDao dao; - @Autowired - PermissionDao permissionDao; - @Autowired - UserDao userDao; - - @Test - @Transactional - public void test() { - Permission savePermission = savePermission(); - User saveUser = saveUser(); - //保存是否成功 - UserSpecPermission entity = new UserSpecPermission(); - entity.setId(UuidGenerator.generate()); - entity.setPermission(savePermission); - entity.setUser(saveUser); - UserSpecPermission saveEntity = dao.saveUserSpecPermission(entity); - assertNotNull(saveEntity.getId()); - - //总数量大于0 - long size = dao.countAll(); - assertTrue(size > 0); - - //分页查询有结果 - List datas = dao.findAllUserSpecPermission(0, 5); - assertTrue(datas.size() > 0); - - //保存到数据库的对象是否和保存的值一致 - UserSpecPermission findByIdEntity = dao.findByUuid(saveEntity.getId()); - assertNotNull(findByIdEntity); - assertEquals(findByIdEntity.getPermission().getUrl(), saveEntity.getPermission().getUrl()); - assertEquals(findByIdEntity.getUser().getUsername(), saveEntity.getUser().getUsername()); - - UserSpecPermission findByRoleAndPermissionEntity = dao.findByUserAndPermission(saveUser, savePermission); - assertNotNull(findByRoleAndPermissionEntity); - assertEquals(findByRoleAndPermissionEntity.getPermission().getUrl(), saveEntity.getPermission().getUrl()); - assertEquals(findByRoleAndPermissionEntity.getUser().getUsername(), saveEntity.getUser().getUsername()); - - //根据username查询的数据库对象是否和保存的值一致 - List findByRoleEntity = dao.findByUser(saveUser); - assertTrue(findByRoleEntity.size() > 0); - assertEquals(findByRoleEntity.get(0).getPermission().getUrl(), saveEntity.getPermission().getUrl()); - - //根据username查询的数据库对象是否和保存的值一致 - List findByPermissionEntity = dao.findByPermission(savePermission); - assertTrue(findByPermissionEntity.size() > 0); - assertEquals(findByPermissionEntity.get(0).getUser().getUsername(), saveEntity.getUser().getUsername()); - - //删除后,是否还能找到对象 - dao.deleteUserSpecPermission(saveEntity); - UserSpecPermission deleteEntity = dao.findByUuid(saveEntity.getId()); - assertNull(deleteEntity); - } - - - private User saveUser() { - //保存是否成功 - User user = new User(); - user.setChineseName("xxx"); - user.setUsername("xxx"); - user.setPassword("xxx"); - User saveUser = userDao.saveUser(user); - assertTrue(saveUser.getId() != 0); - return saveUser; - } - - private Permission savePermission() { - //保存是否成功 - Permission entity = new Permission(); - entity.setUrl("/junit/**"); - entity.setMethod("GET"); - Permission saveEntity = permissionDao.savePermission(entity); - assertTrue(saveEntity.getId() != 0); - return saveEntity; - } - - -} diff --git a/web/project/src/main/java/com/webank/wedatasphere/qualitis/rule/service/impl/LinkisDataSourceServiceImpl.java b/web/project/src/main/java/com/webank/wedatasphere/qualitis/rule/service/impl/LinkisDataSourceServiceImpl.java index 9581e282..5bec2fd0 100644 --- a/web/project/src/main/java/com/webank/wedatasphere/qualitis/rule/service/impl/LinkisDataSourceServiceImpl.java +++ b/web/project/src/main/java/com/webank/wedatasphere/qualitis/rule/service/impl/LinkisDataSourceServiceImpl.java @@ -171,7 +171,7 @@ public LinkisDataSource getByLinkisDataSourceName(String linkisDataSourceName) { * 1. If the env name the user enters is: env_name * 2. then format it to: * manual input: 212_env_name - * automatic input: 212_env_name-127.0.0.1:3306(epccmaindb_G-DCN_D21_set_4) + * automatic input: 212_env_name-0.0.0.0:00(epccmaindb_G-DCN_D21_set_4) * * @param linkisDataSourceId * @param originalEnvName @@ -200,7 +200,7 @@ public String convertOriginalEnvNameToLinkis(Long linkisDataSourceId, String ori /** * 1. If the env name store in database is: * linkisEnvName with input manually: 212_env_name - * linkisEnvName with input automatically: 212_env_name-127.0.0.1-3306(epccmaindb_G-DCN_D21_set_4) + * linkisEnvName with input automatically: 212_env_name-0.0.0.0-00(epccmaindb_G-DCN_D21_set_4) * 2. then recovery it to: env_name * * @param linkisDataSourceId @@ -210,7 +210,7 @@ public String convertOriginalEnvNameToLinkis(Long linkisDataSourceId, String ori */ @Override public String convertLinkisEnvNameToOriginal(Long linkisDataSourceId, String linkisEnvName, Integer inputType) { -// 1. 212_env_name-127.0.0.1-3306(epccmaindb_G-DCN_D21_set_4) +// 1. 212_env_name-0.0.0.0-00(epccmaindb_G-DCN_D21_set_4) String tmpLinkisEnvName = linkisEnvName; // removing the prefix of the env_name: 212_ int prefixIndex = 0; @@ -218,7 +218,7 @@ public String convertLinkisEnvNameToOriginal(Long linkisDataSourceId, String lin if (-1 != tmpLinkisEnvName.indexOf(prefixStr)) { prefixIndex = prefixStr.length(); } -// 2. env_name-127.0.0.1-3306(epccmaindb_G-DCN_D21_set_4) +// 2. env_name-0.0.0.0-00(epccmaindb_G-DCN_D21_set_4) tmpLinkisEnvName = StringUtils.substring(tmpLinkisEnvName, prefixIndex); if (isAutoInput(inputType)) {