Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-4460

Improve MockQuery

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Outdated
    • Minor
    • None
    • 4.5
    • testing
    • None

    Description

      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:

                  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*");
                                              }
                                          };
                                      }
                                  };
                              }
                          };
                      }
                  });
      

      There should be a simpler way.

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              had Jan Haderka
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Task DoD