DiscoverFacetConfigurationConverter { public FacetConfigurationRest convert(final String configurationName, final String scope, DiscoveryConfiguration configuration) { FacetConfigurationRest facetConfigurationRest = new FacetConfigurationRest(); facetConfigurationRest.setConfiguration(configurationName); facetConfigurationRest.setScope(scope); if (configuration != null) { addSidebarFacets(facetConfigurationRest, configuration.getSidebarFacets()); } return facetConfigurationRest; }  FacetConfigurationRest convert(final String configurationName, final String scope,
                                          DiscoveryConfiguration configuration);  }
@Test public void testReturnType() throws Exception { populateDiscoveryConfigurationWithEmptyList(); facetConfigurationRest = discoverFacetConfigurationConverter .convert(configurationName, scopeObject, discoveryConfiguration); assertTrue(facetConfigurationRest.getSidebarFacets().isEmpty()); assertEquals(FacetConfigurationRest.class, facetConfigurationRest.getClass()); }
@Test public void testConvertWithNullParamter() throws Exception { facetConfigurationRest = discoverFacetConfigurationConverter.convert(configurationName, scopeObject, null); assertNotNull(facetConfigurationRest); assertTrue(facetConfigurationRest.getSidebarFacets().isEmpty()); }
@Test public void testConvertWithConfigurationContainingSidebarFacetsFacetConfigurationRestContainsCorrectSidebarFacet() throws Exception { LinkedList<DiscoverySearchFilterFacet> discoverySearchFilterFacets = new LinkedList<>(); DiscoverySearchFilterFacet discoverySearchFilterFacet = new DiscoverySearchFilterFacet(); discoverySearchFilterFacet.setIndexFieldName("Testing"); discoverySearchFilterFacet.setType("test"); discoverySearchFilterFacets.add(discoverySearchFilterFacet); when(discoveryConfiguration.getSidebarFacets()).thenReturn(discoverySearchFilterFacets); facetConfigurationRest = discoverFacetConfigurationConverter .convert(configurationName, scopeObject, discoveryConfiguration); assertNotNull(facetConfigurationRest); assertTrue(!facetConfigurationRest.getSidebarFacets().isEmpty()); assertEquals(discoverySearchFilterFacet.getIndexFieldName(), facetConfigurationRest.getSidebarFacets().get(0).getName()); assertEquals(discoverySearchFilterFacet.getType(), facetConfigurationRest.getSidebarFacets().get(0).getFacetType()); }
@Test public void testConvertWithConfigurationContainingEmptySidebarFacetListFacetConfigurationRestSidebarFacetsIsEmpty() throws Exception { when(discoveryConfiguration.getSidebarFacets()).thenReturn(new LinkedList<DiscoverySearchFilterFacet>()); facetConfigurationRest = discoverFacetConfigurationConverter .convert(configurationName, scopeObject, discoveryConfiguration); assertNotNull(facetConfigurationRest); assertTrue(facetConfigurationRest.getSidebarFacets().isEmpty()); }
@Test public void testConvertWithConfigurationContainingNullSidebarFacetListFacetConfigurationRestSidebarFacetsIsEmpty() throws Exception { when(discoveryConfiguration.getSidebarFacets()).thenReturn(null); facetConfigurationRest = discoverFacetConfigurationConverter .convert(configurationName, scopeObject, discoveryConfiguration); assertNotNull(facetConfigurationRest); assertTrue(facetConfigurationRest.getSidebarFacets().isEmpty()); }