### Question:
ContentBasedSearchService extends RegistryAbstractAdmin implements IContentBasedSearchService { public SearchResultsBean getContentSearchResults(String searchQuery) throws AxisFault{ try { UserRegistry registry = (UserRegistry) getRootRegistry(); return searchContent(searchQuery, registry); } catch (Exception e) { log.error("Error " + e.getMessage() + "at the content search back end component.", e ); } return new SearchResultsBean(); }  SearchResultsBean getContentSearchResults(String searchQuery); SearchResultsBean getAttributeSearchResults(String[][] attributes); SearchResultsBean getTermSearchResults(String[][] attributes); SearchResultsBean searchContent(String searchQuery,
                              UserRegistry registry); SearchResultsBean searchByAttribute(Map<String, String> attributes,
                                           UserRegistry registry); void restartIndexing(); static String getLoggedInUserName(); SearchResultsBean searchTerms(Map<String, String> attributes, UserRegistry registry); SearchResultsBean searchTermsByQuery(String searchQuery, String facetField,
                                                 UserRegistry registry);  }### Answer:
@Test public void getContentSearchResults() throws Exception { SolrDocumentList resultList = new SolrDocumentList(); SolrDocument document = new SolrDocument(); document.setField("id", "/_system/governance/trunk/api/testtenantId=-1234"); resultList.add(document); when(client.query(anyString(),anyInt())).thenReturn(resultList); when(service.getContentSearchResults(anyString())).thenCallRealMethod(); when(service.searchContent(anyString(), (UserRegistry) anyObject())).thenCallRealMethod(); AuthorizationManager authManager = mock(AuthorizationManager.class); when(authManager.isUserAuthorized("admin", "/_system/governance/trunk/api/test", ActionConstants .GET)).thenReturn(Boolean.TRUE); RegistryRealm registryRealm = mock(RegistryRealm.class); try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername("admin"); when(registryRealm.getAuthorizationManager()).thenReturn(authManager); when(registry.getUserRealm()).thenReturn(registryRealm); ResourceImpl resource = new ResourceImpl(); resource.setPath("/_system/governance/trunk/api/test"); resource.setAuthorUserName("admin"); resource.setDescription("Unit Testing"); resource.setCreatedTime(Calendar.getInstance().getTime()); resource.setProperty("registry.user", "admin"); when(registry.get("/_system/governance/trunk/api/test")).thenReturn(resource); when(registry.getAverageRating("/_system/governance/trunk/api/test")).thenReturn(2.5f); when(registry.getUserName()).thenReturn("admin"); SearchResultsBean resultsBean = service.getContentSearchResults("testing"); ResourceData[] resultDataList = resultsBean.getResourceDataList(); assertNotNull(resultDataList); assertEquals(1, resultDataList.length); assertEquals("test", resultDataList[0].getName()); assertEquals(2.5f, resultDataList[0].getAverageRating(), 0); } finally { PrivilegedCarbonContext.endTenantFlow(); } }