This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new a460673fb fix(alert): name the exercised channel in the test 
notification (#5077)
a460673fb is described below

commit a460673fb5b1c61b06f06bac5e48428bb479fa07
Author: Apulupie <[email protected]>
AuthorDate: Thu Oct 1 18:33:39 2026 +0800

    fix(alert): name the exercised channel in the test notification (#5077)
---
 .../ops/alert/NotificationOutboxService.java       | 10 ++++++++--
 .../ops/alert/NotificationOutboxServiceTest.java   | 23 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/ops/alert/NotificationOutboxService.java
 
b/server/src/main/java/org/apache/rocketmq/studio/ops/alert/NotificationOutboxService.java
index fd8806f2b..760a5c974 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/ops/alert/NotificationOutboxService.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/ops/alert/NotificationOutboxService.java
@@ -70,6 +70,12 @@ public class NotificationOutboxService {
     private static final int MAX_HEARTBEAT_THREADS = 4;
     private static final ObjectMapper JSON = new ObjectMapper();
 
+    /** The test message must name the channel it exercises, not always 
DingTalk. */
+    private static final Map<String, String> TEST_MESSAGE_DESCRIPTIONS = 
Map.of(
+            "dingtalk", "DingTalk notification configuration is working.",
+            "email", "Email notification configuration is working.",
+            "sms", "SMS notification configuration is working.");
+
     private final RmqAlertNotificationOutboxMapper mapper;
     private final SettingsRepository settingsRepository;
     private final AlertSilenceService silenceService;
@@ -157,8 +163,8 @@ public class NotificationOutboxService {
         }
         GeneralSettingsVO settings = settingsRepository.loadGeneralSettings();
         SystemAlertVO alert = 
SystemAlertVO.builder().level(org.apache.rocketmq.studio.common.domain.enums.AlertLevel.info)
-                .title("RocketMQ Studio test 
notification").description("DingTalk notification configuration is working.")
-                .build();
+                .title("RocketMQ Studio test notification")
+                .description(TEST_MESSAGE_DESCRIPTIONS.get(channel)).build();
         try {
             String content = AlertNotificationTemplate.render(null, alert, 
null);
             if ("email".equals(channel)) sendEmail(settings, alert, content);
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/ops/alert/NotificationOutboxServiceTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/ops/alert/NotificationOutboxServiceTest.java
index d12defcdc..aea9578c0 100644
--- 
a/server/src/test/java/org/apache/rocketmq/studio/ops/alert/NotificationOutboxServiceTest.java
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/ops/alert/NotificationOutboxServiceTest.java
@@ -878,4 +878,27 @@ class NotificationOutboxServiceTest {
         verify(audit, never()).record(any(), any(), any(), any(), any(), 
any(), any());
         verify(heartbeatFuture).cancel(false);
     }
+
+    @Test
+    void messageNamesTheChannelItExercisesTest() {
+        RmqAlertNotificationOutboxMapper mapper = 
mock(RmqAlertNotificationOutboxMapper.class);
+        SettingsRepository settings = mock(SettingsRepository.class);
+        RestTemplate client = new RestTemplate();
+        MockRestServiceServer server = 
MockRestServiceServer.bindTo(client).build();
+        
when(settings.loadGeneralSettings()).thenReturn(GeneralSettingsVO.builder()
+                .smsWebhook("https://example.com/sms";).build());
+        server.expect(once(), requestTo("https://example.com/sms";))
+                .andExpect(method(org.springframework.http.HttpMethod.POST))
+                .andExpect(content().string(org.hamcrest.Matchers
+                        .containsString("SMS notification configuration is 
working.")))
+                .andExpect(content().string(org.hamcrest.Matchers
+                        
.not(org.hamcrest.Matchers.containsString("DingTalk"))))
+                .andRespond(withSuccess("{\"code\":200}", 
MediaType.APPLICATION_JSON));
+
+        new NotificationOutboxService(mapper, settings, 
mock(AlertSilenceService.class),
+                mock(AlertRepository.class), mock(OperationAuditService.class),
+                client).sendTestMessage("sms");
+
+        server.verify();
+    }
 }

Reply via email to