Skip to content

Commit

Permalink
PR feedback & update test
Browse files Browse the repository at this point in the history
  • Loading branch information
kderusso committed Dec 11, 2024
1 parent 5d13449 commit f20a353
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public Query toQuery(SearchExecutionContext context) throws IOException {

@Override
public QueryBuilder queryName(String queryName) {
return new InterceptedQueryBuilderWrapper(queryBuilder.queryName(queryName));
queryBuilder.queryName(queryName);
return this;
}

@Override
Expand All @@ -75,7 +76,8 @@ public float boost() {

@Override
public QueryBuilder boost(float boost) {
return new InterceptedQueryBuilderWrapper(queryBuilder.boost(boost));
queryBuilder.boost(boost);
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ public class InterceptedQueryBuilderWrapperTests extends ESTestCase {
public void testQueryNameReturnsWrappedQueryBuilder() {
MatchAllQueryBuilder matchAllQueryBuilder = new MatchAllQueryBuilder();
InterceptedQueryBuilderWrapper interceptedQueryBuilderWrapper = new InterceptedQueryBuilderWrapper(matchAllQueryBuilder);
QueryBuilder namedQuery = interceptedQueryBuilderWrapper.queryName(randomAlphaOfLengthBetween(5, 10));
String queryName = randomAlphaOfLengthBetween(5, 10);
QueryBuilder namedQuery = interceptedQueryBuilderWrapper.queryName(queryName);
assertTrue(namedQuery instanceof InterceptedQueryBuilderWrapper);
assertEquals(queryName, namedQuery.queryName());
}

public void testQueryBoostReturnsWrappedQueryBuilder() {
MatchAllQueryBuilder matchAllQueryBuilder = new MatchAllQueryBuilder();
InterceptedQueryBuilderWrapper interceptedQueryBuilderWrapper = new InterceptedQueryBuilderWrapper(matchAllQueryBuilder);
QueryBuilder boostedQuery = interceptedQueryBuilderWrapper.boost(randomFloat());
float boost = randomFloat();
QueryBuilder boostedQuery = interceptedQueryBuilderWrapper.boost(boost);
assertTrue(boostedQuery instanceof InterceptedQueryBuilderWrapper);
assertEquals(boost, boostedQuery.boost(), 0.0001f);
}
}

0 comments on commit f20a353

Please sign in to comment.