Bhavik Kothari created SLING-13088:
--------------------------------------
Summary: [Sling Models] Migrate ModelAdapterFactory, Ordering, and
OSGi tests to JUnit 5
Key: SLING-13088
URL: https://issues.apache.org/jira/browse/SLING-13088
Project: Sling
Issue Type: Improvement
Components: Sling Models
Reporter: Bhavik Kothari
Continuing the JUnit 5 migration (following SLING-13072).
This task covers the third batch of the root `org.apache.sling.models.impl`
package (files starting M-O).
Files migrated:
- ModelAdapterFactory_ImplementationPickerOrderTest
- ModelAdapterFactory_InjectorOrderTest
- ModelAdapterFactoryTest
- ModelPackageBundleListenerTest
- MultipleInjectorTest
- OSGiInjectionTest
- OptionalObjectsTest
- OptionalPrimitivesTest
Changes:
- Replacing `MockitoJUnitRunner` with `@ExtendWith(MockitoExtension.class)`
- Updating all imports to `org.junit.jupiter.api`
- Applying `lenient()` strictness to shared setup method to preserve legacy
test behavior and prevent `UnnecessaryStubbingException` without altering the
original test logic
- using JUnit 5's {{assertThrows}} instead of the JUnit4's {{@Test(expected)}}
attribute
- Correcting Assertion Argument Order
- Adding {{{}<?>{}}}: Change Type variable to {{Type<?>}} variable
- If {{when(...).thenReturn(...)}} fails with a type error, changing it to
{{doReturn(...).when(...).method()}}
- renaming the local log variable to logger to avoid shadowing the class field.
- Removing unnecessary eq() usage
- Removing redundant Throws
- Cleaning SuppressWarnings and resolved sonar issues with doReturn changes
- Adding JUnit 5 OSGi dependency and migrating implementation picker & Injector
orde test.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)