XiaoyangCai360 commented on code in PR #7802:
URL: https://github.com/apache/incubator-seata/pull/7802#discussion_r2558689662


##########
rm-datasource/src/test/java/org/apache/seata/rm/datasource/ConnectionContextProxyTest.java:
##########
@@ -131,15 +145,29 @@ public void testReleaseSavepoint() {
         connectionContext.appendUndoItem(new SQLUndoLog());
 
         Assertions.assertEquals(connectionContext.getUndoItems().size(), 2);
-        Assertions.assertEquals(connectionContext.buildLockKeys(), 
"sp3-lock-key;sp1-lock-key");
+
+        List<String> expectedKeysList = Arrays.asList("sp1-lock-key", 
"sp3-lock-key");
+
+        String actualKeys1 = connectionContext.buildLockKeys();
+        List<String> actualKeysList1 = new 
ArrayList<>(Arrays.asList(actualKeys1.split(";")));
+        Collections.sort(actualKeysList1);
+        Assertions.assertEquals(expectedKeysList, actualKeysList1);
 
         connectionContext.releaseSavepoint(sp3);
         Assertions.assertEquals(connectionContext.getUndoItems().size(), 2);
-        Assertions.assertEquals(connectionContext.buildLockKeys(), 
"sp3-lock-key;sp1-lock-key");
+
+        String actualKeys2 = connectionContext.buildLockKeys();
+        List<String> actualKeysList2 = new 
ArrayList<>(Arrays.asList(actualKeys2.split(";")));
+        Collections.sort(actualKeysList2);
+        Assertions.assertEquals(expectedKeysList, actualKeysList2);
 
         connectionContext.releaseSavepoint(null);
         Assertions.assertEquals(connectionContext.getUndoItems().size(), 2);
-        Assertions.assertEquals(connectionContext.buildLockKeys(), 
"sp3-lock-key;sp1-lock-key");
+
+        String actualKeys3 = connectionContext.buildLockKeys();
+        List<String> actualKeysList3 = new 
ArrayList<>(Arrays.asList(actualKeys3.split(";")));
+        Collections.sort(actualKeysList3);
+        Assertions.assertEquals(expectedKeysList, actualKeysList3);
     }

Review Comment:
   Thanks for the excellent suggestion! I agree that extracting the logic 
improves code quality. I have implemented the common comparison logic helper 
function and refactored the tests to use it. Please review the updated changes 
at your convenience. Let me know if you have any other feedback!



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to