### Question:
CloseableQueryBuilderImpl implements CloseableQueryBuilder, AdapterFactory { @SuppressWarnings("unchecked") @CheckForNull @Override public <AdapterType> AdapterType getAdapter(@Nonnull final Object adaptable, @Nonnull final Class<AdapterType> adapterType) { if (adaptable instanceof ResourceResolver && adapterType.isAssignableFrom(CloseableQueryBuilder.class)) { return (AdapterType) this; } else { return null; } }  @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 testGetAdapter() { assertSame("getAdapter should return same instance with ResourceResolver and correct adapterType.", closeableQueryBuilder, closeableQueryBuilder.getAdapter(contextResolver, CloseableQueryBuilder.class)); assertNull("getAdapter should return null for non-ResourceResolver adapter", closeableQueryBuilder.getAdapter(context.request(), CloseableQueryBuilder.class)); assertNull("getAdapter should return null for incorrect adapterType", closeableQueryBuilder.getAdapter(contextResolver, QueryBuilder.class)); }