[TEST] minor change in BaseQueryTestCase#toQuery

Simplified if when we decide what to do based on the query and return value of supportsBoostAndQueryName
This commit is contained in:
javanna 2015-08-13 16:12:54 +02:00 committed by Luca Cavanna
parent a67ee73ee2
commit 135aab0092
1 changed files with 4 additions and 6 deletions

View File

@ -256,14 +256,12 @@ public abstract class BaseQueryTestCase<QB extends AbstractQueryBuilder<QB>> ext
assertThat("two equivalent query builders lead to different lucene queries", secondLuceneQuery, equalTo(firstLuceneQuery));
//if the initial lucene query is null, changing its boost won't have any effect, we shouldn't test that
//few queries also don't support boost, their setter is a no-op
//otherwise makes sure that boost is taken into account in toQuery
if (firstLuceneQuery != null) {
if (firstLuceneQuery != null && supportsBoostAndQueryName()) {
secondQuery.boost(firstQuery.boost() + 1f + randomFloat());
//some queries don't support boost, their setter is a no-op
if (supportsBoostAndQueryName()) {
Query thirdLuceneQuery = secondQuery.toQuery(context);
assertThat("modifying the boost doesn't affect the corresponding lucene query", firstLuceneQuery, not(equalTo(thirdLuceneQuery)));
}
Query thirdLuceneQuery = secondQuery.toQuery(context);
assertThat("modifying the boost doesn't affect the corresponding lucene query", firstLuceneQuery, not(equalTo(thirdLuceneQuery)));
}
}
}