### Question:
ContentBasedSearchService extends RegistryAbstractAdmin implements IContentBasedSearchService { public static String getLoggedInUserName(){ return PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); }  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 getLoggedInUserName() throws Exception { try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername("admin"); ContentBasedSearchService service = new ContentBasedSearchService(); assertEquals("admin", service.getLoggedInUserName()); } finally { PrivilegedCarbonContext.endTenantFlow(); } }