### Question:
CloseableQueryBuilderImpl implements CloseableQueryBuilder, AdapterFactory { @Override public CloseableQuery loadQuery(final String path, final ResourceResolver resourceResolver) throws RepositoryException, IOException { return loadQuery(path, resourceResolver.adaptTo(Session.class)); }  @SuppressWarnings("unchecked") @CheckForNull @Override AdapterType getAdapter(@Nonnull final Object adaptable,
                                                @Nonnull final Class<AdapterType> adapterType); @Override CloseableQuery createQuery(final PredicateGroup rootPredicateGroup,
                                      final ResourceResolver resourceResolver); @Override CloseableQuery createQuery(final ResourceResolver resourceResolver); @Override CloseableQuery createQuery(final PredicateGroup rootPredicateGroup, final Session session); @Override CloseableQuery createQuery(final Session session); @Override CloseableQuery loadQuery(final String path,
                                    final ResourceResolver resourceResolver); @Override CloseableQuery loadQuery(final String path, final Session session); @Override void storeQuery(final Query query,
                           final String path,
                           final boolean createFile,
                           final ResourceResolver resourceResolver); @Override void storeQuery(final Query query, final String path, final boolean createFile, final Session session); @Override void clearFacetCache();  }### Answer:
@Test public void testLoadQuery() throws Exception { final JackrabbitSession mockJackrabbitSession = mock(JackrabbitSession.class); final Session mockJcrSession = mock(Session.class); final Query mockQuery = mock(Query.class); when(mockQueryBuilder.loadQuery(any(String.class), any(Session.class))).then((invocation) -> { String pathArg = invocation.getArgument(0); Session sessionArg = invocation.getArgument(1); assertTrue("query session should be a wrapper: " + sessionArg.getClass().getName(), sessionArg instanceof BaseSessionIWrap); if ("".equals(pathArg)) { return null; } return mockQuery; }); assertNotNull("load query should not be null with resourceResolver and path", closeableQueryBuilder.loadQuery("/somepath", contextResolver)); assertNotNull("load query should not be null with mocked JCR session and path", closeableQueryBuilder.loadQuery("/somepath", mockJcrSession)); assertNotNull("load query should not be null with mocked Jackrabbit session and path", closeableQueryBuilder.loadQuery("/somepath", mockJackrabbitSession)); assertNull("load query should be null with resourceResolver and empty path", closeableQueryBuilder.loadQuery("", contextResolver)); assertNull("load query should be null with mocked JCR session and empty path", closeableQueryBuilder.loadQuery("", mockJcrSession)); assertNull("load query should be null with mocked Jackrabbit session and empty path", closeableQueryBuilder.loadQuery("", mockJackrabbitSession)); }