Codegass opened a new pull request, #6676: URL: https://github.com/apache/cloudstack/pull/6676
### Description Fix #6659 This PR introduces Hamcrest API to simplify assertion in [`ImplicitPlannerTest.checkStrictModeWithCurrentAccountVmsPresent`](https://github.com/Codegass/cloudstack/blob/71056191f2bdad4be1a7eaf9bb73a7dcee3516f2/plugins/deployment-planners/implicit-dedication/src/test/java/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java#L199), [`ImplicitPlannerTest.checkStrictModeHostWithCurrentAccountVmsFull`](https://github.com/Codegass/cloudstack/blob/71056191f2bdad4be1a7eaf9bb73a7dcee3516f2/plugins/deployment-planners/implicit-dedication/src/test/java/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java#L233), and [`ImplicitPlannerTest.checkPreferredModePreferredHostAvailable`](https://github.com/Codegass/cloudstack/blob/71056191f2bdad4be1a7eaf9bb73a7dcee3516f2/plugins/deployment-planners/implicit-dedication/src/test/java/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java#L291). Take `ImplicitPlannerTest.checkStrictModeWithCurrentAccountVmsPresent` as example: Before Refactoring ```java ... boolean foundNeededCluster = false; for (Long cluster : clusterList) { if (cluster != 1) { fail("Found a cluster that shouldn't have been present, cluster id : " + cluster); } else { foundNeededCluster = true; } } assertTrue("Didn't find cluster 1 in the list. It should have been present", foundNeededCluster); ... ``` After Refactoring ```java import static org.hamcrest.Matchers.everyItem; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; // org.junit.Assert.assertThat has been deprecated ... assertThat("Found cluster that shouldn't have been present, only cluster 1 should have been present", clusterList, everyItem(equalTo(1L))); ... ``` <!--- Describe your changes in DETAIL - And how has behaviour functionally changed. --> <!-- For new features, provide link to FS, dev ML discussion etc. --> <!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. --> <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged --> <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" --> <!-- Fixes: # --> <!--- ********************************************************************************* --> <!--- NOTE: AUTOMATATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. --> <!--- PLEASE PUT AN 'X' in only **ONE** box --> <!--- ********************************************************************************* --> ### Types of changes - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [x] Enhancement (improves an existing feature and functionality) - [ ] Cleanup (Code refactoring and cleanup, that may add test cases) ### Feature/Enhancement Scale or Bug Severity #### Feature/Enhancement Scale - [ ] Major - [x] Minor ### Screenshots (if appropriate): ### How Has This Been Tested? <!-- Please describe in detail how you tested your changes. --> <!-- Include details of your testing environment, and the tests you ran to --> <!-- see how your change affects other areas of the code, etc. --> Local cluster environment (KVM, UBUNTU 18.04) runs the test suite. <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document --> -- 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]
