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 e78284af fix: fail explicitly when dashboard provider is missing (#699)
e78284af is described below
commit e78284af6e3441f0700bd6253ee85851a118fe56
Author: aias00 <[email protected]>
AuthorDate: Sun Aug 2 20:09:42 2026 -0700
fix: fail explicitly when dashboard provider is missing (#699)
---
.../ops/dashboard/DashboardProviderStub.java | 76 ++--------------------
.../ops/dashboard/DashboardProviderStubTest.java | 36 ++++++++++
2 files changed, 41 insertions(+), 71 deletions(-)
diff --git
a/server/src/main/java/org/apache/rocketmq/studio/ops/dashboard/DashboardProviderStub.java
b/server/src/main/java/org/apache/rocketmq/studio/ops/dashboard/DashboardProviderStub.java
index f9ab8997..83c67f8a 100644
---
a/server/src/main/java/org/apache/rocketmq/studio/ops/dashboard/DashboardProviderStub.java
+++
b/server/src/main/java/org/apache/rocketmq/studio/ops/dashboard/DashboardProviderStub.java
@@ -17,83 +17,17 @@
package org.apache.rocketmq.studio.ops.dashboard;
-import org.apache.rocketmq.studio.common.domain.enums.ClusterStatus;
-import org.apache.rocketmq.studio.common.domain.enums.ClusterType;
+import org.apache.rocketmq.studio.common.exception.BusinessException;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
-import java.util.Arrays;
-import java.util.List;
-
+@Slf4j
@Component
public class DashboardProviderStub implements DashboardProvider {
@Override
public DashboardDataVO getDashboardData() {
- DashboardStatsVO stats = DashboardStatsVO.builder()
- .totalClusters(3)
- .healthyClusters(2)
- .totalBrokers(12)
- .totalProxies(6)
- .totalNameServers(6)
- .totalTopics(156)
- .totalConsumerGroups(89)
- .totalMessagesToday(12_500_000L)
- .messagesPerSecond(14_467L)
- .tpsIn(7_200L)
- .tpsOut(7_267L)
- .build();
-
- List<ClusterOverviewVO> clusters = List.of(
- ClusterOverviewVO.builder()
- .id("cluster-1")
- .name("production-cluster")
- .type(ClusterType.V5_PROXY_CLUSTER)
- .status(ClusterStatus.healthy)
- .brokers(6)
- .proxies(3)
- .topics(80)
- .groups(45)
- .tpsIn(4200)
- .tpsOut(4300)
- .version("5.1.4")
- .throughput(Arrays.asList(3200, 3500, 4100, 4200,
3800, 4000,
- 4500, 4200, 3900, 4100, 4300, 4200))
- .build(),
- ClusterOverviewVO.builder()
- .id("cluster-2")
- .name("staging-cluster")
- .type(ClusterType.V5_PROXY_LOCAL)
- .status(ClusterStatus.warning)
- .brokers(4)
- .proxies(2)
- .topics(50)
- .groups(30)
- .tpsIn(2000)
- .tpsOut(1967)
- .version("5.1.4")
- .throughput(Arrays.asList(1800, 1900, 2100, 2000,
1700, 2200,
- 2000, 1800, 1900, 2100, 2000, 1967))
- .build(),
- ClusterOverviewVO.builder()
- .id("cluster-3")
- .name("dev-cluster")
- .type(ClusterType.V4_DIRECT)
- .status(ClusterStatus.healthy)
- .brokers(2)
- .proxies(1)
- .topics(26)
- .groups(14)
- .tpsIn(1000)
- .tpsOut(1000)
- .version("4.9.8")
- .throughput(Arrays.asList(800, 900, 1100, 1000, 950,
1050,
- 1000, 900, 1100, 1000, 950, 1000))
- .build()
- );
-
- return DashboardDataVO.builder()
- .stats(stats)
- .clusters(clusters)
- .build();
+ log.warn("DashboardProviderStub.getDashboardData called without a real
dashboard provider");
+ throw new BusinessException(501, "Dashboard provider is not
configured");
}
}
diff --git
a/server/src/test/java/org/apache/rocketmq/studio/ops/dashboard/DashboardProviderStubTest.java
b/server/src/test/java/org/apache/rocketmq/studio/ops/dashboard/DashboardProviderStubTest.java
new file mode 100644
index 00000000..50bcf6f1
--- /dev/null
+++
b/server/src/test/java/org/apache/rocketmq/studio/ops/dashboard/DashboardProviderStubTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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 org.apache.rocketmq.studio.ops.dashboard;
+
+import org.apache.rocketmq.studio.common.exception.BusinessException;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class DashboardProviderStubTest {
+
+ private final DashboardProviderStub provider = new DashboardProviderStub();
+
+ @Test
+ void getDashboardDataShouldFailWhenRealProviderIsMissing() {
+ assertThatThrownBy(provider::getDashboardData)
+ .isInstanceOf(BusinessException.class)
+ .hasMessage("Dashboard provider is not configured")
+ .satisfies(ex -> assertThat(((BusinessException)
ex).getCode()).isEqualTo(501));
+ }
+}