@Test public void positionalAndNamedParameters() { String statement = "select doc.fullName from XWikiDocument doc where " + "doc.fullName like :fullName escape '/' and " + "doc.author like ? or " + "doc.version = :version and " + "doc.space like ? escape '!'"; Query query = mock(Query.class); when(query.getLanguage()).thenReturn(Query.HQL); when(query.getStatement()).thenReturn(statement); Map<String, Object> namedParameters = new LinkedHashMap<>(); namedParameters.put("fullName", new DefaultQueryParameter(null).literal("Space namedParameters.put("version", "1.1"); when(query.getNamedParameters()).thenReturn(namedParameters); Map<Integer, Object> positionalParameters = new LinkedHashMap<>(); positionalParameters.put(0, new DefaultQueryParameter(null).like("Bar!")); positionalParameters.put(1, new DefaultQueryParameter(null).like("%Foo!%")); when(query.getPositionalParameters()).thenReturn(positionalParameters); Query filteredQuery = this.filter.filterQuery(query); String modifiedStatement = "SELECT doc.fullName FROM XWikiDocument doc WHERE " + "doc.fullName LIKE :fullName ESCAPE '/' AND " + "doc.author LIKE ? ESCAPE '!' OR " + "doc.version = :version AND " + "doc.space LIKE ? ESCAPE '!'"; assertEquals(modifiedStatement, filteredQuery.getStatement()); Map<String, Object> expectedNamedMap = new LinkedHashMap<>(); expectedNamedMap.put("fullName", "Space expectedNamedMap.put("version", "1.1"); assertEquals(expectedNamedMap, filteredQuery.getNamedParameters()); Map<Integer, Object> expectedPositionalMap = new LinkedHashMap<>(); expectedPositionalMap.put(0, "Bar!!"); expectedPositionalMap.put(1, "%Foo!!%"); assertEquals(expectedPositionalMap, filteredQuery.getPositionalParameters()); }
@Override public Query filterQuery(Query query) { return new EscapeLikeParametersQuery(query); }
EscapeLikeParametersFilter implements QueryFilter { @Override public Query filterQuery(Query query) { return new EscapeLikeParametersQuery(query); } }
EscapeLikeParametersFilter implements QueryFilter { @Override public Query filterQuery(Query query) { return new EscapeLikeParametersQuery(query); }  }
EscapeLikeParametersFilter implements QueryFilter { @Override public Query filterQuery(Query query) { return new EscapeLikeParametersQuery(query); }  @Override Query filterQuery(Query query); @Override String filterStatement(String statement, String language); @Override List filterResults(List results); }
EscapeLikeParametersFilter implements QueryFilter { @Override public Query filterQuery(Query query) { return new EscapeLikeParametersQuery(query); }  @Override Query filterQuery(Query query); @Override String filterStatement(String statement, String language); @Override List filterResults(List results);  }