Skip to content

Commit

Permalink
Made Adjustments To Tests
Browse files Browse the repository at this point in the history
Signed-off-by: GabeFernandez310 <gabrielf@bitquilltech.com>
  • Loading branch information
GabeFernandez310 committed Nov 21, 2022
1 parent 2774e66 commit 72580ed
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void test_alternate_syntax_for_match_phrase_returns_same_result() throws
JSONObject result1 = executeJdbcRequest(String.format(query1, TEST_INDEX_PHRASE));
JSONObject result2 = executeJdbcRequest(String.format(query2, TEST_INDEX_PHRASE));
JSONObject result3 = executeJdbcRequest(String.format(query3, TEST_INDEX_PHRASE));
assertEquals(result1, result2);
assertEquals(result1, result3);
assertTrue(result1.similar(result2));
assertTrue(result1.similar(result3));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ public void test_SyntaxCheckException_when_no_arguments_match_phrase_syntax() {
List<Expression> arguments = List.of();
assertThrows(SyntaxCheckException.class,
() -> matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseWithUnderscoreName)));
arguments, matchPhraseWithUnderscoreName)));
}

@Test
public void test_SyntaxCheckException_when_one_argument_match_phrase_syntax() {
List<Expression> arguments = List.of(DSL.namedArgument("field", "test"));
assertThrows(SyntaxCheckException.class,
() -> matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseWithUnderscoreName)));
arguments, matchPhraseWithUnderscoreName)));

}

Expand All @@ -129,7 +129,7 @@ public void test_SyntaxCheckException_when_invalid_parameter_match_phrase_syntax
DSL.namedArgument("unsupported", "3"));
Assertions.assertThrows(SemanticCheckException.class,
() -> matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseWithUnderscoreName)));
arguments, matchPhraseWithUnderscoreName)));
}

@Test
Expand All @@ -140,7 +140,7 @@ public void test_analyzer_parameter_match_phrase_syntax() {
DSL.namedArgument("analyzer", "standard")
);
Assertions.assertNotNull(matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseWithUnderscoreName)));
arguments, matchPhraseWithUnderscoreName)));
}

@Test
Expand All @@ -149,7 +149,7 @@ public void build_succeeds_with_two_arguments_match_phrase_syntax() {
DSL.namedArgument("field", "test"),
DSL.namedArgument("query", "test2"));
Assertions.assertNotNull(matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseWithUnderscoreName)));
arguments, matchPhraseWithUnderscoreName)));
}

@Test
Expand All @@ -160,7 +160,7 @@ public void test_slop_parameter_match_phrase_syntax() {
DSL.namedArgument("slop", "2")
);
Assertions.assertNotNull(matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseWithUnderscoreName)));
arguments, matchPhraseWithUnderscoreName)));
}

@Test
Expand All @@ -171,7 +171,7 @@ public void test_zero_terms_query_parameter_match_phrase_syntax() {
DSL.namedArgument("zero_terms_query", "ALL")
);
Assertions.assertNotNull(matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseWithUnderscoreName)));
arguments, matchPhraseWithUnderscoreName)));
}

@Test
Expand All @@ -182,23 +182,23 @@ public void test_zero_terms_query_parameter_lower_case_match_phrase_syntax() {
DSL.namedArgument("zero_terms_query", "all")
);
Assertions.assertNotNull(matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseWithUnderscoreName)));
arguments, matchPhraseWithUnderscoreName)));
}

@Test
public void test_SyntaxCheckException_when_no_arguments_matchphrase_syntax() {
List<Expression> arguments = List.of();
assertThrows(SyntaxCheckException.class,
() -> matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseQueryName)));
arguments, matchPhraseQueryName)));
}

@Test
public void test_SyntaxCheckException_when_one_argument_matchphrase_syntax() {
List<Expression> arguments = List.of(DSL.namedArgument("field", "test"));
assertThrows(SyntaxCheckException.class,
() -> matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseQueryName)));
arguments, matchPhraseQueryName)));

}

Expand All @@ -210,7 +210,7 @@ public void test_SyntaxCheckException_when_invalid_parameter_matchphrase_syntax(
DSL.namedArgument("unsupported", "3"));
Assertions.assertThrows(SemanticCheckException.class,
() -> matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseQueryName)));
arguments, matchPhraseQueryName)));
}

@Test
Expand All @@ -221,7 +221,7 @@ public void test_analyzer_parameter_matchphrase_syntax() {
DSL.namedArgument("analyzer", "standard")
);
Assertions.assertNotNull(matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseQueryName)));
arguments, matchPhraseQueryName)));
}

@Test
Expand All @@ -230,7 +230,7 @@ public void build_succeeds_with_two_arguments_matchphrase_syntax() {
DSL.namedArgument("field", "test"),
DSL.namedArgument("query", "test2"));
Assertions.assertNotNull(matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseQueryName)));
arguments, matchPhraseQueryName)));
}

@Test
Expand All @@ -241,7 +241,7 @@ public void test_slop_parameter_matchphrase_syntax() {
DSL.namedArgument("slop", "2")
);
Assertions.assertNotNull(matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseQueryName)));
arguments, matchPhraseQueryName)));
}

@Test
Expand All @@ -252,7 +252,7 @@ public void test_zero_terms_query_parameter_matchphrase_syntax() {
DSL.namedArgument("zero_terms_query", "ALL")
);
Assertions.assertNotNull(matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseQueryName)));
arguments, matchPhraseQueryName)));
}

@Test
Expand All @@ -263,12 +263,12 @@ public void test_zero_terms_query_parameter_lower_case_matchphrase_syntax() {
DSL.namedArgument("zero_terms_query", "all")
);
Assertions.assertNotNull(matchPhraseQuery.build(new MatchPhraseExpression(
arguments, MatchPhraseQueryTest.this.matchPhraseQueryName)));
arguments, matchPhraseQueryName)));
}

private class MatchPhraseExpression extends FunctionExpression {
public MatchPhraseExpression(List<Expression> arguments) {
super(MatchPhraseQueryTest.this.matchPhraseName, arguments);
super(matchPhraseName, arguments);
}

public MatchPhraseExpression(List<Expression> arguments, FunctionName funcName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,7 @@ public void can_parse_match_relevance_function() {
"matchPhraseComplexQueries",
"matchPhraseGeneratedQueries",
"generateMatchPhraseQueries",
"matchPhraseQueryComplexQueries",
"generateMatchPhraseQueryQueries"
"matchPhraseQueryComplexQueries"
})
public void canParseComplexMatchPhraseArgsTest(String query) {
assertNotNull(parser.parse(query));
Expand Down Expand Up @@ -466,15 +465,6 @@ private static Stream<String> generateMatchPhraseQueries() {
return generateQueries("match_phrase", matchPhraseArgs);
}

private static Stream<String> generateMatchPhraseQueryQueries() {
var matchPhraseArgs = new HashMap<String, Object[]>();
matchPhraseArgs.put("analyzer", new String[]{ "standard", "stop", "english" });
matchPhraseArgs.put("max_expansions", new Integer[]{ 0, 5, 20 });
matchPhraseArgs.put("slop", new Integer[]{ 0, 1, 2 });

return generateQueries("matchphrasequery", matchPhraseArgs);
}

private static Stream<String> generateMatchPhrasePrefixQueries() {
return generateQueries("match_phrase_prefix", ImmutableMap.<String, Object[]>builder()
.put("analyzer", new String[] {"standard", "stop", "english"})
Expand Down

0 comments on commit 72580ed

Please sign in to comment.