@Test public void testShowSearchResults() { final DNDListComponent dndListComponent = mock(DNDListComponent.class); final DataType dataType0 = mock(DataType.class); final DataType dataType1 = mock(DataType.class); final DataType dataType2 = mock(DataType.class); final DataTypeListItem listItem0 = mock(DataTypeListItem.class); final DataTypeListItem listItem1 = mock(DataTypeListItem.class); final DataTypeListItem listItem2 = mock(DataTypeListItem.class); final DataTypeListItem listItem3 = mock(DataTypeListItem.class); final HTMLElement element0 = mock(HTMLElement.class); final HTMLElement element1 = mock(HTMLElement.class); final HTMLElement element2 = mock(HTMLElement.class); final HTMLElement element3 = mock(HTMLElement.class); final List<DataType> results = asList(dataType0, dataType1, dataType2); final List<DataTypeListItem> listItems = asList(listItem0, listItem1, listItem2, listItem3); element0.classList = mock(DOMTokenList.class); element1.classList = mock(DOMTokenList.class); element2.classList = mock(DOMTokenList.class); element3.classList = mock(DOMTokenList.class); when(listItem0.getDataType()).thenReturn(dataType0); when(listItem1.getDataType()).thenReturn(dataType1); when(listItem2.getDataType()).thenReturn(dataType2); when(listItem0.getDragAndDropElement()).thenReturn(element0); when(listItem1.getDragAndDropElement()).thenReturn(element1); when(listItem2.getDragAndDropElement()).thenReturn(element2); when(listItem3.getDragAndDropElement()).thenReturn(element3); when(presenter.getDataTypeListItemsSortedByPositionY()).thenReturn(listItems); when(presenter.getDNDListComponent()).thenReturn(dndListComponent); doNothing().when(view).enableSearch(); view.showSearchResults(results); verify(element0.classList).remove(HIDDEN_CSS_CLASS); verify(element1.classList).remove(HIDDEN_CSS_CLASS); verify(element2.classList).remove(HIDDEN_CSS_CLASS); verify(element3.classList).add(HIDDEN_CSS_CLASS); verify(dndListComponent).setPositionY(element0, 0); verify(dndListComponent).setPositionY(element1, 1); verify(dndListComponent).setPositionY(element2, 2); verify(dndListComponent).setPositionY(element3, -1); verify(dndListComponent).refreshItemsPosition(); verify(dndListComponent).refreshDragAreaSize(); verify(listItem0).expand(); verify(listItem1).expand(); verify(listItem2).expand(); verify(view).enableSearch(); verify(view).groupElementsWithItsParents(listItems); verify(view).expandListItems(listItems); }
@Override public void showSearchResults(final List<DataType> results) { final AtomicInteger position = new AtomicInteger(0); final List<DataTypeListItem> listItems = presenter.getDataTypeListItemsSortedByPositionY(); expandListItems(listItems); final List<DataTypeListItem> grouped = groupElementsWithItsParents(listItems); for (final DataTypeListItem listItem : grouped) { final HTMLElement element = listItem.getDragAndDropElement(); if (results.contains(listItem.getDataType())) { showElementAt(element, position); } else { hideElement(element); } } refreshItemsPosition(); enableSearch(); refreshDragAreaSize(); }
DataTypeSearchBarView implements DataTypeSearchBar.View { @Override public void showSearchResults(final List<DataType> results) { final AtomicInteger position = new AtomicInteger(0); final List<DataTypeListItem> listItems = presenter.getDataTypeListItemsSortedByPositionY(); expandListItems(listItems); final List<DataTypeListItem> grouped = groupElementsWithItsParents(listItems); for (final DataTypeListItem listItem : grouped) { final HTMLElement element = listItem.getDragAndDropElement(); if (results.contains(listItem.getDataType())) { showElementAt(element, position); } else { hideElement(element); } } refreshItemsPosition(); enableSearch(); refreshDragAreaSize(); } }
DataTypeSearchBarView implements DataTypeSearchBar.View { @Override public void showSearchResults(final List<DataType> results) { final AtomicInteger position = new AtomicInteger(0); final List<DataTypeListItem> listItems = presenter.getDataTypeListItemsSortedByPositionY(); expandListItems(listItems); final List<DataTypeListItem> grouped = groupElementsWithItsParents(listItems); for (final DataTypeListItem listItem : grouped) { final HTMLElement element = listItem.getDragAndDropElement(); if (results.contains(listItem.getDataType())) { showElementAt(element, position); } else { hideElement(element); } } refreshItemsPosition(); enableSearch(); refreshDragAreaSize(); } @Inject  DataTypeSearchBarView(final HTMLInputElement searchBar,
                                 final @Named("span") HTMLElement searchIcon,
                                 final HTMLButtonElement closeSearch,
                                 final TranslationService translationService); }
