Improve MockQuery
-----------------

                 Key: MAGNOLIA-4460
                 URL: http://jira.magnolia-cms.com/browse/MAGNOLIA-4460
             Project: Magnolia
          Issue Type: Improvement
      Security Level: Public
          Components: testing
    Affects Versions: 4.5
            Reporter: Jan Haderka
            Priority: Minor


Current mock API doesn't implement real {{Query}}, but instead advices anyone 
to override {{QueryResult}} if necessary. Overriding is however non trivial and 
requires lots of boiler plate code:
{noformat}

            final MockSession websiteSession = (MockSession) 
getCtx().getJCRSession(workspaceName);
            websiteSession.setWorkspace(new MockWorkspace(workspaceName) {
                @Override
                public QueryManager getQueryManager() {
                    return new MockQueryManager(websiteSession) {
                        @Override
                        public Query createQuery(final String statement, final 
String language) throws InvalidQueryException, RepositoryException {
                            return new MockQuery(websiteSession, statement, 
language) {
                                @Override
                                public QueryResult execute() throws 
InvalidQueryException, RepositoryException {
                                    return new MockQueryResult(websiteSession, 
statement, language) {
                                        @Override
                                        public NodeIterator getNodes() throws 
RepositoryException {
                                            return 
websiteSession.getNode("/demo-project/news-and-events/news-overview").getNodes("news*");
                                        }
                                    };
                                }
                            };
                        }
                    };
                }
            });
{noformat}

There should be a simpler way.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


----------------------------------------------------------------
For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to