@Test public void testSearchWhenAnyElementIsFound() { index.search("Something"); verify(searchable1, never()).onFound(); verify(searchable2, never()).onFound(); verify(searchable3, never()).onFound(); verify(searchable4, never()).onFound(); verify(noResultsFoundCallback).execute(); verify(searchPerformedCallback).execute(); }
@Override public void search(final String term) { triggerClearCurrentResultsCallback(); final boolean isNewSearch = !Objects.equals(term, currentTerm) || isDirty(); final Optional<T> result; if (isNewSearch) { loadSearchResults(term); result = getFirstSearchResult(); } else { result = findNextElement(); } currentResult = result.orElse(null); currentTerm = term; triggerOnFoundCommand(); triggerOnSearchPerformedCommand(); }
BaseEditorSearchIndex implements EditorSearchIndex<T> { @Override public void search(final String term) { triggerClearCurrentResultsCallback(); final boolean isNewSearch = !Objects.equals(term, currentTerm) || isDirty(); final Optional<T> result; if (isNewSearch) { loadSearchResults(term); result = getFirstSearchResult(); } else { result = findNextElement(); } currentResult = result.orElse(null); currentTerm = term; triggerOnFoundCommand(); triggerOnSearchPerformedCommand(); } }
BaseEditorSearchIndex implements EditorSearchIndex<T> { @Override public void search(final String term) { triggerClearCurrentResultsCallback(); final boolean isNewSearch = !Objects.equals(term, currentTerm) || isDirty(); final Optional<T> result; if (isNewSearch) { loadSearchResults(term); result = getFirstSearchResult(); } else { result = findNextElement(); } currentResult = result.orElse(null); currentTerm = term; triggerOnFoundCommand(); triggerOnSearchPerformedCommand(); }  }
BaseEditorSearchIndex implements EditorSearchIndex<T> { @Override public void search(final String term) { triggerClearCurrentResultsCallback(); final boolean isNewSearch = !Objects.equals(term, currentTerm) || isDirty(); final Optional<T> result; if (isNewSearch) { loadSearchResults(term); result = getFirstSearchResult(); } else { result = findNextElement(); } currentResult = result.orElse(null); currentTerm = term; triggerOnFoundCommand(); triggerOnSearchPerformedCommand(); }  @Override void setSearchPerformedCallback(final Command searchPerformedCallback); @Override List<HasSearchableElements<T>> getSubIndexes(); @Override void registerSubIndex(final HasSearchableElements<T> hasSearchableElements); @Override void search(final String term); @Override int getCurrentResultNumber(); @Override int getTotalOfResultsNumber(); @Override void close(); @Override void setNoResultsFoundCallback(final Command callback); @Override void setClearCurrentResultsCallback(final Command callback); @Override void setSearchClosedCallback(final Command searchClosedCallback); @Override boolean isDirty(); @Override void nextResult(); @Override void previousResult(); @Override Integer getCurrentAssetHashcode(); void setCurrentAssetHashcodeSupplier(final Supplier<Integer> currentAssetHashcodeSupplier); @Override Optional<T> getCurrentResult(); }
BaseEditorSearchIndex implements EditorSearchIndex<T> { @Override public void search(final String term) { triggerClearCurrentResultsCallback(); final boolean isNewSearch = !Objects.equals(term, currentTerm) || isDirty(); final Optional<T> result; if (isNewSearch) { loadSearchResults(term); result = getFirstSearchResult(); } else { result = findNextElement(); } currentResult = result.orElse(null); currentTerm = term; triggerOnFoundCommand(); triggerOnSearchPerformedCommand(); }  @Override void setSearchPerformedCallback(final Command searchPerformedCallback); @Override List<HasSearchableElements<T>> getSubIndexes(); @Override void registerSubIndex(final HasSearchableElements<T> hasSearchableElements); @Override void search(final String term); @Override int getCurrentResultNumber(); @Override int getTotalOfResultsNumber(); @Override void close(); @Override void setNoResultsFoundCallback(final Command callback); @Override void setClearCurrentResultsCallback(final Command callback); @Override void setSearchClosedCallback(final Command searchClosedCallback); @Override boolean isDirty(); @Override void nextResult(); @Override void previousResult(); @Override Integer getCurrentAssetHashcode(); void setCurrentAssetHashcodeSupplier(final Supplier<Integer> currentAssetHashcodeSupplier); @Override Optional<T> getCurrentResult();  }