try (ResourceResolver writeAccessResourceResolver = userMapperService.getJCRWriterService(); ResourceResolver readAccessResourceResolver = userMapperService.getJCRReadService()) {... I am mocking userMapperService here , and returning aemContext.resourceResolver(), when userMapperService.getJCRW...