@Test public void testCorrectSortOptionsAfterConvert() throws Exception { populateDiscoveryConfigurationWithEmptyList(); DiscoverySortFieldConfiguration discoverySortFieldConfiguration = new DiscoverySortFieldConfiguration(); discoverySortFieldConfiguration.setMetadataField("title"); discoverySortFieldConfiguration.setType("text"); DiscoverySortFieldConfiguration discoverySortFieldConfiguration1 = new DiscoverySortFieldConfiguration(); discoverySortFieldConfiguration1.setMetadataField("author"); discoverySortFieldConfiguration1.setType("text"); LinkedList<DiscoverySortFieldConfiguration> mockedList = new LinkedList<>(); mockedList.add(discoverySortFieldConfiguration); mockedList.add(discoverySortFieldConfiguration1); when(discoveryConfiguration.getSearchSortConfiguration()).thenReturn(discoverySortConfiguration); when(discoverySortConfiguration.getSortFields()).thenReturn(mockedList); searchConfigurationRest = discoverConfigurationConverter.convert(discoveryConfiguration, Projection.DEFAULT); int counter = 0; for (SearchConfigurationRest.SortOption sortOption : searchConfigurationRest.getSortOptions()) { assertEquals(mockedList.get(counter).getMetadataField(), sortOption.getName()); assertEquals(mockedList.get(counter).getType(), sortOption.getActualName()); counter++; } assertFalse(searchConfigurationRest.getSortOptions().isEmpty()); }
@Override public SearchConfigurationRest convert(DiscoveryConfiguration configuration, Projection projection) { SearchConfigurationRest searchConfigurationRest = new SearchConfigurationRest(); searchConfigurationRest.setProjection(projection); if (configuration != null) { addSearchFilters(searchConfigurationRest, configuration.getSearchFilters(), configuration.getSidebarFacets()); addSortOptions(searchConfigurationRest, configuration.getSearchSortConfiguration()); setDefaultSortOption(configuration, searchConfigurationRest); } return searchConfigurationRest; }
DiscoverConfigurationConverter implements DSpaceConverter<DiscoveryConfiguration, SearchConfigurationRest> { @Override public SearchConfigurationRest convert(DiscoveryConfiguration configuration, Projection projection) { SearchConfigurationRest searchConfigurationRest = new SearchConfigurationRest(); searchConfigurationRest.setProjection(projection); if (configuration != null) { addSearchFilters(searchConfigurationRest, configuration.getSearchFilters(), configuration.getSidebarFacets()); addSortOptions(searchConfigurationRest, configuration.getSearchSortConfiguration()); setDefaultSortOption(configuration, searchConfigurationRest); } return searchConfigurationRest; } }
DiscoverConfigurationConverter implements DSpaceConverter<DiscoveryConfiguration, SearchConfigurationRest> { @Override public SearchConfigurationRest convert(DiscoveryConfiguration configuration, Projection projection) { SearchConfigurationRest searchConfigurationRest = new SearchConfigurationRest(); searchConfigurationRest.setProjection(projection); if (configuration != null) { addSearchFilters(searchConfigurationRest, configuration.getSearchFilters(), configuration.getSidebarFacets()); addSortOptions(searchConfigurationRest, configuration.getSearchSortConfiguration()); setDefaultSortOption(configuration, searchConfigurationRest); } return searchConfigurationRest; }  }
DiscoverConfigurationConverter implements DSpaceConverter<DiscoveryConfiguration, SearchConfigurationRest> { @Override public SearchConfigurationRest convert(DiscoveryConfiguration configuration, Projection projection) { SearchConfigurationRest searchConfigurationRest = new SearchConfigurationRest(); searchConfigurationRest.setProjection(projection); if (configuration != null) { addSearchFilters(searchConfigurationRest, configuration.getSearchFilters(), configuration.getSidebarFacets()); addSortOptions(searchConfigurationRest, configuration.getSearchSortConfiguration()); setDefaultSortOption(configuration, searchConfigurationRest); } return searchConfigurationRest; }  @Override SearchConfigurationRest convert(DiscoveryConfiguration configuration, Projection projection); @Override Class<DiscoveryConfiguration> getModelClass(); void addSearchFilters(SearchConfigurationRest searchConfigurationRest,
                                 List<DiscoverySearchFilter> searchFilterList,
                                 List<DiscoverySearchFilterFacet> facetList); }
DiscoverConfigurationConverter implements DSpaceConverter<DiscoveryConfiguration, SearchConfigurationRest> { @Override public SearchConfigurationRest convert(DiscoveryConfiguration configuration, Projection projection) { SearchConfigurationRest searchConfigurationRest = new SearchConfigurationRest(); searchConfigurationRest.setProjection(projection); if (configuration != null) { addSearchFilters(searchConfigurationRest, configuration.getSearchFilters(), configuration.getSidebarFacets()); addSortOptions(searchConfigurationRest, configuration.getSearchSortConfiguration()); setDefaultSortOption(configuration, searchConfigurationRest); } return searchConfigurationRest; }  @Override SearchConfigurationRest convert(DiscoveryConfiguration configuration, Projection projection); @Override Class<DiscoveryConfiguration> getModelClass(); void addSearchFilters(SearchConfigurationRest searchConfigurationRest,
                                 List<DiscoverySearchFilter> searchFilterList,
                                 List<DiscoverySearchFilterFacet> facetList);  }