You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Stefan Seifert (Jira)" <ji...@apache.org> on 2026/02/28 12:24:00 UTC

[jira] [Closed] (SLING-13088) [Sling Models] Migrate ModelAdapterFactory, Ordering, and OSGi tests to JUnit 5

     [ https://issues.apache.org/jira/browse/SLING-13088?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Seifert closed SLING-13088.
----------------------------------

> [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
>            Assignee: Stefan Seifert
>            Priority: Major
>              Labels: junit5, models, test
>             Fix For: Models Implementation 2.0.2
>
>
> 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)