soreana commented on code in PR #8137:
URL: https://github.com/apache/cloudstack/pull/8137#discussion_r1378610749


##########
plugins/network-elements/juniper-contrail/src/test/java/org/apache/cloudstack/network/contrail/model/InstanceIpModelTest.java:
##########
@@ -56,14 +56,7 @@ public void testCreateInstanceIp() throws IOException {
         when(controller.getManager()).thenReturn(contrailMgr);
 
         // Create Virtual-Network (VN)
-        NetworkVO network = mock(NetworkVO.class);
-        when(network.getName()).thenReturn("testnetwork");
-        when(network.getState()).thenReturn(Network.State.Implemented);
-        when(network.getGateway()).thenReturn("10.1.1.1");
-        when(network.getCidr()).thenReturn("10.1.1.0/24");
-        when(network.getPhysicalNetworkId()).thenReturn(42L);
-        when(network.getDomainId()).thenReturn(10L);
-        when(network.getAccountId()).thenReturn(42L);
+        NetworkVO network =  new 
MockNetworkVO(Network.State.Implemented).getNetwork();

Review Comment:
   This usage of `new` followed by invoking a method is considered a poor 
coding convention. Could you kindly consider modifying it?
   
   I have two suggestions feel free to apply any of them or use any other 
approach.
   
   1. Consider adding a `static method` to the MockNetworkVO class that 
generates a MockNetworkVO rather than using new everytime.
   2. Employ the `builder design` pattern to generate the MockNetworkVO. Begin 
by implementing a builder class called MockNetworkVOBuilder. Within this class, 
introduce a method that constructs a MockNetworkVO using specified parameters.



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