@Test public void testFilterByName() { NewResourceHandler resourceHandler = mock(NewResourceHandler.class, Answers.RETURNS_DEEP_STUBS.get()); when(resourceHandler.getDescription()).thenReturn("demo"); when(resourceHandler.getResourceType().getCategory()).thenReturn(new Decision()); { List<NewResourceHandler> filtered = this.addAssetScreen.filterAndSortHandlers(Arrays.asList(resourceHandler), "de", new Undefined()); assertEquals(resourceHandler, filtered.get(0)); } { List<NewResourceHandler> filtered = this.addAssetScreen.filterAndSortHandlers(Arrays.asList(resourceHandler), "ja", new Undefined()); assertTrue(filtered.isEmpty()); } }
protected List<NewResourceHandler> filterAndSortHandlers(List<NewResourceHandler> handlers, String textFilter, Category category) { Stream<NewResourceHandler> filtered = handlers .stream() .filter(handler -> handler.getDescription().toLowerCase().contains(textFilter.toLowerCase())); if (!category.equals(new Undefined())) { filtered = filtered.filter(resourceHandler -> category.equals(resourceHandler.getResourceType().getCategory())); } return filtered.sorted(Comparator.comparing(r -> r.getDescription().toLowerCase())) .collect(Collectors.toList()); }
AddAssetScreen { protected List<NewResourceHandler> filterAndSortHandlers(List<NewResourceHandler> handlers, String textFilter, Category category) { Stream<NewResourceHandler> filtered = handlers .stream() .filter(handler -> handler.getDescription().toLowerCase().contains(textFilter.toLowerCase())); if (!category.equals(new Undefined())) { filtered = filtered.filter(resourceHandler -> category.equals(resourceHandler.getResourceType().getCategory())); } return filtered.sorted(Comparator.comparing(r -> r.getDescription().toLowerCase())) .collect(Collectors.toList()); } }
AddAssetScreen { protected List<NewResourceHandler> filterAndSortHandlers(List<NewResourceHandler> handlers, String textFilter, Category category) { Stream<NewResourceHandler> filtered = handlers .stream() .filter(handler -> handler.getDescription().toLowerCase().contains(textFilter.toLowerCase())); if (!category.equals(new Undefined())) { filtered = filtered.filter(resourceHandler -> category.equals(resourceHandler.getResourceType().getCategory())); } return filtered.sorted(Comparator.comparing(r -> r.getDescription().toLowerCase())) .collect(Collectors.toList()); } AddAssetScreen(); @Inject  AddAssetScreen(final AddAssetScreen.View view,
                          final TranslationService ts,
                          final ResourceHandlerManager resourceHandlerManager,
                          final CategoriesManagerCache categoriesManagerCache,
                          final ManagedInstance<NewAssetHandlerCardWidget> newAssetHandlerCardWidgets,
                          final LibraryConstants libraryConstants,
                          final CategoryUtils categoryUtils,
                          final LibraryPlaces libraryPlaces,
                          final ProfilePreferences profilesPreferences); }
AddAssetScreen { protected List<NewResourceHandler> filterAndSortHandlers(List<NewResourceHandler> handlers, String textFilter, Category category) { Stream<NewResourceHandler> filtered = handlers .stream() .filter(handler -> handler.getDescription().toLowerCase().contains(textFilter.toLowerCase())); if (!category.equals(new Undefined())) { filtered = filtered.filter(resourceHandler -> category.equals(resourceHandler.getResourceType().getCategory())); } return filtered.sorted(Comparator.comparing(r -> r.getDescription().toLowerCase())) .collect(Collectors.toList()); } AddAssetScreen(); @Inject  AddAssetScreen(final AddAssetScreen.View view,
                          final TranslationService ts,
                          final ResourceHandlerManager resourceHandlerManager,
                          final CategoriesManagerCache categoriesManagerCache,
                          final ManagedInstance<NewAssetHandlerCardWidget> newAssetHandlerCardWidgets,
                          final LibraryConstants libraryConstants,
                          final CategoryUtils categoryUtils,
                          final LibraryPlaces libraryPlaces,
                          final ProfilePreferences profilesPreferences); @PostConstruct void initialize(); @OnOpen void onOpen(); void setFilter(String filter); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView AddAssetScreen.View getView(); void setFilterType(String filterType); void cancel(); }
AddAssetScreen { protected List<NewResourceHandler> filterAndSortHandlers(List<NewResourceHandler> handlers, String textFilter, Category category) { Stream<NewResourceHandler> filtered = handlers .stream() .filter(handler -> handler.getDescription().toLowerCase().contains(textFilter.toLowerCase())); if (!category.equals(new Undefined())) { filtered = filtered.filter(resourceHandler -> category.equals(resourceHandler.getResourceType().getCategory())); } return filtered.sorted(Comparator.comparing(r -> r.getDescription().toLowerCase())) .collect(Collectors.toList()); } AddAssetScreen(); @Inject  AddAssetScreen(final AddAssetScreen.View view,
                          final TranslationService ts,
                          final ResourceHandlerManager resourceHandlerManager,
                          final CategoriesManagerCache categoriesManagerCache,
                          final ManagedInstance<NewAssetHandlerCardWidget> newAssetHandlerCardWidgets,
                          final LibraryConstants libraryConstants,
                          final CategoryUtils categoryUtils,
                          final LibraryPlaces libraryPlaces,
                          final ProfilePreferences profilesPreferences); @PostConstruct void initialize(); @OnOpen void onOpen(); void setFilter(String filter); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView AddAssetScreen.View getView(); void setFilterType(String filterType); void cancel();  }