-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Match Query Unit Tests #56
Adding Match Query Unit Tests #56
Conversation
… avoid NoSuchElementException in MatchQuery Signed-off-by: forestmvey <[email protected]>
Signed-off-by: forestmvey <[email protected]>
Signed-off-by: forestmvey <[email protected]>
...src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/MatchQueryTest.java
Show resolved
Hide resolved
...src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/MatchQueryTest.java
Show resolved
Hide resolved
...src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/MatchQueryTest.java
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## integ-match_query_unit_tests #56 +/- ##
===============================================================
Coverage 97.67% 97.67%
- Complexity 2743 2744 +1
===============================================================
Files 266 266
Lines 6797 6799 +2
Branches 433 433
===============================================================
+ Hits 6639 6641 +2
Misses 157 157
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
...src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/MatchQueryTest.java
Outdated
Show resolved
Hide resolved
…ng exceptions and moved private method definition placement below public methods Signed-off-by: forestmvey <[email protected]>
...src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/MatchQueryTest.java
Outdated
Show resolved
Hide resolved
...in/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/MatchQuery.java
Show resolved
Hide resolved
@forestmvey, |
… Fixed checkstyle syntax errors. Signed-off-by: forestmvey <[email protected]>
...src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/MatchQueryTest.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/MatchQueryTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: forestmvey <[email protected]>
@@ -31,6 +33,82 @@ public class MatchQueryTest { | |||
private final MatchQuery matchQuery = new MatchQuery(); | |||
private final FunctionName match = FunctionName.of("match"); | |||
|
|||
static Stream<List<Expression>> generateValidData() { | |||
final DSL dsl = new ExpressionConfig().dsl(new ExpressionConfig().functionRepository()); | |||
return Stream.of( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Another option is to take the list of valid args and build the stream of test cases from it.
Something like:
NamedArgument field = dsl.namedArgument("field", DSL.literal("field_value"));
NamedArgument query = dsl.namedArgument("query", DSL.literal("query_value"));
return List.of(
dsl.namedArgument("analyzer", "standard"),
dsl.namedArgument("auto_generate_synonyms_phrase_query", "true"),
dsl.namedArgument("fuzziness", "AUTO"),
dsl.namedArgument("max_expansions", "50"),
dsl.namedArgument("prefix_length", "0"),
dsl.namedArgument("fuzzy_transpositions", "true"),
dsl.namedArgument("fuzzy_rewrite", "constant_score"),
dsl.namedArgument("lenient", "false"),
dsl.namedArgument("operator", "OR"),
dsl.namedArgument("minimum_should_match", "3"),
dsl.namedArgument("zero_terms_query", "NONE"),
dsl.namedArgument("boost", "1"))
.stream().map(arg -> List.of(field, query, arg));
build_succeeds_with_two_arguments
would need to be kept.
return Stream.of( | ||
List.of( | ||
dsl.namedArgument("field", DSL.literal("field_value")), | ||
dsl.namedArgument("query", DSL.literal("query_value")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could create
NamedArgument fieldArgument = dsl.namedArgument("field", DSL.literal("field_value"));
NamedArgument queryArgument = dsl.namedArgument("query", DSL.literal("query_value"));
once and pass it to all these lists. If you make it static and global to the class, you can use it in other tests ;)
Description
Add unit tests for match function implementation with 100% code coverage.
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.