[TEST] expand AbstractQueryTestCase#testQueryWrappedInArray to run against query alternate versions

This commit is contained in:
javanna 2016-08-08 19:09:43 +02:00 committed by Luca Cavanna
parent bf0e42aaeb
commit 329eaaea65
1 changed files with 9 additions and 2 deletions

View File

@ -339,10 +339,17 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
* Test that wraps the randomly generated query into an array as follows: { "query_name" : [{}]} * Test that wraps the randomly generated query into an array as follows: { "query_name" : [{}]}
* This causes unexpected situations in parser code that may not be handled properly. * This causes unexpected situations in parser code that may not be handled properly.
*/ */
public void testQueryWrappedInArray() throws IOException { public final void testQueryWrappedInArray() throws IOException {
QB queryBuilder = createTestQueryBuilder(); QB queryBuilder = createTestQueryBuilder();
String validQuery = queryBuilder.toString();
String queryName = queryBuilder.getName(); String queryName = queryBuilder.getName();
String validQuery = queryBuilder.toString();
queryWrappedInArrayTest(queryName, validQuery);
for (String query : getAlternateVersions().keySet()) {
queryWrappedInArrayTest(queryName, query);
}
}
private void queryWrappedInArrayTest(String queryName, String validQuery) throws IOException {
int i = validQuery.indexOf("\"" + queryName + "\""); int i = validQuery.indexOf("\"" + queryName + "\"");
assertThat(i, greaterThan(0)); assertThat(i, greaterThan(0));