[TEST] refactor DummyQueryBuilder and corresponding parser

DummyQueryParser properly implements now fromXContent and the corresponding builder supports converting to the corresponding lucene query through toQuery method.
This commit is contained in:
javanna 2015-08-31 10:00:09 +02:00 committed by Luca Cavanna
parent 1420482f86
commit cc408ddd45
1 changed files with 9 additions and 4 deletions

View File

@ -55,23 +55,28 @@ public class DummyQueryParserPlugin extends Plugin {
builder.startObject(NAME).endObject();
}
@Override
protected Query doToQuery(QueryShardContext context) throws IOException {
return new DummyQuery(context.isFilter());
}
@Override
public String getWriteableName() {
return NAME;
}
}
public static class DummyQueryParser extends BaseQueryParserTemp {
public static class DummyQueryParser extends BaseQueryParser {
@Override
public String[] names() {
return new String[]{DummyQueryBuilder.NAME};
}
@Override
public Query parse(QueryShardContext context) throws IOException, QueryShardException {
XContentParser.Token token = context.parseContext().parser().nextToken();
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
XContentParser.Token token = parseContext.parser().nextToken();
assert token == XContentParser.Token.END_OBJECT;
return new DummyQuery(context.isFilter());
return new DummyQueryBuilder();
}
@Override