Skip to content

Commit

Permalink
SyntaxCheckException is correct when incorrect # of parameters
Browse files Browse the repository at this point in the history
See opensearch-project#604 (comment) for reference

Signed-off-by: MaxKsyunz <[email protected]>
  • Loading branch information
MaxKsyunz committed Aug 10, 2022
1 parent 3b0c9a4 commit aafafe2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.opensearch.sql.common.antlr.SyntaxCheckException;
import org.opensearch.sql.data.model.ExprTupleValue;
import org.opensearch.sql.data.model.ExprValue;
import org.opensearch.sql.data.model.ExprValueUtils;
Expand Down Expand Up @@ -132,16 +133,16 @@ public void test_valid_parameters(List<Expression> validArgs) {
}

@Test
public void test_SemanticCheckException_when_no_arguments() {
public void test_SyntaxCheckException_when_no_arguments() {
List<Expression> arguments = List.of();
assertThrows(SemanticCheckException.class,
assertThrows(SyntaxCheckException.class,
() -> multiMatchQuery.build(new MultiMatchExpression(arguments)));
}

@Test
public void test_SemanticCheckException_when_one_argument() {
public void test_SyntaxCheckException_when_one_argument() {
List<Expression> arguments = List.of(namedArgument("fields", fields_value));
assertThrows(SemanticCheckException.class,
assertThrows(SyntaxCheckException.class,
() -> multiMatchQuery.build(new MultiMatchExpression(arguments)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.opensearch.sql.common.antlr.SyntaxCheckException;
import org.opensearch.sql.data.model.ExprTupleValue;
import org.opensearch.sql.data.model.ExprValue;
import org.opensearch.sql.data.model.ExprValueUtils;
Expand Down Expand Up @@ -132,16 +133,16 @@ public void test_valid_parameters(List<Expression> validArgs) {
}

@Test
public void test_SemanticCheckException_when_no_arguments() {
public void test_SyntaxCheckException_when_no_arguments() {
List<Expression> arguments = List.of();
assertThrows(SemanticCheckException.class,
assertThrows(SyntaxCheckException.class,
() -> simpleQueryStringQuery.build(new SimpleQueryStringExpression(arguments)));
}

@Test
public void test_SemanticCheckException_when_one_argument() {
public void test_SyntaxCheckException_when_one_argument() {
List<Expression> arguments = List.of(namedArgument("fields", fields_value));
assertThrows(SemanticCheckException.class,
assertThrows(SyntaxCheckException.class,
() -> simpleQueryStringQuery.build(new SimpleQueryStringExpression(arguments)));
}

Expand Down

0 comments on commit aafafe2

Please sign in to comment.