DataTypeSearchBarView implements DataTypeSearchBar.View { @Override public void showSearchResults(final List<DataType> results) { final AtomicInteger position = new AtomicInteger(0); final List<DataTypeListItem> listItems = presenter.getDataTypeListItemsSortedByPositionY(); expandListItems(listItems); final List<DataTypeListItem> grouped = groupElementsWithItsParents(listItems); for (final DataTypeListItem listItem : grouped) { final HTMLElement element = listItem.getDragAndDropElement(); if (results.contains(listItem.getDataType())) { showElementAt(element, position); } else { hideElement(element); } } refreshItemsPosition(); enableSearch(); refreshDragAreaSize(); } @Inject  DataTypeSearchBarView(final HTMLInputElement searchBar,
                                 final @Named("span") HTMLElement searchIcon,
                                 final HTMLButtonElement closeSearch,
                                 final TranslationService translationService); @PostConstruct void setupSearchBar(); @Override void init(final DataTypeSearchBar presenter); @EventHandler("close-search") void onSearchBarCloseButton(final ClickEvent e); @EventHandler("search-bar") void onSearchBarKeyUpEvent(final KeyUpEvent event); @EventHandler("search-bar") void onSearchBarKeyDownEvent(final KeyDownEvent e); @EventHandler("search-bar") void onSearchBarChangeEvent(final ChangeEvent e); @Override void resetSearchBar(); @Override void showSearchResults(final List<DataType> results); void refreshItemsPosition(); }
DataTypeSearchBarView implements DataTypeSearchBar.View { @Override public void showSearchResults(final List<DataType> results) { final AtomicInteger position = new AtomicInteger(0); final List<DataTypeListItem> listItems = presenter.getDataTypeListItemsSortedByPositionY(); expandListItems(listItems); final List<DataTypeListItem> grouped = groupElementsWithItsParents(listItems); for (final DataTypeListItem listItem : grouped) { final HTMLElement element = listItem.getDragAndDropElement(); if (results.contains(listItem.getDataType())) { showElementAt(element, position); } else { hideElement(element); } } refreshItemsPosition(); enableSearch(); refreshDragAreaSize(); } @Inject  DataTypeSearchBarView(final HTMLInputElement searchBar,
                                 final @Named("span") HTMLElement searchIcon,
                                 final HTMLButtonElement closeSearch,
                                 final TranslationService translationService); @PostConstruct void setupSearchBar(); @Override void init(final DataTypeSearchBar presenter); @EventHandler("close-search") void onSearchBarCloseButton(final ClickEvent e); @EventHandler("search-bar") void onSearchBarKeyUpEvent(final KeyUpEvent event); @EventHandler("search-bar") void onSearchBarKeyDownEvent(final KeyDownEvent e); @EventHandler("search-bar") void onSearchBarChangeEvent(final ChangeEvent e); @Override void resetSearchBar(); @Override void showSearchResults(final List<DataType> results); void refreshItemsPosition();  }