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 2022/08/19 12:43:00 UTC

[jira] [Updated] (SLING-11252) RRMockResourceResolverWrapper supports no way of mocking searches

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

Stefan Seifert updated SLING-11252:
-----------------------------------
    Fix Version/s: Testing Sling Mock 3.4.0

solved as part of SLING-11455 and SLING-11548

with those tickets, the following changes apply to providing mocked search results:
 * the "RRMockResourceResolverWrapper" is removed, so theoretically the "old" way of casting to MockResourceResolver is still working if {{RESOURCERESOLVER_MOCK}} is used
 * but those methods are now deprecated, and a new class {{org.apache.sling.testing.resourceresolver.MockFindQueryResources}} with static methods is introduced which can be used without having manually to cast anything
 * it works with both {{RESOURCERESOLVER_MOCK}} and the new {{RESOURCEPROVIDER_MOCK}} resource resolver type without users having to care about the details

> RRMockResourceResolverWrapper supports no way of mocking searches
> -----------------------------------------------------------------
>
>                 Key: SLING-11252
>                 URL: https://issues.apache.org/jira/browse/SLING-11252
>             Project: Sling
>          Issue Type: Bug
>          Components: Testing
>    Affects Versions: Testing Sling Mock 3.2.2
>            Reporter: Henry Kuijpers
>            Assignee: Stefan Seifert
>            Priority: Major
>             Fix For: Testing Sling Mock 3.4.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Previously, it was possible to call ((MockResourceResolver)context.resourceResolver()).addFindResourceHandler(...)
> Currently, we have to add a "find resource handler" this way:
> {code:java}
>         final Field wrappedField = ResourceResolverWrapper.class.getDeclaredField("wrapped");
>         wrappedField.setAccessible(true);
>         ((MockResourceResolver) wrappedField.get(context.resourceResolver())).addFindResourceHandler((s, s1) -> {
>             assertEquals("my-language", s);
>             assertEquals("search term", s1);
>             return contentResource.listChildren();
>         });
> {code}
> This wrapping seems to have been added in: https://github.com/apache/sling-org-apache-sling-testing-sling-mock/commit/a6d01ff058d422ff544c2a137b42291bd550f603
> We could add logic that consults the ResourceProviders to see if they can execute the custom search that we'd like to do, or, we could add the methods also on RRMockResourceResolverWrapper.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)