JsonXpathSuggestionSource implements SuggestionSource<BasicSuggestion> { protected List<BasicSuggestion> suggestionsForTypeJson(String line, int position) { final String substring1 = line.substring(0, position); final String substring = substring1.replaceFirst(".*?=", "").trim(); final String toInsert = StringUtils.removeStart(JSON, substring); return Collections.singletonList(new BasicSuggestion(JSON, toInsert)); } JsonXpathSuggestionSource(); void setJsonPaths(Set<String> jsonPaths); void setJsonDoc(String jsonDoc); void setPropertyDoc(String propertyDoc); @Override List<BasicSuggestion> getSuggestions(SuggestionQuery query); static final String JSON; }
@Test(dataProvider = "suggestionForTypeJson") public void suggestionsForTypeJson(String line, int position, List<BasicSuggestion> expected) { final JsonXpathSuggestionSource underTest = new JsonXpathSuggestionSource(); underTest.setJsonPaths(xpaths); final List<BasicSuggestion> result = underTest.suggestionsForTypeJson(line, position); assertEquals(result, expected); }