### Question:
IndexingHandler extends Handler { @Override public Collection searchContent(RequestContext requestContext) throws RegistryException { String searchQuery = requestContext.getKeywords(); UserRegistry registry = CurrentSession.getUserRegistry(); SolrClient client; List<String> filteredResults = new ArrayList<String>(); try { client = SolrClient.getInstance(); SolrDocumentList results = client.query(searchQuery, CurrentSession.getTenantId()); if (log.isDebugEnabled()){ log.debug("result received "+ results); } for(int i = 0;i < results.getNumFound();i++){ SolrDocument solrDocument = results.get(i); String path = getPathFromId((String)solrDocument.getFirstValue("id")); if(isAuthorized(registry,path, ActionConstants.GET)){ filteredResults.add(path); } } if (log.isDebugEnabled()) { log.debug("filtered results "+ filteredResults + " for user "+ registry.getUserName()); } } catch (IndexerException e) { log.error("Unable to do Content Search", e); } String[] resourcePaths = filteredResults.toArray(new String[filteredResults.size()]); Collection searchResults = new CollectionImpl(); searchResults.setContent(resourcePaths); return searchResults; }  void put(RequestContext requestContext); @Override Collection searchContent(RequestContext requestContext); void importResource(RequestContext requestContext); void delete(RequestContext requestContext); void putChild(RequestContext requestContext); void importChild(RequestContext requestContext);  }### Answer:
@Test public void searchContent() throws Exception { RequestContext requestContext = new RequestContext(registry, repository, versionRepository); requestContext.setKeywords("testing"); CurrentSession.setUserRegistry(registry); IndexingHandler indexingHandler = new IndexingHandler(); SolrClient client = PowerMockito.mock(SolrClient.class); mockStatic(SolrClient.class); Whitebox.setInternalState(SolrClient.class, "instance", client); CurrentSession.setTenantId(-1234); SolrDocumentList documentList = new SolrDocumentList(); SolrDocument document = new SolrDocument(); document.put("id", regResourcePath + "tenantId-1234"); documentList.add(document); documentList.setNumFound(1); when(client.query(anyString(), anyInt())).thenReturn(documentList); try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(-1234, true); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername("admin"); Collection results = indexingHandler.searchContent(requestContext); assertNotNull(results); String[] filteredPaths = new String[]{regResourcePath}; assertArrayEquals(filteredPaths, (String[]) results.getContent()); } finally { PrivilegedCarbonContext.endTenantFlow(); } }