sling-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Konrad Windszus (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SLING-7978) Sling Mocks: Allow easy access to the ModelFactory
Date Fri, 05 Oct 2018 10:28:01 GMT

    [ https://issues.apache.org/jira/browse/SLING-7978?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16639631#comment-16639631
] 

Konrad Windszus commented on SLING-7978:
----------------------------------------

I published the updated site to https://sling.apache.org/documentation/development/sling-mock.html#sling-models.


> Sling Mocks: Allow easy access to the ModelFactory
> --------------------------------------------------
>
>                 Key: SLING-7978
>                 URL: https://issues.apache.org/jira/browse/SLING-7978
>             Project: Sling
>          Issue Type: Improvement
>          Components: Site, Testing
>            Reporter: Konrad Windszus
>            Priority: Major
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Currently you would instantiate a Sling Model in a unit test leveraging Sling Mocks via
> {code}
> @Rule
>   public SlingContext context = new SlingContext(ResourceResolverType.RESOURCERESOLVER_MOCK);
>  @Test
>   public void testModel() {
>     context.load()
>            .json(<some json resource from the classpath>, "/page1");
>     context.addModelsForClasses(MyModel.class);
>     MyModel model = context.resourceResolver().getResource("/page1").adaptTo(MyModel.class)
>   // model is now null for some reason, hard to debug why
> {code}
> In case for some reason the model cannot be instantiated it is hard to debug why (because
by default the reason is only emitted in the log with level DEBUG). To ease debugging it would
be nice if {{ModelFactory}} (SLING-3709) could be used, as that throws an explicit exception
in case of instantiation errrors. It would be nice to give direct access to that service directly
from the {{SlingContext}}.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message