pandaapo commented on code in PR #4139:
URL: https://github.com/apache/eventmesh/pull/4139#discussion_r1235531431


##########
eventmesh-admin/eventmesh-admin-rocketmq/src/test/java/org/apache/eventmesh/admin/rocketmq/util/UrlMappingPatternTest.java:
##########
@@ -86,8 +88,21 @@ public void testGetParamNames() {
     }
 
     @Test
-    public void testCompile() {
-        //TODO : Fix me to test the method compile(). It is better using 
Mockito not PowerMockito.
+    public void testCompile() throws NoSuchFieldException, 
IllegalAccessException {
+        // Mock the compiledUrlMappingPattern field with reflection
+        Pattern mockedPattern = mock(Pattern.class);
+        Field compiledUrlMappingPatternField = 
urlMappingPattern.getClass().getDeclaredField("compiledUrlMappingPattern");
+        compiledUrlMappingPatternField.setAccessible(true);
+        compiledUrlMappingPatternField.set(urlMappingPattern, mockedPattern);

Review Comment:
   It seems unnecessary to `mock(Pattern.class)` for the field 
`compiledUrlMappingPattern` again. Because `compiledUrlMappingPattern` has 
already been mocked.
   You can use reflection to obtain and directly use the 
`compiledUrlMappingPattern` field.



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