### Question:
VariableSearchService implements LiveSearchService<String> { @Override public void searchEntry(String key, LiveSearchCallback<String> callback) { LiveSearchResults<String> results = new LiveSearchResults<>(); if (options.containsKey(key)) { results.add(key, options.get(key)); } 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();  }### Answer:
@Test @SuppressWarnings("unchecked") public void testSearchEntryWithResults() { prepareAndInitSession(); List<Pair<String, String>> expectedVariables = buildExpectedVariableNames(MULTIPLE_INSTANCE_SUBPROCESS, 17); for (int i = 0; i < expectedVariables.size(); i++) { searchService.searchEntry(expectedVariables.get(i).getK1(), searchCallback); verify(searchCallback, times(i + 1)).afterSearch(searchResultsCaptor.capture()); verifyContains(searchResultsCaptor.getValue(), expectedVariables.get(i)); } }
@Test @SuppressWarnings("unchecked") public void testSearchEntryWithoutResults() { prepareAndInitSession(); List<String> checkedVariables = Arrays.asList("not-existing1", "not-existing2", "not-existing3", "and_so_on"); for (int i = 0; i < checkedVariables.size(); i++) { searchService.searchEntry(checkedVariables.get(i), searchCallback); verify(searchCallback, times(i + 1)).afterSearch(searchResultsCaptor.capture()); verifyNotContains(searchResultsCaptor.getValue(), new Pair<>(checkedVariables.get(i), checkedVariables.get(i))); } }