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 2021/01/11 21:17:00 UTC
[jira] [Commented] (SLING-10003) Allow to mock findResources in
MockResourceResolver
[ https://issues.apache.org/jira/browse/SLING-10003?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17262936#comment-17262936 ]
Stefan Seifert commented on SLING-10003:
----------------------------------------
[~kwin] i've implemented an alternative approach which is a bit close to that approach from jcr-mock, and also allows to mock queryResources:
https://github.com/apache/sling-org-apache-sling-testing-resourceresolver-mock/pull/2
> Allow to mock findResources in MockResourceResolver
> ---------------------------------------------------
>
> Key: SLING-10003
> URL: https://issues.apache.org/jira/browse/SLING-10003
> Project: Sling
> Issue Type: Improvement
> Components: Testing
> Reporter: Konrad Windszus
> Priority: Major
> Fix For: Testing ResourceResolver Mock 1.2.0
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> Currently there is no easy way to override the method [MockResourceResolver.findResources().|https://github.com/apache/sling-org-apache-sling-testing-resourceresolver-mock/blob/6ef6bd69ce1679b06d6b4d52b1b170dce51d102c/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java#L455]
> There should be a way to override that without relying on other mock frameworks like Mockito.
> One way could be to add a static method {{MockResourceResolver.registerFindResourcesFunction(ResourceResolver resolver, BiFunction<String, String, Iterator<Resource> findResourcesFunction)}} which allows to easily override the default implementation (which always throws an UnsupportedOperationException) for the given resolver (in case this is a MockResourceResolver). The registration should only affect the given resource resolver as usually there is different functions necessary per test method.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)