### Question:
FacetedSearchService { public String getFacetKeys() { List<String> facetKeys = new ArrayList<>(); String jsonString = searchConfig.getTimePeriod(); JSONArray timePeriodList = new JSONArray(jsonString); JSONObject timePeriodJSONObject; try { for (Map.Entry<String, String> e : searchConfig.getFacets().entrySet()) { String facetKey = e.getKey(); { if (facetKey.contains(SearchConstants.DATE_FACET_PRE_KEY)) { facetKey = facetKey.replaceFirst(SearchConstants.DATE_FACET_PRE_KEY, ""); for (int i = 0; i < timePeriodList.length(); i++) { timePeriodJSONObject = timePeriodList.getJSONObject(i); String timePeriod = URLEncoder.encode( "{" + SearchConstants.SOLR_FACET_NAME_CHANGE_COMMAND + "'" + e.getValue() + ", " + timePeriodJSONObject.getString(SearchConstants.TIME_PERIOD_DESCRIPTION) + "'}", SearchConstants.FACETED_SEARCH_ENCODING); String timePeriodValue = URLEncoder.encode(timePeriodJSONObject.getString(SearchConstants.TIME_PERIOD_VALUE), SearchConstants.FACETED_SEARCH_ENCODING); facetKeys.add( SearchConstants.FACET_QUERY + timePeriod + facetKey + SearchConstants.DOTS_SPLITTER + timePeriodValue); } } else { String encoded = URLEncoder.encode("{" + SearchConstants.SOLR_FACET_NAME_CHANGE_COMMAND + "'" + e.getValue() + "'}", SearchConstants.FACETED_SEARCH_ENCODING); facetKeys.add(SearchConstants.FACET_FILED + encoded + facetKey); } } } } catch (UnsupportedEncodingException e1) { log.error("Encoding problem while building the facet key list: " + e1.getMessage(), e1); } return String.join(SearchConstants.AND_SPLITTER, facetKeys); }  String buildHiddenDocumentsFilter(); String getFacetKeys(); String buildSolrQuery(String filter); String updateQueryWithExcludedObjects(String query, String rowQueryParameters); String replaceEventTypeName(String solrResult); String escapeQueryChars(String s); String escapeTermsInQuery(String query); SearchConfig getSearchConfig(); void setSearchConfig(SearchConfig searchConfig); AuditEventConfig getAuditEventConfig(); void setAuditEventConfig(AuditEventConfig auditEventConfig); JSONObject getParentDocumentJsonObject(Authentication authentication, String res); ExecuteSolrQuery getExecuteSolrQuery(); void setExecuteSolrQuery(ExecuteSolrQuery executeSolrQuery);  }### Answer:
@Test public void getFacetKeys() throws Exception { searchConfig.getFacets().put("first_name_s", "First Name"); searchConfig.getFacets().put("last_name_s", "Last Name"); searchConfig.getFacets().put("date.birth_date_tdt", "Birth Date"); String expected = "field=" + URLEncoder.encode("{!key='First Name'}first_name_s", SearchConstants.FACETED_SEARCH_ENCODING) + "&facet.query=" + URLEncoder.encode("{!key='Birth Date, Previous Week'}birth_date_tdt", SearchConstants.FACETED_SEARCH_ENCODING) + ":" + URLEncoder.encode("[NOW/DAY-7DAY TO *]", SearchConstants.FACETED_SEARCH_ENCODING) + "&field=" + URLEncoder.encode("{!key='Last Name'}last_name_s", SearchConstants.FACETED_SEARCH_ENCODING); String found = unit.getFacetKeys(); assertEquals(expected, found); }