diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/component/status/CalculateStatus.java b/manager/src/main/java/org/apache/hertzbeat/manager/component/status/CalculateStatus.java index 828aa495c75..ec37ea966bb 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/component/status/CalculateStatus.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/component/status/CalculateStatus.java @@ -37,6 +37,7 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.manager.Monitor; import org.apache.hertzbeat.common.entity.manager.StatusPageComponent; @@ -51,7 +52,6 @@ import org.apache.hertzbeat.manager.dao.StatusPageOrgDao; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; /** * calculate component status for status page @@ -115,7 +115,7 @@ private void startCalculate() { ListJoin tagJoin = root .join(root.getModel() .getList("tags", Tag.class), JoinType.LEFT); - if (StringUtils.hasText(tagItem.getValue())) { + if (StringUtils.isNotBlank(tagItem.getValue())) { andList.add(criteriaBuilder.equal(tagJoin.get("name"), tagItem.getName())); andList.add(criteriaBuilder.equal(tagJoin.get("tagValue"), tagItem.getValue())); } else { diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/config/CommonCommandLineRunner.java b/manager/src/main/java/org/apache/hertzbeat/manager/config/CommonCommandLineRunner.java index 71fc96023d9..f1cac1a2b18 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/config/CommonCommandLineRunner.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/config/CommonCommandLineRunner.java @@ -24,6 +24,7 @@ import java.util.Locale; import java.util.Random; import java.util.TimeZone; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.manager.GeneralConfig; import org.apache.hertzbeat.common.util.TimeZoneUtil; @@ -40,7 +41,6 @@ import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; /** * Common CommandLineRunner class @@ -106,7 +106,7 @@ public void run(String... args) throws Exception { if (DEFAULT_JWT_SECRET.equals(currentJwtSecret)) { // use the random jwt secret SystemSecret systemSecret = systemSecretService.getConfig(); - if (systemSecret == null || !StringUtils.hasText(systemSecret.getJwtSecret())) { + if (systemSecret == null || StringUtils.isBlank(systemSecret.getJwtSecret())) { char[] chars = DEFAULT_JWT_SECRET.toCharArray(); Random rand = new Random(); for (int i = 0; i < chars.length; i++) { diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/scheduler/SchedulerInit.java b/manager/src/main/java/org/apache/hertzbeat/manager/scheduler/SchedulerInit.java index 3a79aa1f6a6..34d2d9d0227 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/scheduler/SchedulerInit.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/scheduler/SchedulerInit.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.dto.CollectorInfo; import org.apache.hertzbeat.common.entity.job.Configmap; @@ -40,7 +41,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; -import org.springframework.util.StringUtils; /** * scheduler init @@ -110,7 +110,7 @@ public void run(String... args) throws Exception { .map(param -> new Configmap(param.getField(), param.getParamValue(), param.getType())).collect(Collectors.toList()); List paramDefaultValue = appDefine.getParams().stream() - .filter(item -> StringUtils.hasText(item.getDefaultValue())) + .filter(item -> StringUtils.isNotBlank(item.getDefaultValue())) .toList(); paramDefaultValue.forEach(defaultVar -> { if (configmaps.stream().noneMatch(item -> item.getKey().equals(defaultVar.getField()))) { diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/scheduler/netty/process/CollectorOnlineProcessor.java b/manager/src/main/java/org/apache/hertzbeat/manager/scheduler/netty/process/CollectorOnlineProcessor.java index ab48b220380..f48412232e8 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/scheduler/netty/process/CollectorOnlineProcessor.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/scheduler/netty/process/CollectorOnlineProcessor.java @@ -20,12 +20,12 @@ import io.netty.channel.ChannelHandlerContext; import java.net.InetSocketAddress; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.entity.dto.CollectorInfo; import org.apache.hertzbeat.common.entity.message.ClusterMsg; import org.apache.hertzbeat.common.util.JsonUtil; import org.apache.hertzbeat.manager.scheduler.netty.ManageServer; import org.apache.hertzbeat.remoting.netty.NettyRemotingProcessor; -import org.springframework.util.StringUtils; /** * handle collector online message @@ -43,7 +43,7 @@ public ClusterMsg.Message handle(ChannelHandlerContext ctx, ClusterMsg.Message m String collector = message.getIdentity(); log.info("the collector {} actively requests to go online.", collector); CollectorInfo collectorInfo = JsonUtil.fromJson(message.getMsg(), CollectorInfo.class); - if (collectorInfo != null && !StringUtils.hasText(collectorInfo.getIp())) { + if (collectorInfo != null && StringUtils.isBlank(collectorInfo.getIp())) { // fetch remote ip address InetSocketAddress socketAddress = (InetSocketAddress) ctx.channel().remoteAddress(); String clientIP = socketAddress.getAddress().getHostAddress(); diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/AppServiceImpl.java b/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/AppServiceImpl.java index 11215605605..71189de92a3 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/AppServiceImpl.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/AppServiceImpl.java @@ -38,6 +38,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.collector.dispatch.DispatchConstants; import org.apache.hertzbeat.collector.util.CollectUtil; import org.apache.hertzbeat.common.entity.job.Configmap; @@ -70,7 +71,6 @@ import org.springframework.stereotype.Service; import org.springframework.util.Assert; import org.springframework.util.StreamUtils; -import org.springframework.util.StringUtils; import org.yaml.snakeyaml.Yaml; /** @@ -106,7 +106,7 @@ public class AppServiceImpl implements AppService, CommandLineRunner { @Override public List getAppParamDefines(String app) { - if (StringUtils.hasText(app)){ + if (StringUtils.isNotBlank(app)){ var appDefine = appDefines.get(app.toLowerCase()); if (appDefine != null && appDefine.getParams() != null) { return appDefine.getParams(); @@ -168,7 +168,7 @@ public Job getAutoGenerateDynamicDefine(Long monitorId) { @Override public Job getAppDefine(String app) throws IllegalArgumentException { - if (!StringUtils.hasText(app)) { + if (StringUtils.isBlank(app)) { throw new IllegalArgumentException("The app can not null."); } var appDefine = appDefines.get(app.toLowerCase()); @@ -180,7 +180,7 @@ public Job getAppDefine(String app) throws IllegalArgumentException { @Override public Optional getAppDefineOption(String app) { - if (StringUtils.hasText(app)) { + if (StringUtils.isNotBlank(app)) { Job appDefine = appDefines.get(app.toLowerCase()); return Optional.ofNullable(appDefine); } @@ -190,7 +190,7 @@ public Optional getAppDefineOption(String app) { @Override public List getAppDefineMetricNames(String app) { List metricNames = new ArrayList<>(16); - if (StringUtils.hasLength(app)) { + if (StringUtils.isNotBlank(app)) { var appDefine = appDefines.get(app.toLowerCase()); if (appDefine == null) { throw new IllegalArgumentException("The app " + app + " not support."); diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/ExcelImExportServiceImpl.java b/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/ExcelImExportServiceImpl.java index b3802dd7f0f..671d2a6a4a0 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/ExcelImExportServiceImpl.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/ExcelImExportServiceImpl.java @@ -30,6 +30,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; @@ -43,7 +44,6 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.RegionUtil; import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; /** * Configure the import and export EXCEL format @@ -89,14 +89,14 @@ public List parseImport(InputStream is) { continue; } String name = getCellValueAsString(row.getCell(0)); - if (StringUtils.hasText(name)) { + if (StringUtils.isNotBlank(name)) { startRowList.add(row.getRowNum()); MonitorDTO monitor = extractMonitorDataFromRow(row); ExportMonitorDTO exportMonitor = new ExportMonitorDTO(); exportMonitor.setMonitor(monitor); monitors.add(exportMonitor); String metrics = getCellValueAsString(row.getCell(11)); - if (StringUtils.hasText(metrics)) { + if (StringUtils.isNotBlank(metrics)) { List metricList = Arrays.stream(metrics.split(",")).collect(Collectors.toList()); exportMonitor.setMetrics(metricList); } @@ -145,7 +145,7 @@ private MonitorDTO extractMonitorDataFromRow(Row row) { monitor.setDescription(getCellValueAsString(row.getCell(5))); String tagsString = getCellValueAsString(row.getCell(6)); - if (StringUtils.hasText(tagsString)) { + if (StringUtils.isNotBlank(tagsString)) { List tags = Arrays.stream(tagsString.split(",")) .map(Long::parseLong) .collect(Collectors.toList()); @@ -159,7 +159,7 @@ private MonitorDTO extractMonitorDataFromRow(Row row) { private ParamDTO extractParamDataFromRow(Row row) { String fieldName = getCellValueAsString(row.getCell(8)); - if (StringUtils.hasText(fieldName)) { + if (StringUtils.isNotBlank(fieldName)) { ParamDTO param = new ParamDTO(); param.setField(fieldName); param.setType(getCellValueAsByte(row.getCell(9))); diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/MonitorServiceImpl.java b/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/MonitorServiceImpl.java index f0b84dedef5..cd0ea218b9f 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/MonitorServiceImpl.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/MonitorServiceImpl.java @@ -37,6 +37,7 @@ import java.util.Set; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.alert.dao.AlertDefineBindDao; import org.apache.hertzbeat.collector.dispatch.DispatchConstants; import org.apache.hertzbeat.common.constants.CommonConstants; @@ -87,7 +88,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; import org.springframework.web.multipart.MultipartFile; /** @@ -214,7 +214,7 @@ public void addMonitor(Monitor monitor, List params, String collector) th }).collect(Collectors.toList()); appDefine.setConfigmap(configmaps); - long jobId = !StringUtils.hasText(collector) ? collectJobScheduling.addAsyncCollectJob(appDefine, null) : + long jobId = StringUtils.isBlank(collector) ? collectJobScheduling.addAsyncCollectJob(appDefine, null) : collectJobScheduling.addAsyncCollectJob(appDefine, collector); try { @@ -361,7 +361,7 @@ public void validate(MonitorDto monitorDto, Boolean isModify) throws IllegalArgu monitor.setTags(monitor.getTags().stream().distinct().collect(Collectors.toList())); } // the dispatch collector must exist if pin - if (StringUtils.hasText(monitorDto.getCollector())) { + if (StringUtils.isNotBlank(monitorDto.getCollector())) { Optional optionalCollector = collectorDao.findCollectorByName(monitorDto.getCollector()); if (optionalCollector.isEmpty()) { throw new IllegalArgumentException("The pinned collector does not exist."); @@ -378,7 +378,7 @@ public void validate(MonitorDto monitorDto, Boolean isModify) throws IllegalArgu if (paramDefine.isRequired() && (param == null || param.getParamValue() == null)) { throw new IllegalArgumentException("Params field " + field + " is required."); } - if (param != null && param.getParamValue() != null && StringUtils.hasText(param.getParamValue())) { + if (param != null && param.getParamValue() != null && StringUtils.isNotBlank(param.getParamValue())) { switch (paramDefine.getType()) { case "number": double doubleValue; @@ -654,7 +654,7 @@ public Page getMonitors(List monitorIds, String app, String name, } andList.add(inPredicate); } - if (StringUtils.hasText(app)) { + if (StringUtils.isNotBlank(app)) { Predicate predicateApp = criteriaBuilder.equal(root.get("app"), app); andList.add(predicateApp); } @@ -663,7 +663,7 @@ public Page getMonitors(List monitorIds, String app, String name, andList.add(predicateStatus); } - if (StringUtils.hasText(tag)) { + if (StringUtils.isNotBlank(tag)) { String[] tagArr = tag.split(":"); String tagName = tagArr[0]; ListJoin tagJoin = root @@ -681,11 +681,11 @@ public Page getMonitors(List monitorIds, String app, String name, Predicate andPredicate = criteriaBuilder.and(andList.toArray(andPredicates)); List orList = new ArrayList<>(); - if (StringUtils.hasText(host)) { + if (StringUtils.isNotBlank(host)) { Predicate predicateHost = criteriaBuilder.like(root.get("host"), "%" + host + "%"); orList.add(predicateHost); } - if (StringUtils.hasText(name)) { + if (StringUtils.isNotBlank(name)) { Predicate predicateName = criteriaBuilder.like(root.get("name"), "%" + name + "%"); orList.add(predicateName); } @@ -748,7 +748,7 @@ public void enableManageMonitors(HashSet ids) { List configmaps = params.stream().map(param -> new Configmap(param.getField(), param.getParamValue(), param.getType())).collect(Collectors.toList()); List paramDefaultValue = appDefine.getParams().stream() - .filter(item -> StringUtils.hasText(item.getDefaultValue())) + .filter(item -> StringUtils.isNotBlank(item.getDefaultValue())) .toList(); paramDefaultValue.forEach(defaultVar -> { if (configmaps.stream().noneMatch(item -> item.getKey().equals(defaultVar.getField()))) { @@ -854,7 +854,7 @@ public void updateAppCollectJob(Job job) { List configmaps = params.stream().map(param -> new Configmap(param.getField(), param.getParamValue(), param.getType())).collect(Collectors.toList()); List paramDefaultValue = appDefine.getParams().stream() - .filter(item -> StringUtils.hasText(item.getDefaultValue())) + .filter(item -> StringUtils.isNotBlank(item.getDefaultValue())) .toList(); paramDefaultValue.forEach(defaultVar -> { if (configmaps.stream().noneMatch(item -> item.getKey().equals(defaultVar.getField()))) { diff --git a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/DingTalkRobotAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/DingTalkRobotAlertNotifyHandlerImplTest.java index a89afc771d0..8d4bfb25563 100644 --- a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/DingTalkRobotAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/DingTalkRobotAlertNotifyHandlerImplTest.java @@ -21,13 +21,13 @@ import java.util.HashMap; import java.util.Map; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.alerter.Alert; import org.apache.hertzbeat.common.entity.manager.NoticeReceiver; import org.apache.hertzbeat.common.entity.manager.NoticeTemplate; import org.apache.hertzbeat.manager.AbstractSpringIntegrationTest; import org.junit.jupiter.api.Test; -import org.springframework.util.StringUtils; /** * Test case for {@link DingTalkRobotAlertNotifyHandlerImpl} @@ -41,7 +41,7 @@ class DingTalkRobotAlertNotifyHandlerImplTest extends AbstractSpringIntegrationT @Test void send() { String ddAccessToken = System.getenv("DD_ACCESS_TOKEN"); - if (!StringUtils.hasText(ddAccessToken)) { + if (StringUtils.isBlank(ddAccessToken)) { log.warn("Please provide environment variables DD_ACCESS_TOKEN"); return; } diff --git a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/DiscordBotAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/DiscordBotAlertNotifyHandlerImplTest.java index 04d56739907..ff5ca3436db 100644 --- a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/DiscordBotAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/DiscordBotAlertNotifyHandlerImplTest.java @@ -20,13 +20,13 @@ import jakarta.annotation.Resource; import java.util.Map; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.alerter.Alert; import org.apache.hertzbeat.common.entity.manager.NoticeReceiver; import org.apache.hertzbeat.common.entity.manager.NoticeTemplate; import org.apache.hertzbeat.manager.AbstractSpringIntegrationTest; import org.junit.jupiter.api.Test; -import org.springframework.util.StringUtils; /** * Test case for {@link DiscordBotAlertNotifyHandlerImpl} @@ -41,7 +41,7 @@ class DiscordBotAlertNotifyHandlerImplTest extends AbstractSpringIntegrationTest void send() { var discordChannelId = System.getenv("DISCORD_CHANNEL_ID"); var discordBotToken = System.getenv("DISCORD_BOT_TOKEN"); - if (!StringUtils.hasText(discordChannelId) || !StringUtils.hasText(discordBotToken)) { + if (StringUtils.isBlank(discordChannelId) || StringUtils.isBlank(discordBotToken)) { log.warn("Please provide environment variables DISCORD_CHANNEL_ID, DISCORD_BOT_TOKEN"); return; } diff --git a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImplTest.java index f66bc82cec6..e6bd03da37b 100644 --- a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImplTest.java @@ -21,13 +21,13 @@ import java.util.HashMap; import java.util.Map; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.alerter.Alert; import org.apache.hertzbeat.common.entity.manager.NoticeReceiver; import org.apache.hertzbeat.common.entity.manager.NoticeTemplate; import org.apache.hertzbeat.manager.AbstractSpringIntegrationTest; import org.junit.jupiter.api.Test; -import org.springframework.util.StringUtils; /** * Test case for {@link FlyBookAlertNotifyHandlerImpl} @@ -41,7 +41,7 @@ class FlyBookAlertNotifyHandlerImplTest extends AbstractSpringIntegrationTest { @Test void send() { String flyBookId = System.getenv("FLY_BOOK_ID"); - if (!StringUtils.hasText(flyBookId)) { + if (StringUtils.isBlank(flyBookId)) { log.warn("Please provide environment variables FLY_BOOK_ID"); return; } diff --git a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/HuaweiCloudSmnAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/HuaweiCloudSmnAlertNotifyHandlerImplTest.java index fb19e220d20..8b6d697789e 100644 --- a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/HuaweiCloudSmnAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/HuaweiCloudSmnAlertNotifyHandlerImplTest.java @@ -18,13 +18,13 @@ import jakarta.annotation.Resource; import java.util.Map; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.alerter.Alert; import org.apache.hertzbeat.common.entity.manager.NoticeReceiver; import org.apache.hertzbeat.common.entity.manager.NoticeTemplate; import org.apache.hertzbeat.manager.AbstractSpringIntegrationTest; import org.junit.jupiter.api.Test; -import org.springframework.util.StringUtils; /** * Test case for {@link HuaweiCloudSmnAlertNotifyHandlerImpl} @@ -38,27 +38,27 @@ class HuaweiCloudSmnAlertNotifyHandlerImplTest extends AbstractSpringIntegration @Test void send() throws InterruptedException { var smnProjectId = System.getenv("SMN_PROJECT_ID"); - if (!StringUtils.hasText(smnProjectId)) { + if (StringUtils.isBlank(smnProjectId)) { log.warn("Please provide environment variables SMN_PROJECT_ID"); return; } var smnAk = System.getenv("SMN_AK"); - if (!StringUtils.hasText(smnAk)) { + if (StringUtils.isBlank(smnAk)) { log.warn("Please provide environment variables SMN_AK"); return; } var smnSk = System.getenv("SMN_SK"); - if (!StringUtils.hasText(smnSk)) { + if (StringUtils.isBlank(smnSk)) { log.warn("Please provide environment variables SMN_SK"); return; } var smnRegion = System.getenv("SMN_REGION"); - if (!StringUtils.hasText(smnRegion)) { + if (StringUtils.isBlank(smnRegion)) { log.warn("Please provide environment variables SMN_REGION"); return; } var smnTopicUrn = System.getenv("SMN_TOPIC_URN"); - if (!StringUtils.hasText(smnTopicUrn)) { + if (StringUtils.isBlank(smnTopicUrn)) { log.warn("Please provide environment variables SMN_TOPIC_URN"); return; } diff --git a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/SlackAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/SlackAlertNotifyHandlerImplTest.java index 6bb188f0bfc..074c0bf128a 100644 --- a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/SlackAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/SlackAlertNotifyHandlerImplTest.java @@ -20,13 +20,13 @@ import jakarta.annotation.Resource; import java.util.Map; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.alerter.Alert; import org.apache.hertzbeat.common.entity.manager.NoticeReceiver; import org.apache.hertzbeat.common.entity.manager.NoticeTemplate; import org.apache.hertzbeat.manager.AbstractSpringIntegrationTest; import org.junit.jupiter.api.Test; -import org.springframework.util.StringUtils; /** * Test case for {@link SlackAlertNotifyHandlerImpl} @@ -41,7 +41,7 @@ class SlackAlertNotifyHandlerImplTest extends AbstractSpringIntegrationTest { @Test void send() { var slackWebHook = System.getenv("SLACK_WEB_HOOK"); - if (!StringUtils.hasText(slackWebHook)) { + if (StringUtils.isBlank(slackWebHook)) { log.warn("Please provide environment variables SLACK_WEB_HOOK"); return; } diff --git a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/TelegramBotAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/TelegramBotAlertNotifyHandlerImplTest.java index 62183b0a8d6..caa8d94972a 100644 --- a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/TelegramBotAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/TelegramBotAlertNotifyHandlerImplTest.java @@ -21,13 +21,13 @@ import java.util.HashMap; import java.util.Map; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.alerter.Alert; import org.apache.hertzbeat.common.entity.manager.NoticeReceiver; import org.apache.hertzbeat.common.entity.manager.NoticeTemplate; import org.apache.hertzbeat.manager.AbstractSpringIntegrationTest; import org.junit.jupiter.api.Test; -import org.springframework.util.StringUtils; /** * Test case for {@link TelegramBotAlertNotifyHandlerImpl} @@ -43,7 +43,7 @@ class TelegramBotAlertNotifyHandlerImplTest extends AbstractSpringIntegrationTes void send() { String tgBotToken = System.getenv("TG_BOT_TOKEN"); String tgUserId = System.getenv("TG_USER_ID"); - if (!StringUtils.hasText(tgBotToken) || !StringUtils.hasText(tgUserId)) { + if (StringUtils.isBlank(tgBotToken) || StringUtils.isBlank(tgUserId)) { log.warn("Please provide environment variables TG_BOT_TOKEN, TG_USER_ID"); return; } diff --git a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/WeChatAppAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/WeChatAppAlertNotifyHandlerImplTest.java index 13d4d0770f5..8bb6a7016b9 100644 --- a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/WeChatAppAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/WeChatAppAlertNotifyHandlerImplTest.java @@ -21,13 +21,13 @@ import java.util.HashMap; import java.util.Map; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.alerter.Alert; import org.apache.hertzbeat.common.entity.manager.NoticeReceiver; import org.apache.hertzbeat.common.entity.manager.NoticeTemplate; import org.apache.hertzbeat.manager.AbstractSpringIntegrationTest; import org.junit.jupiter.api.Test; -import org.springframework.util.StringUtils; /** * unit test case for WeChatAppAlertNotifyHandlerImpl @@ -43,7 +43,7 @@ public void send() { String corpId = System.getenv("CORP_ID"); String agentId = System.getenv("AGENT_ID"); String appSecret = System.getenv("APP_SECRET"); - if (!StringUtils.hasText(corpId) || !StringUtils.hasText(agentId) || !StringUtils.hasText(appSecret)) { + if (StringUtils.isBlank(corpId) || StringUtils.isBlank(agentId) || StringUtils.isBlank(appSecret)) { log.warn("Please provide environment variables CORP_ID, TG_USER_ID APP_SECRET"); return; } diff --git a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/WeComRobotAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/WeComRobotAlertNotifyHandlerImplTest.java index 23b8ff110d5..08de0ed3054 100644 --- a/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/WeComRobotAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/apache/hertzbeat/manager/component/alerter/impl/WeComRobotAlertNotifyHandlerImplTest.java @@ -21,13 +21,13 @@ import java.util.HashMap; import java.util.Map; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.constants.CommonConstants; import org.apache.hertzbeat.common.entity.alerter.Alert; import org.apache.hertzbeat.common.entity.manager.NoticeReceiver; import org.apache.hertzbeat.common.entity.manager.NoticeTemplate; import org.apache.hertzbeat.manager.AbstractSpringIntegrationTest; import org.junit.jupiter.api.Test; -import org.springframework.util.StringUtils; /** * Test case for {@link WeComRobotAlertNotifyHandlerImpl} @@ -41,7 +41,7 @@ class WeComRobotAlertNotifyHandlerImplTest extends AbstractSpringIntegrationTest @Test void send() { String weWorkKey = System.getenv("WE_WORK_KEY"); - if (!StringUtils.hasText(weWorkKey)) { + if (StringUtils.isBlank(weWorkKey)) { log.warn("Please provide environment variables WE_WORK_KEY"); return; }