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 6d8c5c7d fix(settings): pass instance ids through data source DTOs 
(#1672)
6d8c5c7d is described below

commit 6d8c5c7dcc097adb819b4c37bd22396afe0289a1
Author: youngkermit8-coder <[email protected]>
AuthorDate: Tue Aug 11 20:47:44 2026 +0800

    fix(settings): pass instance ids through data source DTOs (#1672)
    
    Signed-off-by: youngkermit8-coder <[email protected]>
---
 .../org/apache/rocketmq/studio/settings/DataSourceDTO.java |  5 +++++
 .../rocketmq/studio/settings/SettingsControllerTest.java   | 14 +++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/settings/DataSourceDTO.java 
b/server/src/main/java/org/apache/rocketmq/studio/settings/DataSourceDTO.java
index bf9c5fb6..ff7fb9e8 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/settings/DataSourceDTO.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/settings/DataSourceDTO.java
@@ -20,6 +20,8 @@ import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.Pattern;
 import lombok.Data;
 
+import java.util.List;
+
 @Data
 public class DataSourceDTO {
 
@@ -42,6 +44,8 @@ public class DataSourceDTO {
             message = "Unsupported metrics data source authentication")
     private String auth;
 
+    private List<String> instanceIds;
+
     public DataSourceVO toDataSourceVO() {
         return DataSourceVO.builder()
                 .key(key)
@@ -49,6 +53,7 @@ public class DataSourceDTO {
                 .type(type.trim())
                 .url(url)
                 .auth(auth == null ? null : auth.trim())
+                .instanceIds(instanceIds)
                 .build();
     }
 }
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/settings/SettingsControllerTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/settings/SettingsControllerTest.java
index 094ee02e..c27ab702 100644
--- 
a/server/src/test/java/org/apache/rocketmq/studio/settings/SettingsControllerTest.java
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/settings/SettingsControllerTest.java
@@ -27,6 +27,7 @@ import org.springframework.test.web.servlet.MockMvc;
 
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.List;
 
 import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.is;
@@ -190,9 +191,10 @@ class SettingsControllerTest {
     @Test
     void createDataSourceShouldReturnCreatedSource() throws Exception {
         DataSourceVO input = DataSourceVO.builder().name("New 
DS").type("Prometheus")
-                .url("new-host:9876").build();
+                .url("new-host:9876").instanceIds(List.of("instance-a", 
"instance-b")).build();
         DataSourceVO created = DataSourceVO.builder().key("ds-new").name("New 
DS").type("Prometheus")
-                .url("new-host:9876").status("connected").build();
+                .url("new-host:9876").status("connected")
+                .instanceIds(List.of("instance-a", "instance-b")).build();
         
when(settingsService.createDataSource(any(DataSourceVO.class))).thenReturn(created);
 
         mockMvc.perform(post("/api/settings/datasources/create")
@@ -203,6 +205,9 @@ class SettingsControllerTest {
                 .andExpect(jsonPath("$.data.key", is("ds-new")))
                 .andExpect(jsonPath("$.data.name", is("New DS")))
                 .andExpect(jsonPath("$.data.status", is("connected")));
+
+        verify(settingsService).createDataSource(argThat(dataSource ->
+                List.of("instance-a", 
"instance-b").equals(dataSource.getInstanceIds())));
     }
 
     @Test
@@ -274,7 +279,7 @@ class SettingsControllerTest {
     @Test
     void updateDataSourceShouldReturnUpdatedSource() throws Exception {
         DataSourceVO input = DataSourceVO.builder().key("ds-1").name("Updated 
DS").type("Prometheus")
-                .url("updated:9876").build();
+                
.url("updated:9876").instanceIds(List.of("instance-b")).build();
         
when(settingsService.updateDataSource(any(DataSourceVO.class))).thenReturn(input);
 
         mockMvc.perform(post("/api/settings/datasources/update")
@@ -284,6 +289,9 @@ class SettingsControllerTest {
                 .andExpect(jsonPath("$.code", is(200)))
                 .andExpect(jsonPath("$.data.key", is("ds-1")))
                 .andExpect(jsonPath("$.data.name", is("Updated DS")));
+
+        verify(settingsService).updateDataSource(argThat(dataSource ->
+                List.of("instance-b").equals(dataSource.getInstanceIds())));
     }
 
     @Test

Reply via email to