### Question:
IndexingHandler extends Handler { public void put(RequestContext requestContext) throws RegistryException { if (log.isDebugEnabled()){ log.debug(" Before put resources into indexer " + requestContext.getResourcePath().getPath()); } if (isIndexablePutOperation(requestContext) || Utils.getRegistryService() == null) { return; } PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); String path = getRegistryPath(requestContext); submitFileForIndexing(getIndexer(), requestContext.getResource(), path, null,carbonContext.getTenantId(), carbonContext.getTenantDomain() ); if (log.isDebugEnabled()){ log.debug(" After put resources into indexer "+ requestContext.getResourcePath().getPath()); } }  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 testPut() throws Exception { RequestContext requestContext = new RequestContext(registry, repository, versionRepository); requestContext.setResource(resource); IndexingHandler indexingHandler = new IndexingHandler(); SolrClient client = PowerMockito.mock(SolrClient.class); mockStatic(SolrClient.class); Whitebox.setInternalState(SolrClient.class, "instance", client); final IndexDocument[] documents = new IndexDocument[1]; doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); documents[0] = (IndexDocument) args[0]; return null; } }).when(client).addDocument((IndexDocument) anyObject()); try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(-1234, true); indexingHandler.put(requestContext); } finally { PrivilegedCarbonContext.endTenantFlow(); } assertNotNull(documents[0]); assertEquals(regResourcePath, documents[0].getPath()); }
@Test public void testPutCollection() throws Exception { RequestContext requestContext = new RequestContext(registry, repository, versionRepository); Collection collection = new CollectionImpl(); requestContext.setResource(collection); IndexingHandler indexingHandler = new IndexingHandler(); SolrClient client = mock(SolrClient.class); mockStatic(SolrClient.class); Whitebox.setInternalState(SolrClient.class, "instance", client); final IndexDocument[] documents = new IndexDocument[1]; doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); documents[0] = (IndexDocument) args[0]; return null; } }).when(client).addDocument((IndexDocument) anyObject()); try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(-1234, true); indexingHandler.put(requestContext); } finally { PrivilegedCarbonContext.endTenantFlow(); } assertNull(documents[0]); }