diff --git a/dsms-engine-application/src/test/java/com/dsms/common/util/PrometheusUtilTest.java b/dsms-engine-application/src/test/java/com/dsms/common/util/PrometheusUtilTest.java index 520c17593c9974e6b70f1e23ab1ef66a6a4af13e..c1cbfc1171b6941b907294eabe75c2e1caa93904 100644 --- a/dsms-engine-application/src/test/java/com/dsms/common/util/PrometheusUtilTest.java +++ b/dsms-engine-application/src/test/java/com/dsms/common/util/PrometheusUtilTest.java @@ -3,14 +3,25 @@ package com.dsms.common.util; import static org.junit.jupiter.api.Assertions.assertEquals; import com.dsms.common.constant.PromQL; +import com.google.gson.JsonSyntaxException; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -class PrometheusUtilTest { +class PrometheusUtilsTest { @Test - public void testPrometheusUtil() { + public void testPrometheusUtils() { String exceptResult = "rate(node_network_receive_drop_total{instance=\"ceph1\"}[1m])"; assertEquals(exceptResult, PrometheusUtils.getFormatPromQL(PromQL.NODE_NETWORK_RECEIVE_DROP_RATE, new String[]{"ceph1"})); + + + String noData = "{\"status\":\"success\",\"data1\":{\"resultType\":\"vector\",\"result\":[{\"metric\":{},\"values\":[1742977682.864,\"+Inf\"]}]}}"; + Assertions.assertThrows(JsonSyntaxException.class, () -> PrometheusUtils.convertQueryResultString(noData)); + + + String noResultType = "{\"status\":\"success\",\"data\":{\"resultType\":\"test\",\"result1\":[{\"metric\":{},\"values1\":[1742977682.864,\"+Inf\"]}]}}"; + Assertions.assertThrows(JsonSyntaxException.class, () -> PrometheusUtils.convertQueryResultString(noResultType)); + } } \ No newline at end of file