vishesh92 commented on code in PR #7645:
URL: https://github.com/apache/cloudstack/pull/7645#discussion_r1334404336


##########
api/src/test/java/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmdTest.java:
##########
@@ -71,12 +82,9 @@ public void validateCidrsTestValidCidrs(){
         Mockito.verify(networkServiceMock).getNetwork(networkIdMock);
         Mockito.verify(networkMock).getCidr();
 
-        PowerMockito.verifyStatic(NetUtils.class, Mockito.times(2));
-        NetUtils.isValidIp4Cidr(cidrMock);
-        NetUtils.isValidIp6Cidr(cidrMock);
-
-        PowerMockito.verifyStatic(NetUtils.class);
-        NetUtils.isNetworkAWithinNetworkB(cidrMock,cidrMock);
+        netUtilsMocked.verify(() -> NetUtils.isValidIp4Cidr(cidrMock), 
Mockito.times(2));
+        netUtilsMocked.verify(() -> NetUtils.isValidIp6Cidr(cidrMock), 
Mockito.never());

Review Comment:
   We don't need the mock for `isValidIp6Cidr` either. It gets called in the 
below code snippet. Since `isValidIp4Cidr` returns true, there is no need for 
`isValidIp6Cidr` to get called.
   
![image](https://github.com/apache/cloudstack/assets/8760112/4ea099b5-aca9-447d-902b-1b8f04e1eca9)
   
   Regarding why it was working earlier, I am not sure. Couldn't find any 
similar example in the docs for powermock where two methods after called after 
`verifyStatic`.
   I think powermock probably saw `isValidIp4Cidr` execution two times and 
`isValidIp6Cidr` none. So, total count in the end was two which is correct.



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