### Question:
ContentBasedSearchService extends RegistryAbstractAdmin implements IContentBasedSearchService { public SearchResultsBean searchTerms(Map<String, String> attributes, UserRegistry registry) throws IndexerException, RegistryException { return searchTermsInternal(null, null, attributes, registry); }  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 searchTermsByAttributes() throws Exception { List<FacetField.Count> resultList = new ArrayList<>(); FacetField.Count count = new FacetField.Count(new FacetField("overview_name_s"), "tag1", 2); resultList.add(count); when(client.facetQuery(anyInt(), (Map)anyObject())).thenReturn(resultList); when(service.searchTerms((Map)anyObject(), (UserRegistry)anyObject())) .thenCallRealMethod(); AuthorizationManager authManager = mock(AuthorizationManager.class); when(authManager.isUserAuthorized("admin", "/_system/governance/trunk/api/test", ActionConstants .GET)).thenReturn(Boolean.TRUE); RegistryRealm registryRealm = PowerMockito.mock(RegistryRealm.class); try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername("admin"); when(registryRealm.getAuthorizationManager()).thenReturn(authManager); when(registry.getUserRealm()).thenReturn(registryRealm); Map<String, String> attributeMap = new HashMap<>(); attributeMap.put("facet.field", "overview_name"); attributeMap.put("facet.limit", "10"); attributeMap.put("facet.mincount", "1"); attributeMap.put("facet.sort", "overview_version"); attributeMap.put("facet.prefix", "ta"); SearchResultsBean resultsBean = service.searchTerms(attributeMap, registry); TermData[] resultDataList = resultsBean.getTermDataList(); Assert.assertNotNull(resultDataList); assertEquals(1, resultDataList.length); assertEquals("tag1", resultDataList[0].getTerm()); assertEquals(2, resultDataList[0].getFrequency(), 0); } finally { PrivilegedCarbonContext.endTenantFlow(); } }