From 145761774ac1fd93a3d89cd9d273bb248caf7317 Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Tue, 4 Oct 2022 20:20:18 +0800 Subject: [PATCH] [hertzbeat] add more unit test case and example (#324) [manger] add mockito unit test [manger] add mockito unit test [hertzbeat] test framework demo [hertzbeat] test framework demo [hertzbeat] test framework demo --- .../usthe/alert/AlerterWorkerPoolTest.java | 21 ++++ .../controller/AlertDefineControllerTest.java | 40 +++++++ .../AlertDefinesControllerTest.java | 24 +++++ .../controller/AlertsControllerTest.java | 40 +++++++ .../alert/service/AlertDefineServiceTest.java | 61 +++++++++++ .../usthe/alert/service/AlertServiceTest.java | 44 ++++++++ .../alert/util/AlertTemplateUtilTest.java | 21 ++++ .../dispatch/timer/WheelTimerTask.java | 2 +- .../collector/util/SpringContextHolder.java | 65 ----------- .../main/resources/META-INF/spring.factories | 1 - .../collect/common/cache/CommonCacheTest.java | 41 +++++++ .../common/http/CommonHttpClientTest.java | 30 ++++++ .../common/ssh/CommonSshClientTest.java | 26 +++++ .../database/JdbcCommonCollectTest.java | 21 ++++ .../collect/database/JdbcSpiLoaderTest.java | 21 ++++ .../collect/http/HttpCollectImplTest.java | 30 ++++++ .../http/SslCertificateCollectImplTest.java | 25 +++++ .../collect/icmp/IcmpCollectImplTest.java | 25 +++++ .../collect/jmx/JmxCollectImplTest.java | 30 ++++++ .../redis/RedisSingleCollectImplTest.java | 25 +++++ .../collect/snmp/SnmpCollectImplTest.java | 30 ++++++ .../collect/ssh/SshCollectImplTest.java | 30 ++++++ .../collect/telnet/TelnetCollectImplTest.java | 4 +- .../dispatch/CommonDispatcherTest.java | 25 +++++ .../dispatch/MetricsCollectorQueueTest.java | 30 ++++++ .../collector/dispatch/WorkerPoolTest.java | 30 ++++++ .../internal/CollectJobServiceTest.java | 38 +++++++ .../usthe/collector/util/CollectUtilTest.java | 46 ++++++++ .../collector/util/JsonPathParserTest.java | 21 ++++ .../usthe/collector/util/KeyPairUtilTest.java | 21 ++++ .../common/queue/CommonDataQueueTest.java | 45 ++++++++ .../ResourceBundleUtf8ControlTest.java | 16 +++ .../support/SpringContextHolderTest.java | 33 ++++++ .../com/usthe/common/util/AesUtilTest.java | 50 +++++++++ .../com/usthe/common/util/Base64UtilTest.java | 16 +++ .../com/usthe/common/util/CommonUtilTest.java | 4 +- .../com/usthe/common/util/GsonUtilTest.java | 33 ++++++ .../util/IntervalExpressionUtilTest.java | 21 ++++ .../usthe/common/util/IpDomainUtilTest.java | 4 +- .../com/usthe/common/util/LruHashMapTest.java | 16 +++ .../usthe/common/util/ProtoJsonUtilTest.java | 25 +++++ .../common/util/ResourceBundleUtilTest.java | 21 ++++ .../common/util/SnowFlakeIdGeneratorTest.java | 4 +- .../com/usthe/manager/dao/MonitorDao.java | 2 +- .../src/main/resources/application-test.yml | 54 ++++++++++ manager/src/main/resources/application.yml | 20 ++-- .../AbstractSpringIntegrationTest.java | 13 +++ .../alerter/AlertNotifyHandlerTest.java | 25 +++++ .../alerter/DispatcherAlarmTest.java | 25 +++++ .../impl/DbAlertStoreHandlerImplTest.java | 21 ++++ ...ngTalkRobotAlertNotifyHandlerImplTest.java | 25 +++++ .../impl/EmailAlertNotifyHandlerImplTest.java | 25 +++++ .../FlyBookAlertNotifyHandlerImplTest.java | 25 +++++ ...WeWorkRobotAlertNotifyHandlerImplTest.java | 25 +++++ .../WebHookAlertNotifyHandlerImplTest.java | 25 +++++ .../controller/AccountControllerTest.java | 63 +++++++++++ .../manager/controller/AppControllerTest.java | 29 +++++ .../controller/I18nControllerTest.java | 21 ++++ .../controller/MonitorControllerTest.java | 45 ++++++++ .../controller/MonitorsControllerTest.java | 37 +++++++ .../NoticeConfigControllerTest.java | 53 +++++++++ .../controller/SummaryControllerTest.java | 20 ++++ .../manager/controller/TagControllerTest.java | 32 ++++++ .../com/usthe/manager/dao/MonitorDaoTest.java | 101 ++++++++++++++++++ .../usthe/manager/dao/NoticeRuleDaoTest.java | 21 ++++ .../com/usthe/manager/dao/ParamDaoTest.java | 29 +++++ .../usthe/manager/dao/ParamDefineDaoTest.java | 21 ++++ .../com/usthe/manager/dao/TagDaoTest.java | 21 ++++ .../usthe/manager/service/AppServiceTest.java | 37 +++++++ .../manager/service/MailServiceTest.java | 21 ++++ .../manager/service/MonitorServiceTest.java | 81 ++++++++++++++ .../service/NoticeConfigServiceTest.java | 65 +++++++++++ .../usthe/manager/service/TagServiceTest.java | 65 +++++++++++ .../support/GlobalExceptionHandlerTest.java | 57 ++++++++++ pom.xml | 6 +- script/application.yml | 24 ++--- script/docker-compose/conf/application.yml | 26 +++-- .../warehouse/WarehouseWorkerPoolTest.java | 20 ++++ .../controller/MetricsDataControllerTest.java | 28 +++++ .../store/MemoryDataStorageTest.java | 24 +++++ .../store/MetricsDataRedisCodecTest.java | 32 ++++++ .../warehouse/store/RedisDataStorageTest.java | 24 +++++ .../store/TdEngineDataStorageTest.java | 36 +++++++ 83 files changed, 2360 insertions(+), 120 deletions(-) create mode 100644 alerter/src/test/java/com/usthe/alert/AlerterWorkerPoolTest.java create mode 100644 alerter/src/test/java/com/usthe/alert/controller/AlertDefineControllerTest.java create mode 100644 alerter/src/test/java/com/usthe/alert/controller/AlertDefinesControllerTest.java create mode 100644 alerter/src/test/java/com/usthe/alert/controller/AlertsControllerTest.java create mode 100644 alerter/src/test/java/com/usthe/alert/service/AlertDefineServiceTest.java create mode 100644 alerter/src/test/java/com/usthe/alert/service/AlertServiceTest.java create mode 100644 alerter/src/test/java/com/usthe/alert/util/AlertTemplateUtilTest.java delete mode 100644 collector/src/main/java/com/usthe/collector/util/SpringContextHolder.java create mode 100644 collector/src/test/java/com/usthe/collector/collect/common/cache/CommonCacheTest.java create mode 100644 collector/src/test/java/com/usthe/collector/collect/common/http/CommonHttpClientTest.java create mode 100644 collector/src/test/java/com/usthe/collector/collect/common/ssh/CommonSshClientTest.java create mode 100644 collector/src/test/java/com/usthe/collector/collect/database/JdbcCommonCollectTest.java create mode 100644 collector/src/test/java/com/usthe/collector/collect/database/JdbcSpiLoaderTest.java create mode 100644 collector/src/test/java/com/usthe/collector/collect/http/HttpCollectImplTest.java create mode 100644 collector/src/test/java/com/usthe/collector/collect/http/SslCertificateCollectImplTest.java create mode 100644 collector/src/test/java/com/usthe/collector/collect/icmp/IcmpCollectImplTest.java create mode 100644 collector/src/test/java/com/usthe/collector/collect/jmx/JmxCollectImplTest.java create mode 100644 collector/src/test/java/com/usthe/collector/collect/redis/RedisSingleCollectImplTest.java create mode 100644 collector/src/test/java/com/usthe/collector/collect/snmp/SnmpCollectImplTest.java create mode 100644 collector/src/test/java/com/usthe/collector/collect/ssh/SshCollectImplTest.java create mode 100644 collector/src/test/java/com/usthe/collector/dispatch/CommonDispatcherTest.java create mode 100644 collector/src/test/java/com/usthe/collector/dispatch/MetricsCollectorQueueTest.java create mode 100644 collector/src/test/java/com/usthe/collector/dispatch/WorkerPoolTest.java create mode 100644 collector/src/test/java/com/usthe/collector/dispatch/entrance/internal/CollectJobServiceTest.java create mode 100644 collector/src/test/java/com/usthe/collector/util/CollectUtilTest.java create mode 100644 collector/src/test/java/com/usthe/collector/util/JsonPathParserTest.java create mode 100644 collector/src/test/java/com/usthe/collector/util/KeyPairUtilTest.java create mode 100644 common/src/test/java/com/usthe/common/queue/CommonDataQueueTest.java create mode 100644 common/src/test/java/com/usthe/common/support/ResourceBundleUtf8ControlTest.java create mode 100644 common/src/test/java/com/usthe/common/support/SpringContextHolderTest.java create mode 100644 common/src/test/java/com/usthe/common/util/AesUtilTest.java create mode 100644 common/src/test/java/com/usthe/common/util/Base64UtilTest.java create mode 100644 common/src/test/java/com/usthe/common/util/GsonUtilTest.java create mode 100644 common/src/test/java/com/usthe/common/util/IntervalExpressionUtilTest.java create mode 100644 common/src/test/java/com/usthe/common/util/LruHashMapTest.java create mode 100644 common/src/test/java/com/usthe/common/util/ProtoJsonUtilTest.java create mode 100644 common/src/test/java/com/usthe/common/util/ResourceBundleUtilTest.java create mode 100644 manager/src/main/resources/application-test.yml create mode 100644 manager/src/test/java/com/usthe/manager/AbstractSpringIntegrationTest.java create mode 100644 manager/src/test/java/com/usthe/manager/component/alerter/AlertNotifyHandlerTest.java create mode 100644 manager/src/test/java/com/usthe/manager/component/alerter/DispatcherAlarmTest.java create mode 100644 manager/src/test/java/com/usthe/manager/component/alerter/impl/DbAlertStoreHandlerImplTest.java create mode 100644 manager/src/test/java/com/usthe/manager/component/alerter/impl/DingTalkRobotAlertNotifyHandlerImplTest.java create mode 100644 manager/src/test/java/com/usthe/manager/component/alerter/impl/EmailAlertNotifyHandlerImplTest.java create mode 100644 manager/src/test/java/com/usthe/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImplTest.java create mode 100644 manager/src/test/java/com/usthe/manager/component/alerter/impl/WeWorkRobotAlertNotifyHandlerImplTest.java create mode 100644 manager/src/test/java/com/usthe/manager/component/alerter/impl/WebHookAlertNotifyHandlerImplTest.java create mode 100644 manager/src/test/java/com/usthe/manager/controller/AccountControllerTest.java create mode 100644 manager/src/test/java/com/usthe/manager/controller/AppControllerTest.java create mode 100644 manager/src/test/java/com/usthe/manager/controller/I18nControllerTest.java create mode 100644 manager/src/test/java/com/usthe/manager/controller/MonitorControllerTest.java create mode 100644 manager/src/test/java/com/usthe/manager/controller/MonitorsControllerTest.java create mode 100644 manager/src/test/java/com/usthe/manager/controller/NoticeConfigControllerTest.java create mode 100644 manager/src/test/java/com/usthe/manager/controller/SummaryControllerTest.java create mode 100644 manager/src/test/java/com/usthe/manager/controller/TagControllerTest.java create mode 100644 manager/src/test/java/com/usthe/manager/dao/MonitorDaoTest.java create mode 100644 manager/src/test/java/com/usthe/manager/dao/NoticeRuleDaoTest.java create mode 100644 manager/src/test/java/com/usthe/manager/dao/ParamDaoTest.java create mode 100644 manager/src/test/java/com/usthe/manager/dao/ParamDefineDaoTest.java create mode 100644 manager/src/test/java/com/usthe/manager/dao/TagDaoTest.java create mode 100644 manager/src/test/java/com/usthe/manager/service/AppServiceTest.java create mode 100644 manager/src/test/java/com/usthe/manager/service/MailServiceTest.java create mode 100644 manager/src/test/java/com/usthe/manager/service/MonitorServiceTest.java create mode 100644 manager/src/test/java/com/usthe/manager/service/NoticeConfigServiceTest.java create mode 100644 manager/src/test/java/com/usthe/manager/service/TagServiceTest.java create mode 100644 manager/src/test/java/com/usthe/manager/support/GlobalExceptionHandlerTest.java create mode 100644 warehouse/src/test/java/com/usthe/warehouse/WarehouseWorkerPoolTest.java create mode 100644 warehouse/src/test/java/com/usthe/warehouse/controller/MetricsDataControllerTest.java create mode 100644 warehouse/src/test/java/com/usthe/warehouse/store/MemoryDataStorageTest.java create mode 100644 warehouse/src/test/java/com/usthe/warehouse/store/MetricsDataRedisCodecTest.java create mode 100644 warehouse/src/test/java/com/usthe/warehouse/store/RedisDataStorageTest.java create mode 100644 warehouse/src/test/java/com/usthe/warehouse/store/TdEngineDataStorageTest.java diff --git a/alerter/src/test/java/com/usthe/alert/AlerterWorkerPoolTest.java b/alerter/src/test/java/com/usthe/alert/AlerterWorkerPoolTest.java new file mode 100644 index 00000000000..910de972fd1 --- /dev/null +++ b/alerter/src/test/java/com/usthe/alert/AlerterWorkerPoolTest.java @@ -0,0 +1,21 @@ +package com.usthe.alert; + +import com.usthe.alert.controller.AlertDefineController; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link AlerterWorkerPool} + */ +class AlerterWorkerPoolTest { + + @BeforeEach + void setUp() { + } + + @Test + void executeJob() { + } +} \ No newline at end of file diff --git a/alerter/src/test/java/com/usthe/alert/controller/AlertDefineControllerTest.java b/alerter/src/test/java/com/usthe/alert/controller/AlertDefineControllerTest.java new file mode 100644 index 00000000000..23a45481ade --- /dev/null +++ b/alerter/src/test/java/com/usthe/alert/controller/AlertDefineControllerTest.java @@ -0,0 +1,40 @@ +package com.usthe.alert.controller; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link AlertDefineController} + */ +class AlertDefineControllerTest { + + @BeforeEach + void setUp() { + } + + @Test + void addNewAlertDefine() { + } + + @Test + void modifyAlertDefine() { + } + + @Test + void getAlertDefine() { + } + + @Test + void deleteAlertDefine() { + } + + @Test + void applyAlertDefineMonitorsBind() { + } + + @Test + void getAlertDefineMonitorsBind() { + } +} \ No newline at end of file diff --git a/alerter/src/test/java/com/usthe/alert/controller/AlertDefinesControllerTest.java b/alerter/src/test/java/com/usthe/alert/controller/AlertDefinesControllerTest.java new file mode 100644 index 00000000000..d8939d5eb29 --- /dev/null +++ b/alerter/src/test/java/com/usthe/alert/controller/AlertDefinesControllerTest.java @@ -0,0 +1,24 @@ +package com.usthe.alert.controller; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link AlertDefinesController} + */ +class AlertDefinesControllerTest { + + @BeforeEach + void setUp() { + } + + @Test + void getAlertDefines() { + } + + @Test + void deleteAlertDefines() { + } +} \ No newline at end of file diff --git a/alerter/src/test/java/com/usthe/alert/controller/AlertsControllerTest.java b/alerter/src/test/java/com/usthe/alert/controller/AlertsControllerTest.java new file mode 100644 index 00000000000..e36aed1477d --- /dev/null +++ b/alerter/src/test/java/com/usthe/alert/controller/AlertsControllerTest.java @@ -0,0 +1,40 @@ +package com.usthe.alert.controller; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link AlertsController} + */ +class AlertsControllerTest { + + @BeforeEach + void setUp() { + } + + @Test + void getAlerts() { + } + + @Test + void deleteAlerts() { + } + + @Test + void clearAllAlerts() { + } + + @Test + void applyAlertDefinesStatus() { + } + + @Test + void getAlertsSummary() { + } + + @Test + void addNewAlertReport() { + } +} \ No newline at end of file diff --git a/alerter/src/test/java/com/usthe/alert/service/AlertDefineServiceTest.java b/alerter/src/test/java/com/usthe/alert/service/AlertDefineServiceTest.java new file mode 100644 index 00000000000..3c7d6716f3e --- /dev/null +++ b/alerter/src/test/java/com/usthe/alert/service/AlertDefineServiceTest.java @@ -0,0 +1,61 @@ +package com.usthe.alert.service; + +import com.usthe.alert.controller.AlertDefineController; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link AlertDefineService} + */ +class AlertDefineServiceTest { + + @BeforeEach + void setUp() { + } + + @Test + void validate() { + } + + @Test + void addAlertDefine() { + } + + @Test + void modifyAlertDefine() { + } + + @Test + void deleteAlertDefine() { + } + + @Test + void getAlertDefine() { + } + + @Test + void deleteAlertDefines() { + } + + @Test + void getMonitorBindAlertDefines() { + } + + @Test + void applyBindAlertDefineMonitors() { + } + + @Test + void testGetMonitorBindAlertDefines() { + } + + @Test + void getAlertDefines() { + } + + @Test + void getBindAlertDefineMonitors() { + } +} \ No newline at end of file diff --git a/alerter/src/test/java/com/usthe/alert/service/AlertServiceTest.java b/alerter/src/test/java/com/usthe/alert/service/AlertServiceTest.java new file mode 100644 index 00000000000..c5cce11196c --- /dev/null +++ b/alerter/src/test/java/com/usthe/alert/service/AlertServiceTest.java @@ -0,0 +1,44 @@ +package com.usthe.alert.service; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link AlertService} + */ +class AlertServiceTest { + + @BeforeEach + void setUp() { + } + + @Test + void addAlert() { + } + + @Test + void getAlerts() { + } + + @Test + void deleteAlerts() { + } + + @Test + void clearAlerts() { + } + + @Test + void editAlertStatus() { + } + + @Test + void getAlertsSummary() { + } + + @Test + void addNewAlertReport() { + } +} \ No newline at end of file diff --git a/alerter/src/test/java/com/usthe/alert/util/AlertTemplateUtilTest.java b/alerter/src/test/java/com/usthe/alert/util/AlertTemplateUtilTest.java new file mode 100644 index 00000000000..d7687da4ddf --- /dev/null +++ b/alerter/src/test/java/com/usthe/alert/util/AlertTemplateUtilTest.java @@ -0,0 +1,21 @@ +package com.usthe.alert.util; + +import com.usthe.alert.service.AlertService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link AlertTemplateUtil} + */ +class AlertTemplateUtilTest { + + @BeforeEach + void setUp() { + } + + @Test + void render() { + } +} \ No newline at end of file diff --git a/collector/src/main/java/com/usthe/collector/dispatch/timer/WheelTimerTask.java b/collector/src/main/java/com/usthe/collector/dispatch/timer/WheelTimerTask.java index a99c95334b8..df5c7175236 100644 --- a/collector/src/main/java/com/usthe/collector/dispatch/timer/WheelTimerTask.java +++ b/collector/src/main/java/com/usthe/collector/dispatch/timer/WheelTimerTask.java @@ -21,10 +21,10 @@ import com.google.gson.JsonElement; import com.usthe.collector.dispatch.MetricsTaskDispatch; import com.usthe.collector.util.CollectUtil; -import com.usthe.collector.util.SpringContextHolder; import com.usthe.common.entity.job.Configmap; import com.usthe.common.entity.job.Job; import com.usthe.common.entity.job.Metrics; +import com.usthe.common.support.SpringContextHolder; import com.usthe.common.util.AesUtil; import com.usthe.common.util.CommonConstants; import lombok.extern.slf4j.Slf4j; diff --git a/collector/src/main/java/com/usthe/collector/util/SpringContextHolder.java b/collector/src/main/java/com/usthe/collector/util/SpringContextHolder.java deleted file mode 100644 index 5e19c71a43e..00000000000 --- a/collector/src/main/java/com/usthe/collector/util/SpringContextHolder.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.usthe.collector.util; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - -/** - * Spring的ApplicationContext的持有者,可以用静态方法的方式获取spring容器中的bean - * @author tomsun28 - * @date 21:07 2018/4/18 - */ -@Component -public class SpringContextHolder implements ApplicationContextAware { - - private static ApplicationContext applicationContext; - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - set(applicationContext); - } - - private static void set(ApplicationContext applicationContext) { - SpringContextHolder.applicationContext = applicationContext; - } - - public static ApplicationContext getApplicationContext() { - assertApplicationContext(); - return applicationContext; - } - - @SuppressWarnings("unchecked") - public static T getBean(String beanName) { - assertApplicationContext(); - return (T) applicationContext.getBean(beanName); - } - - public static T getBean(Class tClass) { - assertApplicationContext(); - return (T) applicationContext.getBean(tClass); - } - - private static void assertApplicationContext() { - if (null == SpringContextHolder.applicationContext) { - throw new RuntimeException("applicationContext为空,请检查是否注入springContextHolder"); - } - } -} diff --git a/collector/src/main/resources/META-INF/spring.factories b/collector/src/main/resources/META-INF/spring.factories index 7d06a515dda..79bf5ec79e7 100644 --- a/collector/src/main/resources/META-INF/spring.factories +++ b/collector/src/main/resources/META-INF/spring.factories @@ -20,7 +20,6 @@ com.usthe.collector.dispatch.DispatchProperties,\ com.usthe.collector.dispatch.MetricsCollectorQueue,\ com.usthe.collector.dispatch.WorkerPool,\ com.usthe.collector.dispatch.entrance.internal.CollectJobService,\ -com.usthe.collector.util.SpringContextHolder,\ com.usthe.collector.collect.database.JdbcSpiLoader,\ com.usthe.collector.collect.http.promethus.PrometheusParseCreater diff --git a/collector/src/test/java/com/usthe/collector/collect/common/cache/CommonCacheTest.java b/collector/src/test/java/com/usthe/collector/collect/common/cache/CommonCacheTest.java new file mode 100644 index 00000000000..81b40d1392c --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/collect/common/cache/CommonCacheTest.java @@ -0,0 +1,41 @@ +package com.usthe.collector.collect.common.cache; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link CommonCache} + */ +class CommonCacheTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void addCache() { + } + + @Test + void testAddCache() { + } + + @Test + void getCache() { + } + + @Test + void removeCache() { + } + + @Test + void getInstance() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/collect/common/http/CommonHttpClientTest.java b/collector/src/test/java/com/usthe/collector/collect/common/http/CommonHttpClientTest.java new file mode 100644 index 00000000000..ba6cb6f3314 --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/collect/common/http/CommonHttpClientTest.java @@ -0,0 +1,30 @@ +package com.usthe.collector.collect.common.http; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link CommonHttpClient} + */ +class CommonHttpClientTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void getHttpClient() { + } + + @Test + void getConnectionManager() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/collect/common/ssh/CommonSshClientTest.java b/collector/src/test/java/com/usthe/collector/collect/common/ssh/CommonSshClientTest.java new file mode 100644 index 00000000000..7575ae3fc6e --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/collect/common/ssh/CommonSshClientTest.java @@ -0,0 +1,26 @@ +package com.usthe.collector.collect.common.ssh; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link CommonSshClient} + */ +class CommonSshClientTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void getSshClient() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/collect/database/JdbcCommonCollectTest.java b/collector/src/test/java/com/usthe/collector/collect/database/JdbcCommonCollectTest.java new file mode 100644 index 00000000000..4855972e4ad --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/collect/database/JdbcCommonCollectTest.java @@ -0,0 +1,21 @@ +package com.usthe.collector.collect.database; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link JdbcCommonCollect} + */ +class JdbcCommonCollectTest { + + @BeforeEach + void setUp() { + } + + @Test + void getInstance() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/collect/database/JdbcSpiLoaderTest.java b/collector/src/test/java/com/usthe/collector/collect/database/JdbcSpiLoaderTest.java new file mode 100644 index 00000000000..3e759b1f550 --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/collect/database/JdbcSpiLoaderTest.java @@ -0,0 +1,21 @@ +package com.usthe.collector.collect.database; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link JdbcSpiLoader} + */ +class JdbcSpiLoaderTest { + + @BeforeEach + void setUp() { + } + + @Test + void run() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/collect/http/HttpCollectImplTest.java b/collector/src/test/java/com/usthe/collector/collect/http/HttpCollectImplTest.java new file mode 100644 index 00000000000..d5bb753fa65 --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/collect/http/HttpCollectImplTest.java @@ -0,0 +1,30 @@ +package com.usthe.collector.collect.http; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link HttpCollectImpl} + */ +class HttpCollectImplTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void getInstance() { + } + + @Test + void collect() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/collect/http/SslCertificateCollectImplTest.java b/collector/src/test/java/com/usthe/collector/collect/http/SslCertificateCollectImplTest.java new file mode 100644 index 00000000000..a4acd3e95ec --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/collect/http/SslCertificateCollectImplTest.java @@ -0,0 +1,25 @@ +package com.usthe.collector.collect.http; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link SslCertificateCollectImpl} + */ +class SslCertificateCollectImplTest { + + @BeforeEach + void setUp() { + } + + @Test + void getInstance() { + } + + @Test + void collect() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/collect/icmp/IcmpCollectImplTest.java b/collector/src/test/java/com/usthe/collector/collect/icmp/IcmpCollectImplTest.java new file mode 100644 index 00000000000..7cd6ee97fef --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/collect/icmp/IcmpCollectImplTest.java @@ -0,0 +1,25 @@ +package com.usthe.collector.collect.icmp; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link IcmpCollectImpl} + */ +class IcmpCollectImplTest { + + @BeforeEach + void setUp() { + } + + @Test + void getInstance() { + } + + @Test + void collect() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/collect/jmx/JmxCollectImplTest.java b/collector/src/test/java/com/usthe/collector/collect/jmx/JmxCollectImplTest.java new file mode 100644 index 00000000000..458692ab531 --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/collect/jmx/JmxCollectImplTest.java @@ -0,0 +1,30 @@ +package com.usthe.collector.collect.jmx; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link JmxCollectImpl} + */ +class JmxCollectImplTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void getInstance() { + } + + @Test + void collect() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/collect/redis/RedisSingleCollectImplTest.java b/collector/src/test/java/com/usthe/collector/collect/redis/RedisSingleCollectImplTest.java new file mode 100644 index 00000000000..19f7bd743a3 --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/collect/redis/RedisSingleCollectImplTest.java @@ -0,0 +1,25 @@ +package com.usthe.collector.collect.redis; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link RedisSingleCollectImpl} + */ +class RedisSingleCollectImplTest { + + @BeforeEach + void setUp() { + } + + @Test + void getInstance() { + } + + @Test + void collect() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/collect/snmp/SnmpCollectImplTest.java b/collector/src/test/java/com/usthe/collector/collect/snmp/SnmpCollectImplTest.java new file mode 100644 index 00000000000..6cef5a57581 --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/collect/snmp/SnmpCollectImplTest.java @@ -0,0 +1,30 @@ +package com.usthe.collector.collect.snmp; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link SnmpCollectImpl} + */ +class SnmpCollectImplTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void getInstance() { + } + + @Test + void collect() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/collect/ssh/SshCollectImplTest.java b/collector/src/test/java/com/usthe/collector/collect/ssh/SshCollectImplTest.java new file mode 100644 index 00000000000..57f8894858c --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/collect/ssh/SshCollectImplTest.java @@ -0,0 +1,30 @@ +package com.usthe.collector.collect.ssh; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link SshCollectImpl} + */ +class SshCollectImplTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void getInstance() { + } + + @Test + void collect() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/collect/telnet/TelnetCollectImplTest.java b/collector/src/test/java/com/usthe/collector/collect/telnet/TelnetCollectImplTest.java index 10c88650fd0..be8a531ee87 100644 --- a/collector/src/test/java/com/usthe/collector/collect/telnet/TelnetCollectImplTest.java +++ b/collector/src/test/java/com/usthe/collector/collect/telnet/TelnetCollectImplTest.java @@ -17,6 +17,7 @@ package com.usthe.collector.collect.telnet; +import com.usthe.collector.collect.common.cache.CommonCache; import org.apache.commons.net.telnet.TelnetClient; import org.junit.jupiter.api.Test; @@ -26,8 +27,7 @@ import static org.junit.jupiter.api.Assertions.*; /** - * @author tom - * @date 2021/12/4 19:39 + * Test case for {@link TelnetCollectImpl} */ class TelnetCollectImplTest { diff --git a/collector/src/test/java/com/usthe/collector/dispatch/CommonDispatcherTest.java b/collector/src/test/java/com/usthe/collector/dispatch/CommonDispatcherTest.java new file mode 100644 index 00000000000..2d1165f45b4 --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/dispatch/CommonDispatcherTest.java @@ -0,0 +1,25 @@ +package com.usthe.collector.dispatch; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link CommonDispatcher} + */ +class CommonDispatcherTest { + + @BeforeEach + void setUp() { + } + + @Test + void dispatchMetricsTask() { + } + + @Test + void dispatchCollectData() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/dispatch/MetricsCollectorQueueTest.java b/collector/src/test/java/com/usthe/collector/dispatch/MetricsCollectorQueueTest.java new file mode 100644 index 00000000000..735ff911f3f --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/dispatch/MetricsCollectorQueueTest.java @@ -0,0 +1,30 @@ +package com.usthe.collector.dispatch; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link MetricsCollectorQueue} + */ +class MetricsCollectorQueueTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void addJob() { + } + + @Test + void getJob() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/dispatch/WorkerPoolTest.java b/collector/src/test/java/com/usthe/collector/dispatch/WorkerPoolTest.java new file mode 100644 index 00000000000..c06919ccebd --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/dispatch/WorkerPoolTest.java @@ -0,0 +1,30 @@ +package com.usthe.collector.dispatch; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link WorkerPool} + */ +class WorkerPoolTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void executeJob() { + } + + @Test + void destroy() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/dispatch/entrance/internal/CollectJobServiceTest.java b/collector/src/test/java/com/usthe/collector/dispatch/entrance/internal/CollectJobServiceTest.java new file mode 100644 index 00000000000..9daaa93722e --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/dispatch/entrance/internal/CollectJobServiceTest.java @@ -0,0 +1,38 @@ +package com.usthe.collector.dispatch.entrance.internal; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link CollectJobService} + */ +class CollectJobServiceTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void collectSyncJobData() { + } + + @Test + void addAsyncCollectJob() { + } + + @Test + void updateAsyncCollectJob() { + } + + @Test + void cancelAsyncCollectJob() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/util/CollectUtilTest.java b/collector/src/test/java/com/usthe/collector/util/CollectUtilTest.java new file mode 100644 index 00000000000..54dbbdca759 --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/util/CollectUtilTest.java @@ -0,0 +1,46 @@ +package com.usthe.collector.util; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link CollectUtil} + */ +class CollectUtilTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void countMatchKeyword() { + } + + @Test + void getTimeout() { + } + + @Test + void testGetTimeout() { + } + + @Test + void assertPromRequireField() { + } + + @Test + void replaceCryPlaceholder() { + } + + @Test + void replaceSmilingPlaceholder() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/util/JsonPathParserTest.java b/collector/src/test/java/com/usthe/collector/util/JsonPathParserTest.java new file mode 100644 index 00000000000..193182d815a --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/util/JsonPathParserTest.java @@ -0,0 +1,21 @@ +package com.usthe.collector.util; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link JsonPathParser} + */ +class JsonPathParserTest { + + @BeforeEach + void setUp() { + } + + @Test + void parseContentWithJsonPath() { + } +} \ No newline at end of file diff --git a/collector/src/test/java/com/usthe/collector/util/KeyPairUtilTest.java b/collector/src/test/java/com/usthe/collector/util/KeyPairUtilTest.java new file mode 100644 index 00000000000..2f657d1ef21 --- /dev/null +++ b/collector/src/test/java/com/usthe/collector/util/KeyPairUtilTest.java @@ -0,0 +1,21 @@ +package com.usthe.collector.util; + +import com.usthe.collector.collect.common.cache.CommonCache; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link KeyPairUtil} + */ +class KeyPairUtilTest { + + @BeforeEach + void setUp() { + } + + @Test + void getKeyPairFromPublicKey() { + } +} \ No newline at end of file diff --git a/common/src/test/java/com/usthe/common/queue/CommonDataQueueTest.java b/common/src/test/java/com/usthe/common/queue/CommonDataQueueTest.java new file mode 100644 index 00000000000..67f9f3abff1 --- /dev/null +++ b/common/src/test/java/com/usthe/common/queue/CommonDataQueueTest.java @@ -0,0 +1,45 @@ +package com.usthe.common.queue; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link CommonDataQueue} + */ +class CommonDataQueueTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void addAlertData() { + } + + @Test + void pollAlertData() { + } + + @Test + void pollAlertMetricsData() { + } + + @Test + void pollPersistentStorageMetricsData() { + } + + @Test + void pollRealTimeStorageMetricsData() { + } + + @Test + void sendMetricsData() { + } +} \ No newline at end of file diff --git a/common/src/test/java/com/usthe/common/support/ResourceBundleUtf8ControlTest.java b/common/src/test/java/com/usthe/common/support/ResourceBundleUtf8ControlTest.java new file mode 100644 index 00000000000..ee0916d7c57 --- /dev/null +++ b/common/src/test/java/com/usthe/common/support/ResourceBundleUtf8ControlTest.java @@ -0,0 +1,16 @@ +package com.usthe.common.support; + +import com.usthe.common.queue.CommonDataQueue; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link ResourceBundleUtf8Control} + */ +class ResourceBundleUtf8ControlTest { + + @Test + void newBundle() { + } +} \ No newline at end of file diff --git a/common/src/test/java/com/usthe/common/support/SpringContextHolderTest.java b/common/src/test/java/com/usthe/common/support/SpringContextHolderTest.java new file mode 100644 index 00000000000..954f3ef17ad --- /dev/null +++ b/common/src/test/java/com/usthe/common/support/SpringContextHolderTest.java @@ -0,0 +1,33 @@ +package com.usthe.common.support; + +import com.usthe.common.queue.CommonDataQueue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link SpringContextHolder} + */ +class SpringContextHolderTest { + + @BeforeEach + void setUp() { + } + + @Test + void setApplicationContext() { + } + + @Test + void getApplicationContext() { + } + + @Test + void getBean() { + } + + @Test + void testGetBean() { + } +} \ No newline at end of file diff --git a/common/src/test/java/com/usthe/common/util/AesUtilTest.java b/common/src/test/java/com/usthe/common/util/AesUtilTest.java new file mode 100644 index 00000000000..c53adf70fa5 --- /dev/null +++ b/common/src/test/java/com/usthe/common/util/AesUtilTest.java @@ -0,0 +1,50 @@ +package com.usthe.common.util; + +import com.usthe.common.queue.CommonDataQueue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link AesUtil} + */ +class AesUtilTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void setDefaultSecretKey() { + } + + @Test + void aesEncode() { + } + + @Test + void aesDecode() { + } + + @Test + void isCiphertext() { + } + + @Test + void testAesEncode() { + } + + @Test + void testAesDecode() { + } + + @Test + void testIsCiphertext() { + } +} \ No newline at end of file diff --git a/common/src/test/java/com/usthe/common/util/Base64UtilTest.java b/common/src/test/java/com/usthe/common/util/Base64UtilTest.java new file mode 100644 index 00000000000..5825a3ac5d4 --- /dev/null +++ b/common/src/test/java/com/usthe/common/util/Base64UtilTest.java @@ -0,0 +1,16 @@ +package com.usthe.common.util; + +import com.usthe.common.queue.CommonDataQueue; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link Base64Util} + */ +class Base64UtilTest { + + @Test + void isBase64() { + } +} \ No newline at end of file diff --git a/common/src/test/java/com/usthe/common/util/CommonUtilTest.java b/common/src/test/java/com/usthe/common/util/CommonUtilTest.java index 43ea23203a5..30be07da4be 100644 --- a/common/src/test/java/com/usthe/common/util/CommonUtilTest.java +++ b/common/src/test/java/com/usthe/common/util/CommonUtilTest.java @@ -17,13 +17,13 @@ package com.usthe.common.util; +import com.usthe.common.queue.CommonDataQueue; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; /** - * @author tom - * @date 2022/4/7 17:18 + * Test case for {@link CommonUtil} */ class CommonUtilTest { diff --git a/common/src/test/java/com/usthe/common/util/GsonUtilTest.java b/common/src/test/java/com/usthe/common/util/GsonUtilTest.java new file mode 100644 index 00000000000..148b01f193c --- /dev/null +++ b/common/src/test/java/com/usthe/common/util/GsonUtilTest.java @@ -0,0 +1,33 @@ +package com.usthe.common.util; + +import com.usthe.common.queue.CommonDataQueue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link GsonUtil} + */ +class GsonUtilTest { + + @BeforeEach + void setUp() { + } + + @Test + void toJson() { + } + + @Test + void fromJson() { + } + + @Test + void testFromJson() { + } + + @Test + void testFromJson1() { + } +} \ No newline at end of file diff --git a/common/src/test/java/com/usthe/common/util/IntervalExpressionUtilTest.java b/common/src/test/java/com/usthe/common/util/IntervalExpressionUtilTest.java new file mode 100644 index 00000000000..f7d30cf4e90 --- /dev/null +++ b/common/src/test/java/com/usthe/common/util/IntervalExpressionUtilTest.java @@ -0,0 +1,21 @@ +package com.usthe.common.util; + +import com.usthe.common.queue.CommonDataQueue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link IntervalExpressionUtil} + */ +class IntervalExpressionUtilTest { + + @BeforeEach + void setUp() { + } + + @Test + void validNumberIntervalExpress() { + } +} \ No newline at end of file diff --git a/common/src/test/java/com/usthe/common/util/IpDomainUtilTest.java b/common/src/test/java/com/usthe/common/util/IpDomainUtilTest.java index 019e1a03136..e3e6bd2025a 100644 --- a/common/src/test/java/com/usthe/common/util/IpDomainUtilTest.java +++ b/common/src/test/java/com/usthe/common/util/IpDomainUtilTest.java @@ -17,14 +17,14 @@ package com.usthe.common.util; +import com.usthe.common.queue.CommonDataQueue; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; /** - * @author tom - * @date 2022/2/19 20:32 + * Test case for {@link IpDomainUtil} */ class IpDomainUtilTest { diff --git a/common/src/test/java/com/usthe/common/util/LruHashMapTest.java b/common/src/test/java/com/usthe/common/util/LruHashMapTest.java new file mode 100644 index 00000000000..520a3a385f2 --- /dev/null +++ b/common/src/test/java/com/usthe/common/util/LruHashMapTest.java @@ -0,0 +1,16 @@ +package com.usthe.common.util; + +import com.usthe.common.queue.CommonDataQueue; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link LruHashMap} + */ +class LruHashMapTest { + + @Test + void removeEldestEntry() { + } +} \ No newline at end of file diff --git a/common/src/test/java/com/usthe/common/util/ProtoJsonUtilTest.java b/common/src/test/java/com/usthe/common/util/ProtoJsonUtilTest.java new file mode 100644 index 00000000000..017e3a68c3c --- /dev/null +++ b/common/src/test/java/com/usthe/common/util/ProtoJsonUtilTest.java @@ -0,0 +1,25 @@ +package com.usthe.common.util; + +import com.usthe.common.queue.CommonDataQueue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link ProtoJsonUtil} + */ +class ProtoJsonUtilTest { + + @BeforeEach + void setUp() { + } + + @Test + void toJsonStr() { + } + + @Test + void toProtobuf() { + } +} \ No newline at end of file diff --git a/common/src/test/java/com/usthe/common/util/ResourceBundleUtilTest.java b/common/src/test/java/com/usthe/common/util/ResourceBundleUtilTest.java new file mode 100644 index 00000000000..b749b5390f6 --- /dev/null +++ b/common/src/test/java/com/usthe/common/util/ResourceBundleUtilTest.java @@ -0,0 +1,21 @@ +package com.usthe.common.util; + +import com.usthe.common.queue.CommonDataQueue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link ResourceBundleUtil} + */ +class ResourceBundleUtilTest { + + @BeforeEach + void setUp() { + } + + @Test + void getBundle() { + } +} \ No newline at end of file diff --git a/common/src/test/java/com/usthe/common/util/SnowFlakeIdGeneratorTest.java b/common/src/test/java/com/usthe/common/util/SnowFlakeIdGeneratorTest.java index dac8cfda16c..67da9f9b456 100644 --- a/common/src/test/java/com/usthe/common/util/SnowFlakeIdGeneratorTest.java +++ b/common/src/test/java/com/usthe/common/util/SnowFlakeIdGeneratorTest.java @@ -17,14 +17,14 @@ package com.usthe.common.util; +import com.usthe.common.queue.CommonDataQueue; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; /** - * @author tom - * @date 2021/12/3 13:28 + * Test case for {@link SnowFlakeIdGenerator} */ class SnowFlakeIdGeneratorTest { diff --git a/manager/src/main/java/com/usthe/manager/dao/MonitorDao.java b/manager/src/main/java/com/usthe/manager/dao/MonitorDao.java index 914a7a8afb2..6a19c8d8269 100644 --- a/manager/src/main/java/com/usthe/manager/dao/MonitorDao.java +++ b/manager/src/main/java/com/usthe/manager/dao/MonitorDao.java @@ -97,7 +97,7 @@ public interface MonitorDao extends JpaRepository, JpaSpecificati * @param id Monitor ID 监控ID * @param status 监控状态 Monitor Status */ - @Modifying + @Modifying(clearAutomatically = true) @Query("update Monitor set status = :status where id = :id") void updateMonitorStatus(@Param(value = "id") Long id, @Param(value = "status") byte status); } diff --git a/manager/src/main/resources/application-test.yml b/manager/src/main/resources/application-test.yml new file mode 100644 index 00000000000..d757e2bf209 --- /dev/null +++ b/manager/src/main/resources/application-test.yml @@ -0,0 +1,54 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +server: + port: ${random.int[10000,19999]} +spring: + datasource: + driver-class-name: org.h2.Driver + username: sa + password: 123456 + url: jdbc:h2:./data/hertzbeat-test;MODE=MYSQL + hikari: + max-lifetime: 120000 + jpa: + hibernate: + ddl-auto: update + mail: + host: smtp.exmail.qq.com + username: example@tancloud.cn + password: example + port: 465 + default-encoding: UTF-8 + properties: + mail: + smtp: + socketFactoryClass: javax.net.ssl.SSLSocketFactory + ssl: + enable: true + debug: false + thymeleaf: + prefix: classpath:/templates/ + check-template-location: true + cache: true + suffix: .html + mode: HTML +warehouse: + store: + td-engine: + enabled: false + driver-class-name: com.taosdata.jdbc.rs.RestfulDriver + url: jdbc:TAOS-RS://localhost:6041/hertzbeat + username: root + password: taosdata diff --git a/manager/src/main/resources/application.yml b/manager/src/main/resources/application.yml index 87769be77ce..ca1cc2f0b22 100644 --- a/manager/src/main/resources/application.yml +++ b/manager/src/main/resources/application.yml @@ -28,6 +28,12 @@ spring: static-locations: - classpath:/dist/ - classpath:../dist/ + thymeleaf: + prefix: classpath:/templates/ + check-template-location: true + cache: true + suffix: .html + mode: HTML sureness: auths: @@ -73,13 +79,6 @@ spring: enable: true debug: false - thymeleaf: - prefix: classpath:/templates/ - check-template-location: true - cache: true - suffix: .html - mode: HTML - warehouse: store: td-engine: @@ -98,10 +97,3 @@ alerter: max-alert-eval-interval: 86400000 # system alert(available alert, reachable alert...) trigger times system-alert-trigger-times: 1 - -springdoc: - api-docs: - enabled: true - packagesToScan: com.usthe.manager.controller - pathsToMatch: /api/** - diff --git a/manager/src/test/java/com/usthe/manager/AbstractSpringIntegrationTest.java b/manager/src/test/java/com/usthe/manager/AbstractSpringIntegrationTest.java new file mode 100644 index 00000000000..29f8f31d210 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/AbstractSpringIntegrationTest.java @@ -0,0 +1,13 @@ +package com.usthe.manager; + +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +/** + * Abstract Integration Test for Spring. + */ +@ActiveProfiles("test") +@SpringBootTest(classes = Manager.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class AbstractSpringIntegrationTest { + +} diff --git a/manager/src/test/java/com/usthe/manager/component/alerter/AlertNotifyHandlerTest.java b/manager/src/test/java/com/usthe/manager/component/alerter/AlertNotifyHandlerTest.java new file mode 100644 index 00000000000..4c300f0e064 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/component/alerter/AlertNotifyHandlerTest.java @@ -0,0 +1,25 @@ +package com.usthe.manager.component.alerter; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link AlertNotifyHandler} + */ +class AlertNotifyHandlerTest { + + @BeforeEach + void setUp() { + } + + @Test + void send() { + } + + @Test + void type() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/component/alerter/DispatcherAlarmTest.java b/manager/src/test/java/com/usthe/manager/component/alerter/DispatcherAlarmTest.java new file mode 100644 index 00000000000..403063eb3f9 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/component/alerter/DispatcherAlarmTest.java @@ -0,0 +1,25 @@ +package com.usthe.manager.component.alerter; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link DispatcherAlarm} + */ +class DispatcherAlarmTest { + + @BeforeEach + void setUp() { + } + + @Test + void afterPropertiesSet() { + } + + @Test + void sendNoticeMsg() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/component/alerter/impl/DbAlertStoreHandlerImplTest.java b/manager/src/test/java/com/usthe/manager/component/alerter/impl/DbAlertStoreHandlerImplTest.java new file mode 100644 index 00000000000..c73376bacea --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/component/alerter/impl/DbAlertStoreHandlerImplTest.java @@ -0,0 +1,21 @@ +package com.usthe.manager.component.alerter.impl; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link DbAlertStoreHandlerImpl} + */ +class DbAlertStoreHandlerImplTest { + + @BeforeEach + void setUp() { + } + + @Test + void store() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/component/alerter/impl/DingTalkRobotAlertNotifyHandlerImplTest.java b/manager/src/test/java/com/usthe/manager/component/alerter/impl/DingTalkRobotAlertNotifyHandlerImplTest.java new file mode 100644 index 00000000000..36cf283130b --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/component/alerter/impl/DingTalkRobotAlertNotifyHandlerImplTest.java @@ -0,0 +1,25 @@ +package com.usthe.manager.component.alerter.impl; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link DingTalkRobotAlertNotifyHandlerImpl} + */ +class DingTalkRobotAlertNotifyHandlerImplTest { + + @BeforeEach + void setUp() { + } + + @Test + void send() { + } + + @Test + void type() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/component/alerter/impl/EmailAlertNotifyHandlerImplTest.java b/manager/src/test/java/com/usthe/manager/component/alerter/impl/EmailAlertNotifyHandlerImplTest.java new file mode 100644 index 00000000000..8bd1e4eac07 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/component/alerter/impl/EmailAlertNotifyHandlerImplTest.java @@ -0,0 +1,25 @@ +package com.usthe.manager.component.alerter.impl; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link EmailAlertNotifyHandlerImpl} + */ +class EmailAlertNotifyHandlerImplTest { + + @BeforeEach + void setUp() { + } + + @Test + void send() { + } + + @Test + void type() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImplTest.java b/manager/src/test/java/com/usthe/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImplTest.java new file mode 100644 index 00000000000..d6ce008d8eb --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImplTest.java @@ -0,0 +1,25 @@ +package com.usthe.manager.component.alerter.impl; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link FlyBookAlertNotifyHandlerImpl} + */ +class FlyBookAlertNotifyHandlerImplTest { + + @BeforeEach + void setUp() { + } + + @Test + void send() { + } + + @Test + void type() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/component/alerter/impl/WeWorkRobotAlertNotifyHandlerImplTest.java b/manager/src/test/java/com/usthe/manager/component/alerter/impl/WeWorkRobotAlertNotifyHandlerImplTest.java new file mode 100644 index 00000000000..5f7951574aa --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/component/alerter/impl/WeWorkRobotAlertNotifyHandlerImplTest.java @@ -0,0 +1,25 @@ +package com.usthe.manager.component.alerter.impl; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link WeWorkRobotAlertNotifyHandlerImpl} + */ +class WeWorkRobotAlertNotifyHandlerImplTest { + + @BeforeEach + void setUp() { + } + + @Test + void send() { + } + + @Test + void type() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/component/alerter/impl/WebHookAlertNotifyHandlerImplTest.java b/manager/src/test/java/com/usthe/manager/component/alerter/impl/WebHookAlertNotifyHandlerImplTest.java new file mode 100644 index 00000000000..3ba2340dce7 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/component/alerter/impl/WebHookAlertNotifyHandlerImplTest.java @@ -0,0 +1,25 @@ +package com.usthe.manager.component.alerter.impl; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link WebHookAlertNotifyHandlerImpl} + */ +class WebHookAlertNotifyHandlerImplTest { + + @BeforeEach + void setUp() { + } + + @Test + void send() { + } + + @Test + void type() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/controller/AccountControllerTest.java b/manager/src/test/java/com/usthe/manager/controller/AccountControllerTest.java new file mode 100644 index 00000000000..d3bc43a1e29 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/controller/AccountControllerTest.java @@ -0,0 +1,63 @@ +package com.usthe.manager.controller; + +import com.usthe.common.util.CommonConstants; +import com.usthe.common.util.GsonUtil; +import com.usthe.manager.pojo.dto.LoginDto; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; + +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +/** + * Test case for {@link AccountController} + */ +@ExtendWith(MockitoExtension.class) +class AccountControllerTest { + + private MockMvc mockMvc; + + @InjectMocks + private AccountController accountController; + + @BeforeEach + void setUp() { + this.mockMvc = MockMvcBuilders.standaloneSetup(accountController).build(); + } + + @Test + void authGetToken() throws Exception { + LoginDto loginDto = LoginDto.builder() + .identifier("admin") + .credential("hertzbeat") + .build(); + this.mockMvc.perform(MockMvcRequestBuilders.post("/api/account/auth/form") + .contentType(MediaType.APPLICATION_JSON) + .content(GsonUtil.toJson(loginDto))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value((int) CommonConstants.SUCCESS_CODE)) + .andExpect(jsonPath("$.data.token").exists()) + .andReturn(); + loginDto.setCredential("wrong_credential"); + this.mockMvc.perform(MockMvcRequestBuilders.post("/api/account/auth/form") + .contentType(MediaType.APPLICATION_JSON) + .content(GsonUtil.toJson(loginDto))) + .andExpect(jsonPath("$.code").value((int) CommonConstants.MONITOR_LOGIN_FAILED_CODE)) + .andReturn(); + } + + @Test + void refreshToken() throws Exception { + this.mockMvc.perform(MockMvcRequestBuilders.get("/api/account/auth/refresh/{refreshToken}", + "123456")) + .andExpect(jsonPath("$.code").value((int) CommonConstants.MONITOR_LOGIN_FAILED_CODE)) + .andReturn(); + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/controller/AppControllerTest.java b/manager/src/test/java/com/usthe/manager/controller/AppControllerTest.java new file mode 100644 index 00000000000..cd801cd2a68 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/controller/AppControllerTest.java @@ -0,0 +1,29 @@ +package com.usthe.manager.controller; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link AppController} + */ +class AppControllerTest { + + @BeforeEach + void setUp() { + } + + @Test + void queryAppParamDefines() { + } + + @Test + void queryAppDefine() { + } + + @Test + void queryAppsHierarchy() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/controller/I18nControllerTest.java b/manager/src/test/java/com/usthe/manager/controller/I18nControllerTest.java new file mode 100644 index 00000000000..4c4c455c790 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/controller/I18nControllerTest.java @@ -0,0 +1,21 @@ +package com.usthe.manager.controller; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link I18nController} + */ +class I18nControllerTest { + + @BeforeEach + void setUp() { + } + + @Test + void queryI18n() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/controller/MonitorControllerTest.java b/manager/src/test/java/com/usthe/manager/controller/MonitorControllerTest.java new file mode 100644 index 00000000000..abca649a10a --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/controller/MonitorControllerTest.java @@ -0,0 +1,45 @@ +package com.usthe.manager.controller; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link MonitorController} + */ +class MonitorControllerTest { + + @BeforeEach + void setUp() { + } + + @Test + void addNewMonitor() { + } + + @Test + void modifyMonitor() { + } + + @Test + void getMonitor() { + } + + @Test + void deleteMonitor() { + } + + @Test + void detectMonitor() { + } + + @Test + void addNewMonitorOptionalMetrics() { + } + + @Test + void getMonitorMetrics() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/controller/MonitorsControllerTest.java b/manager/src/test/java/com/usthe/manager/controller/MonitorsControllerTest.java new file mode 100644 index 00000000000..1ebe5cc431a --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/controller/MonitorsControllerTest.java @@ -0,0 +1,37 @@ +package com.usthe.manager.controller; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link MonitorsController} + */ +class MonitorsControllerTest { + + @BeforeEach + void setUp() { + } + + @Test + void getMonitors() { + } + + @Test + void getAppMonitors() { + } + + @Test + void deleteMonitors() { + } + + @Test + void cancelManageMonitors() { + } + + @Test + void enableManageMonitors() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/controller/NoticeConfigControllerTest.java b/manager/src/test/java/com/usthe/manager/controller/NoticeConfigControllerTest.java new file mode 100644 index 00000000000..e4378b31284 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/controller/NoticeConfigControllerTest.java @@ -0,0 +1,53 @@ +package com.usthe.manager.controller; + +import com.usthe.manager.service.TagService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link NoticeConfigController} + */ +class NoticeConfigControllerTest { + + @BeforeEach + void setUp() { + } + + @Test + void addNewNoticeReceiver() { + } + + @Test + void editNoticeReceiver() { + } + + @Test + void deleteNoticeReceiver() { + } + + @Test + void getReceivers() { + } + + @Test + void addNewNoticeRule() { + } + + @Test + void editNoticeRule() { + } + + @Test + void deleteNoticeRule() { + } + + @Test + void getRules() { + } + + @Test + void sendTestMsg() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/controller/SummaryControllerTest.java b/manager/src/test/java/com/usthe/manager/controller/SummaryControllerTest.java new file mode 100644 index 00000000000..f1e48a61eaa --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/controller/SummaryControllerTest.java @@ -0,0 +1,20 @@ +package com.usthe.manager.controller; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link SummaryController} + */ +class SummaryControllerTest { + + @BeforeEach + void setUp() { + } + + @Test + void appMonitors() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/controller/TagControllerTest.java b/manager/src/test/java/com/usthe/manager/controller/TagControllerTest.java new file mode 100644 index 00000000000..9c2e904b845 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/controller/TagControllerTest.java @@ -0,0 +1,32 @@ +package com.usthe.manager.controller; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link TagController} + */ +class TagControllerTest { + + @BeforeEach + void setUp() { + } + + @Test + void addNewTags() { + } + + @Test + void modifyMonitor() { + } + + @Test + void getTags() { + } + + @Test + void deleteTags() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/dao/MonitorDaoTest.java b/manager/src/test/java/com/usthe/manager/dao/MonitorDaoTest.java new file mode 100644 index 00000000000..a5dba1b00d3 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/dao/MonitorDaoTest.java @@ -0,0 +1,101 @@ +package com.usthe.manager.dao; + +import com.usthe.common.entity.manager.Monitor; +import com.usthe.manager.AbstractSpringIntegrationTest; +import com.usthe.manager.pojo.dto.AppCount; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; + +import java.util.*; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link MonitorDao} + */ +@Transactional +class MonitorDaoTest extends AbstractSpringIntegrationTest { + + @Resource + private MonitorDao monitorDao; + + @BeforeEach + void setUp() { + Monitor monitor = Monitor.builder() + .id(1L) + .jobId(2L) + .app("jvm") + .name("jvm_test") + .host("192.34.5.43") + .status((byte) 1) + .build(); + monitor = monitorDao.saveAndFlush(monitor); + assertNotNull(monitor); + } + + @AfterEach + void tearDown() { + monitorDao.deleteAll(); + } + + @Test + void deleteAllByIdIn() { + Set ids = new HashSet<>(); + ids.add(1L); + assertDoesNotThrow(() -> monitorDao.deleteAllByIdIn(ids)); + } + + @Test + void findMonitorsByIdIn() { + Set ids = new HashSet<>(); + ids.add(1L); + List monitors = monitorDao.findMonitorsByIdIn(ids); + assertNotNull(monitors); + assertEquals(1, monitors.size()); + } + + @Test + void findMonitorsByAppEquals() { + List monitors = monitorDao.findMonitorsByAppEquals("jvm"); + assertNotNull(monitors); + assertEquals(1, monitors.size()); + monitors = monitorDao.findMonitorsByAppEquals("mysql"); + assertTrue(monitors.isEmpty()); + } + + @Test + void findMonitorsByStatusNotInAndAndJobIdNotNull() { + List bytes = Arrays.asList((byte) 2, (byte) 3); + List monitors = monitorDao.findMonitorsByStatusNotInAndAndJobIdNotNull(bytes); + assertNotNull(monitors); + assertEquals(1, monitors.size()); + } + + @Test + void findMonitorByNameEquals() { + Optional monitorOptional = monitorDao.findMonitorByNameEquals("jvm_test"); + assertTrue(monitorOptional.isPresent()); + } + + @Test + void findAppsStatusCount() { + List appCounts = monitorDao.findAppsStatusCount(); + assertNotNull(appCounts); + assertFalse(appCounts.isEmpty()); + } + + @Test + void updateMonitorStatus() { + Optional monitorOptional = monitorDao.findById(1L); + assertTrue(monitorOptional.isPresent()); + assertEquals((byte) 1, monitorOptional.get().getStatus()); + monitorDao.updateMonitorStatus(1L, (byte) 0); + monitorOptional = monitorDao.findById(1L); + assertTrue(monitorOptional.isPresent()); + assertEquals((byte) 0, monitorOptional.get().getStatus()); + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/dao/NoticeRuleDaoTest.java b/manager/src/test/java/com/usthe/manager/dao/NoticeRuleDaoTest.java new file mode 100644 index 00000000000..e078ccf30bb --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/dao/NoticeRuleDaoTest.java @@ -0,0 +1,21 @@ +package com.usthe.manager.dao; + +import com.usthe.manager.controller.NoticeConfigController; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link NoticeRuleDao} + */ +class NoticeRuleDaoTest { + + @BeforeEach + void setUp() { + } + + @Test + void findNoticeRulesByEnableTrue() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/dao/ParamDaoTest.java b/manager/src/test/java/com/usthe/manager/dao/ParamDaoTest.java new file mode 100644 index 00000000000..db76805fcaa --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/dao/ParamDaoTest.java @@ -0,0 +1,29 @@ +package com.usthe.manager.dao; + +import com.usthe.manager.controller.NoticeConfigController; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link ParamDao} + */ +class ParamDaoTest { + + @BeforeEach + void setUp() { + } + + @Test + void findParamsByMonitorId() { + } + + @Test + void deleteParamsByMonitorId() { + } + + @Test + void deleteParamsByMonitorIdIn() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/dao/ParamDefineDaoTest.java b/manager/src/test/java/com/usthe/manager/dao/ParamDefineDaoTest.java new file mode 100644 index 00000000000..83be06c6433 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/dao/ParamDefineDaoTest.java @@ -0,0 +1,21 @@ +package com.usthe.manager.dao; + +import com.usthe.manager.controller.NoticeConfigController; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link ParamDefineDao} + */ +class ParamDefineDaoTest { + + @BeforeEach + void setUp() { + } + + @Test + void findParamDefinesByApp() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/dao/TagDaoTest.java b/manager/src/test/java/com/usthe/manager/dao/TagDaoTest.java new file mode 100644 index 00000000000..b50572129a8 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/dao/TagDaoTest.java @@ -0,0 +1,21 @@ +package com.usthe.manager.dao; + +import com.usthe.manager.controller.NoticeConfigController; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link TagDao} + */ +class TagDaoTest { + + @BeforeEach + void setUp() { + } + + @Test + void deleteTagsByIdIn() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/service/AppServiceTest.java b/manager/src/test/java/com/usthe/manager/service/AppServiceTest.java new file mode 100644 index 00000000000..b8802479d7f --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/service/AppServiceTest.java @@ -0,0 +1,37 @@ +package com.usthe.manager.service; + +import com.usthe.manager.controller.NoticeConfigController; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link AppService} + */ +class AppServiceTest { + + @BeforeEach + void setUp() { + } + + @Test + void getAppParamDefines() { + } + + @Test + void getAppDefine() { + } + + @Test + void getAppDefineMetricNames() { + } + + @Test + void getI18nResources() { + } + + @Test + void getAllAppHierarchy() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/service/MailServiceTest.java b/manager/src/test/java/com/usthe/manager/service/MailServiceTest.java new file mode 100644 index 00000000000..85247453fd7 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/service/MailServiceTest.java @@ -0,0 +1,21 @@ +package com.usthe.manager.service; + +import com.usthe.manager.controller.NoticeConfigController; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link MailService} + */ +class MailServiceTest { + + @BeforeEach + void setUp() { + } + + @Test + void buildAlertHtmlTemplate() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/service/MonitorServiceTest.java b/manager/src/test/java/com/usthe/manager/service/MonitorServiceTest.java new file mode 100644 index 00000000000..8a8eb9b42c1 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/service/MonitorServiceTest.java @@ -0,0 +1,81 @@ +package com.usthe.manager.service; + +import com.usthe.manager.controller.NoticeConfigController; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link MonitorService} + */ +class MonitorServiceTest { + + @BeforeEach + void setUp() { + } + + @Test + void detectMonitor() { + } + + @Test + void addMonitor() { + } + + @Test + void validate() { + } + + @Test + void modifyMonitor() { + } + + @Test + void deleteMonitor() { + } + + @Test + void deleteMonitors() { + } + + @Test + void getMonitorDto() { + } + + @Test + void getMonitors() { + } + + @Test + void cancelManageMonitors() { + } + + @Test + void enableManageMonitors() { + } + + @Test + void getAllAppMonitorsCount() { + } + + @Test + void getMonitor() { + } + + @Test + void updateMonitorStatus() { + } + + @Test + void getAppMonitors() { + } + + @Test + void addNewMonitorOptionalMetrics() { + } + + @Test + void getMonitorMetrics() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/service/NoticeConfigServiceTest.java b/manager/src/test/java/com/usthe/manager/service/NoticeConfigServiceTest.java new file mode 100644 index 00000000000..9df1ba9fde6 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/service/NoticeConfigServiceTest.java @@ -0,0 +1,65 @@ +package com.usthe.manager.service; + +import com.usthe.manager.controller.NoticeConfigController; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link NoticeConfigService} + */ +class NoticeConfigServiceTest { + + @BeforeEach + void setUp() { + } + + @Test + void getNoticeReceivers() { + } + + @Test + void getNoticeRules() { + } + + @Test + void addReceiver() { + } + + @Test + void editReceiver() { + } + + @Test + void deleteReceiver() { + } + + @Test + void addNoticeRule() { + } + + @Test + void editNoticeRule() { + } + + @Test + void deleteNoticeRule() { + } + + @Test + void getReceiverFilterRule() { + } + + @Test + void getReceiverById() { + } + + @Test + void getNoticeRulesById() { + } + + @Test + void sendTestMsg() { + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/service/TagServiceTest.java b/manager/src/test/java/com/usthe/manager/service/TagServiceTest.java new file mode 100644 index 00000000000..35b0376c809 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/service/TagServiceTest.java @@ -0,0 +1,65 @@ +package com.usthe.manager.service; + +import com.usthe.common.entity.manager.Tag; +import com.usthe.manager.dao.TagDao; +import com.usthe.manager.service.impl.TagServiceImpl; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; + +/** + * Test case for {@link TagService} + */ +@ExtendWith(MockitoExtension.class) +class TagServiceTest { + + @InjectMocks + private TagServiceImpl tagService; + + @Mock + private TagDao tagDao; + + @Test + void addTags() { + when(tagDao.saveAll(anyList())).thenReturn(anyList()); + assertDoesNotThrow(() -> tagService.addTags(Collections.singletonList(new Tag()))); + } + + @Test + void modifyTag() { + Tag tag = Tag.builder().id(1L).build(); + when(tagDao.findById(1L)).thenReturn(Optional.of(tag)); + when(tagDao.save(tag)).thenReturn(tag); + assertDoesNotThrow(() -> tagService.modifyTag(tag)); + reset(); + when(tagDao.findById(1L)).thenReturn(Optional.empty()); + assertThrows(IllegalArgumentException.class, () -> tagService.modifyTag(tag)); + } + + @Test + void getTags() { + Specification specification = mock(Specification.class); + when(tagDao.findAll(specification, PageRequest.of(1, 1))).thenReturn(Page.empty()); + assertNotNull(tagService.getTags(specification, PageRequest.of(1, 1))); + } + + @Test + void deleteTags() { + doNothing().when(tagDao).deleteTagsByIdIn(anySet()); + assertDoesNotThrow(() -> tagService.deleteTags(new HashSet<>(1))); + } +} \ No newline at end of file diff --git a/manager/src/test/java/com/usthe/manager/support/GlobalExceptionHandlerTest.java b/manager/src/test/java/com/usthe/manager/support/GlobalExceptionHandlerTest.java new file mode 100644 index 00000000000..dfb2d5cd241 --- /dev/null +++ b/manager/src/test/java/com/usthe/manager/support/GlobalExceptionHandlerTest.java @@ -0,0 +1,57 @@ +package com.usthe.manager.support; + +import com.usthe.manager.controller.NoticeConfigController; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link GlobalExceptionHandler} + */ +class GlobalExceptionHandlerTest { + + @BeforeEach + void setUp() { + } + + @Test + void handleMonitorDetectException() { + } + + @Test + void handleMonitorDatabaseException() { + } + + @Test + void handleIllegalArgumentException() { + } + + @Test + void handleAlertNoticeException() { + } + + @Test + void handleHttpMessageNotReadableException() { + } + + @Test + void handleInputValidException() { + } + + @Test + void handleDataAccessException() { + } + + @Test + void handleMethodNotSupportException() { + } + + @Test + void handleUnknownException() { + } + + @Test + void handleMonitorMetricsException() { + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 218ea4781cf..c3970fdc795 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,6 @@ 1.6.11 5.7.0 - 4.0.2 @@ -73,9 +72,8 @@ test - org.easymock - easymock - ${easymock.version} + org.springframework.boot + spring-boot-starter-test test diff --git a/script/application.yml b/script/application.yml index d24b681aeac..332d8e02856 100644 --- a/script/application.yml +++ b/script/application.yml @@ -22,12 +22,19 @@ spring: active: prod mvc: static-path-pattern: /** - resources: - static-locations: - - classpath:/dist/ - - classpath:../dist/ jackson: - default-property-inclusion: NON_EMPTY + default-property-inclusion: ALWAYS + web: + resources: + static-locations: + - classpath:/dist/ + - classpath:../dist/ + thymeleaf: + prefix: classpath:/templates/ + check-template-location: true + cache: true + suffix: .html + mode: HTML sureness: auths: @@ -73,13 +80,6 @@ spring: enable: true debug: false - thymeleaf: - prefix: classpath:/templates/ - check-template-location: true - cache: true - suffix: .html - mode: HTML - warehouse: store: td-engine: diff --git a/script/docker-compose/conf/application.yml b/script/docker-compose/conf/application.yml index b1cfa82e996..e285dfad6ff 100644 --- a/script/docker-compose/conf/application.yml +++ b/script/docker-compose/conf/application.yml @@ -22,12 +22,19 @@ spring: active: prod mvc: static-path-pattern: /** - resources: - static-locations: - - classpath:/dist/ - - classpath:../dist/ jackson: - default-property-inclusion: NON_EMPTY + default-property-inclusion: ALWAYS + web: + resources: + static-locations: + - classpath:/dist/ + - classpath:../dist/ + thymeleaf: + prefix: classpath:/templates/ + check-template-location: true + cache: true + suffix: .html + mode: HTML sureness: auths: @@ -71,15 +78,6 @@ spring: ssl: enable: true - thymeleaf: - prefix: classpath:/templates/ - check-template-location: true - cache: true - suffix: .html - #encoding: UTF-8 - #content-type: text/html - mode: HTML - warehouse: store: td-engine: diff --git a/warehouse/src/test/java/com/usthe/warehouse/WarehouseWorkerPoolTest.java b/warehouse/src/test/java/com/usthe/warehouse/WarehouseWorkerPoolTest.java new file mode 100644 index 00000000000..18105e6c13a --- /dev/null +++ b/warehouse/src/test/java/com/usthe/warehouse/WarehouseWorkerPoolTest.java @@ -0,0 +1,20 @@ +package com.usthe.warehouse; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link WarehouseWorkerPool} + */ +class WarehouseWorkerPoolTest { + + @BeforeEach + void setUp() { + } + + @Test + void executeJob() { + } +} \ No newline at end of file diff --git a/warehouse/src/test/java/com/usthe/warehouse/controller/MetricsDataControllerTest.java b/warehouse/src/test/java/com/usthe/warehouse/controller/MetricsDataControllerTest.java new file mode 100644 index 00000000000..56f2a7ed125 --- /dev/null +++ b/warehouse/src/test/java/com/usthe/warehouse/controller/MetricsDataControllerTest.java @@ -0,0 +1,28 @@ +package com.usthe.warehouse.controller; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link MetricsDataController} + */ +class MetricsDataControllerTest { + + @BeforeEach + void setUp() { + } + + @Test + void getWarehouseStorageServerStatus() { + } + + @Test + void getMetricsData() { + } + + @Test + void getMetricHistoryData() { + } +} \ No newline at end of file diff --git a/warehouse/src/test/java/com/usthe/warehouse/store/MemoryDataStorageTest.java b/warehouse/src/test/java/com/usthe/warehouse/store/MemoryDataStorageTest.java new file mode 100644 index 00000000000..23fb2a5ab66 --- /dev/null +++ b/warehouse/src/test/java/com/usthe/warehouse/store/MemoryDataStorageTest.java @@ -0,0 +1,24 @@ +package com.usthe.warehouse.store; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link MemoryDataStorage} + */ +class MemoryDataStorageTest { + + @BeforeEach + void setUp() { + } + + @Test + void getCurrentMetricsData() { + } + + @Test + void destroy() { + } +} \ No newline at end of file diff --git a/warehouse/src/test/java/com/usthe/warehouse/store/MetricsDataRedisCodecTest.java b/warehouse/src/test/java/com/usthe/warehouse/store/MetricsDataRedisCodecTest.java new file mode 100644 index 00000000000..35887eff4f5 --- /dev/null +++ b/warehouse/src/test/java/com/usthe/warehouse/store/MetricsDataRedisCodecTest.java @@ -0,0 +1,32 @@ +package com.usthe.warehouse.store; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link MetricsDataRedisCodec} + */ +class MetricsDataRedisCodecTest { + + @BeforeEach + void setUp() { + } + + @Test + void decodeKey() { + } + + @Test + void decodeValue() { + } + + @Test + void encodeKey() { + } + + @Test + void encodeValue() { + } +} \ No newline at end of file diff --git a/warehouse/src/test/java/com/usthe/warehouse/store/RedisDataStorageTest.java b/warehouse/src/test/java/com/usthe/warehouse/store/RedisDataStorageTest.java new file mode 100644 index 00000000000..52e489091a0 --- /dev/null +++ b/warehouse/src/test/java/com/usthe/warehouse/store/RedisDataStorageTest.java @@ -0,0 +1,24 @@ +package com.usthe.warehouse.store; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link RedisDataStorage} + */ +class RedisDataStorageTest { + + @BeforeEach + void setUp() { + } + + @Test + void getCurrentMetricsData() { + } + + @Test + void destroy() { + } +} \ No newline at end of file diff --git a/warehouse/src/test/java/com/usthe/warehouse/store/TdEngineDataStorageTest.java b/warehouse/src/test/java/com/usthe/warehouse/store/TdEngineDataStorageTest.java new file mode 100644 index 00000000000..7600551edd1 --- /dev/null +++ b/warehouse/src/test/java/com/usthe/warehouse/store/TdEngineDataStorageTest.java @@ -0,0 +1,36 @@ +package com.usthe.warehouse.store; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test case for {@link TdEngineDataStorage} + */ +class TdEngineDataStorageTest { + + @BeforeEach + void setUp() { + } + + @Test + void isServerAvailable() { + } + + @Test + void saveData() { + } + + @Test + void destroy() { + } + + @Test + void getHistoryMetricData() { + } + + @Test + void getHistoryIntervalMetricData() { + } +} \ No newline at end of file