Hi,
On Tue, Jun 2, 2020 at 7:06 PM Andreas Schaefer
<[email protected]> wrote:
> ...I do not like to use a “Mock” class for a in-production code..
If you don't have a request but need a request, you do need to mock it ;-)
I agree that the term "mocks" is often connected to testing but if you
look at our servlet helper classes [1] I don't see anything that makes
them specific to testing.
Their automated test coverage is quite good and it all looks like
solid code to me, they look perfectly fine as "production mocks".
> ...I cannot do multiparts forms in the Mock classes (getParts(), getPart() is
> throwing an Unsupported Operation Exception)...
How about improving that servlet-helpers module to support that?
IMHO, internal requests using the SlingRequestProcessor is a powerful
mechanism, I'm all for making it easier to use - but I think we have a
good foundation with that module.
As a sidenote (which might be relevant if we improve this), for my use
cases a fluent interface to the SlingRequestProcessor would be nice,
something like
InternalRequest.Get(SlingRequestProcessor, ResourceResolver)
.forPath("/yocats").withSelectors("farenheit", "451").withExtension("json")
.execute()
.checkStatus(200)
.checkContentType("application/json")
.getContentAsStream()
-Bertrand
[1]
https://github.com/apache/sling-org-apache-sling-servlet-helpers/tree/master/src/main/java/org/apache/sling/servlethelpers