FacetParameterUtils { public static Map<String, Integer> getSolrFacetParams(String type, String[] solrFacets, Map<String, String[]> parameters, boolean defaultFacetsRequested) { Map<String, Integer> solrFacetParams = new HashMap<>(); if (defaultFacetsRequested) { for (SolrFacetType solrFacet : SolrFacetType.values()) { saveNumericFacetParam(type, solrFacet.name(), parameters, true, false, solrFacetParams); } } if (ArrayUtils.isNotEmpty(solrFacets)) { for (String solrFacetName : solrFacets) { if (!(defaultFacetsRequested && defaultSolrFacetList.contains(solrFacetName))) { saveNumericFacetParam(type, solrFacetName, parameters, defaultSolrFacetList.contains(solrFacetName), false, solrFacetParams); } } } return solrFacetParams; }  static Map<String, Integer> getSolrFacetParams(String type, String[] solrFacets,
                                                          Map<String, String[]> parameters,
                                                          boolean defaultFacetsRequested); static Map<String, Integer> getTechnicalFacetParams(String type, String[] technicalFacets, Map<String,
            String[]> parameters, boolean defaultFacetsRequested); static Map<String, String> getDateRangeParams(Map<String, String[]> parameters); static String getLimitForDataProvider();  }
@Test public void testOffsetWithoutDefaults() { Map<String, Integer> resultMap = FacetParameterUtils.getSolrFacetParams("offset", facets, parameters, false); assertNotNull(resultMap); assertEquals(1, resultMap.size()); assertTrue(resultMap.containsKey("f.proxy_dc_contributor.facet.offset")); assertEquals(new Integer(0), resultMap.get("f.proxy_dc_contributor.facet.offset")); }
@Test public void testAdditionalOffsetWithDefaults() { parameters.put("f.PROVIDER.facet.offset", new String[]{"0"}); Map<String, Integer> resultMap = FacetParameterUtils.getSolrFacetParams("offset", facets, parameters, true); assertNotNull(resultMap); assertEquals(2, resultMap.size()); assertTrue(resultMap.containsKey("f.proxy_dc_contributor.facet.offset")); assertEquals(new Integer(0), resultMap.get("f.proxy_dc_contributor.facet.offset")); assertTrue(resultMap.containsKey("f.proxy_dc_contributor.facet.offset")); assertEquals(new Integer(0), resultMap.get("f.PROVIDER.facet.offset")); }
@Test public void testAdditionalOffsetWithoutDefaults() { parameters.put("f.PROVIDER.facet.offset", new String[]{"0"}); Map<String, Integer> resultMap = FacetParameterUtils.getSolrFacetParams("offset", facets, parameters, false); assertNotNull(resultMap); assertEquals(1, resultMap.size()); assertTrue(resultMap.containsKey("f.proxy_dc_contributor.facet.offset")); assertEquals(new Integer(0), resultMap.get("f.proxy_dc_contributor.facet.offset")); }
@Test public void testLimitWithDefaults() { Map<String, Integer> resultMap = FacetParameterUtils.getSolrFacetParams("limit", facets, parameters, true); assertNotNull(resultMap); assertEquals(SolrFacetType.values().length + 1, resultMap.size()); assertTrue(resultMap.containsKey("f.proxy_dc_contributor.facet.limit")); assertTrue(resultMap.containsKey("f.DATA_PROVIDER.facet.limit")); assertEquals(new Integer(30), resultMap.get("f.proxy_dc_contributor.facet.limit")); assertEquals(new Integer(50), resultMap.get("f.DATA_PROVIDER.facet.limit")); }
@Test public void testLimitWithoutDefaults() { Map<String, Integer> resultMap = FacetParameterUtils.getSolrFacetParams("limit", facets, parameters, false); assertNotNull(resultMap); assertEquals(1, resultMap.size()); assertTrue(resultMap.containsKey("f.proxy_dc_contributor.facet.limit")); assertEquals(new Integer(30), resultMap.get("f.proxy_dc_contributor.facet.limit")); }
@Test public void testOffsetWithDefaults() { Map<String, Integer> resultMap = FacetParameterUtils.getSolrFacetParams("offset", facets, parameters, true); assertNotNull(resultMap); assertEquals(1, resultMap.size()); assertTrue(resultMap.containsKey("f.proxy_dc_contributor.facet.offset")); assertEquals(new Integer(0), resultMap.get("f.proxy_dc_contributor.facet.offset")); }