@Test public void testSearchWithoutResults() { prepareAndInitSession(); searchService.search("non-existing", 20, searchCallback); verify(searchCallback).afterSearch(searchResultsCaptor.capture()); LiveSearchResults<String> results = searchResultsCaptor.getValue(); assertEquals(0, results.size()); }
@Override public void search(String pattern, int maxResults, LiveSearchCallback<String> callback) { LiveSearchResults<String> results = new LiveSearchResults<>(maxResults); options.entrySet().stream() .filter(entry -> entry.getValue().toLowerCase().contains(pattern.toLowerCase())) .forEach(entry -> results.add(entry.getKey(), entry.getValue())); callback.afterSearch(results); }
VariableSearchService implements LiveSearchService<String> { @Override public void search(String pattern, int maxResults, LiveSearchCallback<String> callback) { LiveSearchResults<String> results = new LiveSearchResults<>(maxResults); options.entrySet().stream() .filter(entry -> entry.getValue().toLowerCase().contains(pattern.toLowerCase())) .forEach(entry -> results.add(entry.getKey(), entry.getValue())); callback.afterSearch(results); } }
VariableSearchService implements LiveSearchService<String> { @Override public void search(String pattern, int maxResults, LiveSearchCallback<String> callback) { LiveSearchResults<String> results = new LiveSearchResults<>(maxResults); options.entrySet().stream() .filter(entry -> entry.getValue().toLowerCase().contains(pattern.toLowerCase())) .forEach(entry -> results.add(entry.getKey(), entry.getValue())); callback.afterSearch(results); } @Inject  VariableSearchService(final ConditionEditorMetadataService metadataService,
                                 final ClientTranslationService translationService); }
VariableSearchService implements LiveSearchService<String> { @Override public void search(String pattern, int maxResults, LiveSearchCallback<String> callback) { LiveSearchResults<String> results = new LiveSearchResults<>(maxResults); options.entrySet().stream() .filter(entry -> entry.getValue().toLowerCase().contains(pattern.toLowerCase())) .forEach(entry -> results.add(entry.getKey(), entry.getValue())); callback.afterSearch(results); } @Inject  VariableSearchService(final ConditionEditorMetadataService metadataService,
                                 final ClientTranslationService translationService); void init(ClientSession session); @Override void search(String pattern, int maxResults, LiveSearchCallback<String> callback); @Override void searchEntry(String key, LiveSearchCallback<String> callback); String getOptionType(String key); void clear(); }
VariableSearchService implements LiveSearchService<String> { @Override public void search(String pattern, int maxResults, LiveSearchCallback<String> callback) { LiveSearchResults<String> results = new LiveSearchResults<>(maxResults); options.entrySet().stream() .filter(entry -> entry.getValue().toLowerCase().contains(pattern.toLowerCase())) .forEach(entry -> results.add(entry.getKey(), entry.getValue())); callback.afterSearch(results); } @Inject  VariableSearchService(final ConditionEditorMetadataService metadataService,
                                 final ClientTranslationService translationService); void init(ClientSession session); @Override void search(String pattern, int maxResults, LiveSearchCallback<String> callback); @Override void searchEntry(String key, LiveSearchCallback<String> callback); String getOptionType(String key); void clear();  }