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/04/05 13:16:00 UTC

[jira] [Assigned] (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 reassigned SLING-11252:
--------------------------------------

    Assignee: Stefan Seifert

good point - i've a proposal: https://github.com/apache/sling-org-apache-sling-testing-sling-mock/pull/8

WDYT?

> 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
>
> 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.1#820001)