erickalendra opened a new pull request, #10686:
URL: https://github.com/apache/cloudstack/pull/10686

   ### Description
   
   This PR updates Mockito to 5.16.1 from 4.
   See the release notes for high level changes: 
https://github.com/mockito/mockito/releases/tag/v5.0.0
   
   Dependency name change `mockito-inline` to `mockito-core`. Inline is now the 
default and the last version of `mockito-inline` released is `5.2.0`.
   
   * `assertj-core` in user-authenticators/saml2 pulls in an incompatible 
version of byte-buddy and required an exclusion. Updating the version of 
assertj is left for a future PR.
   
   The upgrade requires Java 11+, dropping support for Java 8. CloudStack 
documentation already says to use Java 11 and does not indicate that java 8 is 
supported.
   
   Test classes using `@RunWith(MockitoJUnitRunner.class)` now get run in 
strict mode. Changes were made to tests where the stubbing intention was clear. 
In `ManagementServerMaintenanceManagerImplTest` there are 5 tests where the 
intention of the test is unclear. Each of the statements now use 
`Mockito.lenient()` to avoid the exception. Other cases in the tests follow a 
similar pattern.
   
   ```
   Unnecessary stubbings detected in test class: 
ManagementServerMaintenanceManagerImplTest
   Clean & maintainable test code requires zero unnecessary code.
   Following stubbings are unnecessary (click to navigate to relevant line of 
code):
     1. -> at 
org.apache.cloudstack.maintenance.ManagementServerMaintenanceManagerImplTest.prepareForShutdownCmdFailedResponseFromClusterManager(ManagementServerMaintenanceManagerImplTest.java:189)
     2. -> at 
org.apache.cloudstack.maintenance.ManagementServerMaintenanceManagerImplTest.prepareForShutdownCmdNullResponseFromClusterManager(ManagementServerMaintenanceManagerImplTest.java:173)
     3. -> at 
org.apache.cloudstack.maintenance.ManagementServerMaintenanceManagerImplTest.prepareForShutdownCmdSuccessResponseFromClusterManager(ManagementServerMaintenanceManagerImplTest.java:204)
     4. -> at 
org.apache.cloudstack.maintenance.ManagementServerMaintenanceManagerImplTest.prepareForShutdownCmdOtherMsHostsInPreparingState(ManagementServerMaintenanceManagerImplTest.java:158)
     5. -> at 
org.apache.cloudstack.maintenance.ManagementServerMaintenanceManagerImplTest.triggerShutdownCmdMsInUpStateAndOtherMsHostsInPreparingState(ManagementServerMaintenanceManagerImplTest.java:283)
   Please remove unnecessary stubbings or use 'lenient' strictness. More info: 
javadoc for UnnecessaryStubbingException class.
   ```
   
   Minor clean up.
   * Both `@Spy` and `Mockito.spy(` should not be used. Favored the annotation.
   * Both `@RunWith(MockitoJUnitRunner.class)` and 
`MockitoAnnotations.openMocks(this);` should not be used. Favored the 
annotation.
   * Unnecessary `extends TestCase` removed.
   * `@InjectMocks` and `new` in statement unnecessary. Removed new when issue 
presented.
   * Some of the `Cmd` classes like `UpdateNetworkCmd` have a type tree that 
includes fields of type `Object`. This appears to cause issues with injection, 
requiring that `@Mock` fields be available. This is where the following fields 
were added in multiple places:
     * `Object job;`
     * `ResponseGenerator _responseGenerator;`
   * Wrong number of parameters for `Mockito.when` in 
LibvirtRevertSnapshotCommandWrapperTest.java
   
   
   <!--- 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: AUTOMATION 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)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   - [ ] build/CI
   - [X] test (unit or integration test code)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [ ] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [ ] Minor
   - [ ] Trivial
   
   ### Screenshots (if appropriate):
   
   ### How Has This Been Tested?
   
   All tests that run with flags: `-Dnoredist -P developer,systemvm`.
   
   Commands used:
   `mvn clean install -Dnoredist -P developer,systemvm`
   
   Do not need to verify running of the server or agent because Mockito is only 
used in tests.
   
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to 
-->
   
   #### How did you try to break this feature and the system with this change?
   
   <!-- see how your change affects other areas of the code, etc. -->
   
   <!-- 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]

Reply via email to