wu-sheng commented on code in PR #10990:
URL: https://github.com/apache/skywalking/pull/10990#discussion_r1241049386


##########
oap-server/server-library/library-util/src/test/java/org/apache/skywalking/oap/server/library/util/StringUtilTest.java:
##########
@@ -76,4 +76,12 @@ public void testTrim() {
         assertEquals(StringUtil.trim("abcdef", 'a'), "bcdef");
         assertEquals(StringUtil.trim("abcdef", 'f'), "abcde");
     }
+
+    @Test
+    public void testTrimJson() {
+        String jsonString = 
"{\"k1\":\"v1\",\"k2\":\"v2\",\"k3\":true,\"k4\":[{\"a\":\"b\",\"c\":\"d\"},{\"e\":\"f\",\"g\":\"h\"}]}";
+        assertEquals(StringUtil.trimJson(jsonString, 10), 
"{\"k1\":\"v1\",\"k2\":\"v2\"}");
+        assertEquals(StringUtil.trimJson(jsonString, 30), 
"{\"k1\":\"v1\",\"k2\":\"v2\",\"k3\":true}");
+    }

Review Comment:
   I think we should verify whether the size of the trimmed JSON str oversized.



##########
oap-server/server-library/library-util/src/test/java/org/apache/skywalking/oap/server/library/util/StringUtilTest.java:
##########
@@ -76,4 +76,12 @@ public void testTrim() {
         assertEquals(StringUtil.trim("abcdef", 'a'), "bcdef");
         assertEquals(StringUtil.trim("abcdef", 'f'), "abcde");
     }
+
+    @Test
+    public void testTrimJson() {
+        String jsonString = 
"{\"k1\":\"v1\",\"k2\":\"v2\",\"k3\":true,\"k4\":[{\"a\":\"b\",\"c\":\"d\"},{\"e\":\"f\",\"g\":\"h\"}]}";
+        assertEquals(StringUtil.trimJson(jsonString, 10), 
"{\"k1\":\"v1\",\"k2\":\"v2\"}");
+        assertEquals(StringUtil.trimJson(jsonString, 30), 
"{\"k1\":\"v1\",\"k2\":\"v2\",\"k3\":true}");
+    }

Review Comment:
   I think we should verify whether the size of the trimmed JSON str is 
oversized.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to