PersistentSuggestionSource implements SuggestionSource { @Override public List<T> getSuggestions(SuggestionQuery query) { return loadValues().stream() .filter(s -> filterFunction.apply(s, query)) .collect(toList()); } PersistentSuggestionSource(
      String persistKey,
      PersistService persistService,
      BiFunction<T, SuggestionQuery, Boolean> filterFunction,
      Function<T, String> serializer,
      Function<String, T> deserializer); @Override List<T> getSuggestions(SuggestionQuery query); @SafeVarargs final void add(T... values);  }
@Test public void testGetSuggestions() throws Exception { when(persistService.load(eq("key"), eq(""), any(Deserializer.class))).thenReturn("1111\n1112\n3232"); final List<Integer> suggestions = suggestionSource.getSuggestions(new SuggestionQuery("11", 0)); assertEquals(suggestions.size(), 2); assertEquals(suggestions, Arrays.asList(1111, 1112)); }