### Question:
CloseableQueryBuilderImpl implements CloseableQueryBuilder, AdapterFactory { @Override public void storeQuery(final Query query, final String path, final boolean createFile, final ResourceResolver resourceResolver) throws RepositoryException, IOException { storeQuery(query, path, createFile, 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 testStoreQuery() throws Exception { final JackrabbitSession mockJackrabbitSession = mock(JackrabbitSession.class); final Session mockJcrSession = mock(Session.class); final Query mockQuery = mock(Query.class); doAnswer((invocation) -> { Session sessionArg = invocation.getArgument(3); assertTrue("query session should NOT be a session wrapper: " + sessionArg.getClass().getName(), !(sessionArg instanceof BaseSessionIWrap)); return null; }).when(mockQueryBuilder).storeQuery(isA(Query.class), isA(String.class), anyBoolean(), any(Session.class)); closeableQueryBuilder.storeQuery(mockQuery, "/somepath", true, contextResolver); closeableQueryBuilder.storeQuery(mockQuery, "/somepath", true, mockJcrSession); closeableQueryBuilder.storeQuery(mockQuery, "/somepath", true, mockJackrabbitSession); verify(mockQueryBuilder, times(3)) .storeQuery(isA(Query.class), isA(String.class), anyBoolean(), any(Session.class)); }