Conversation
Codecov Report
@@ Coverage Diff @@
## main #8137 +/- ##
============================================
+ Coverage 28.15% 29.20% +1.05%
- Complexity 29181 31016 +1835
============================================
Files 5111 5181 +70
Lines 360669 365099 +4430
Branches 52700 53420 +720
============================================
+ Hits 101562 106644 +5082
+ Misses 245113 243839 -1274
- Partials 13994 14616 +622
Flags with carried forward coverage won't be shown. Click here to find out more. see 444 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
...rail/src/test/java/org/apache/cloudstack/network/contrail/model/VirtualNetworkModelTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: dahn <daan.hoogland@gmail.com>
|
@blueorangutan package |
|
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
lot of failed checks |
|
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 7512 |
| when(network.getPhysicalNetworkId()).thenReturn(42L); | ||
| when(network.getDomainId()).thenReturn(10L); | ||
| when(network.getAccountId()).thenReturn(42L); | ||
| NetworkVO network = new MockNetworkVO(Network.State.Implemented).getNetwork(); |
There was a problem hiding this 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.
- Consider adding a
static methodto the MockNetworkVO class that generates a MockNetworkVO rather than using new everytime. - Employ the
builder designpattern 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.
There was a problem hiding this comment.
Thanks for the advice, I used the first method.
adding a static method to the MockNetworkVO class that generates a MockNetworkVO rather than using new everytime.
* refactor MockNetworkVO * Apply suggestions from code review Co-authored-by: dahn <daan.hoogland@gmail.com> * adding static adding a static method to the MockNetworkVO class that generates a MockNetworkVO rather than using new everytime. --------- Co-authored-by: dahn <daan.hoogland@gmail.com>
Description
This PR addresses a problem similar to the one mentioned in Issue #8087 by adopting the same solution approach used in PR #8098. Specifically, it refactors the mock object creation for
NetworkVOacross test suites of four classes:InstanceIpModelTest.java,VirtualMachineModelTest.java,VirtualNetworkModelTest.java, and thetestCreateVMInterfacemethod in another class. The central concern is the repetitive mock object creations forNetworkVO.Proposed Changes
Following the methodology from PR #8098, I've introduced a new and reusable
MockNetworkVOclass. This class is designated for creatingNetworkVOmock objects with consistent behavior, aiming to eliminate redundancy.Benefits of the Proposed Refactoring:
NetworkVOmock creation process in the future, adjustments will only be necessary within theMockNetworkVOclass. This centralizes modifications instead of scattering them across multiple test classes.Fixes: Similar Issue to #8087