forked from opensearch-project/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: GabeFernandez310 <[email protected]>
- Loading branch information
1 parent
451ec4c
commit f2d77c6
Showing
4 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...rg/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/NoFieldQueryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.opensearch.storage.script.filter.lucene.relevance; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
import org.opensearch.sql.data.model.ExprValueUtils; | ||
import org.opensearch.sql.expression.DSL; | ||
import org.opensearch.sql.expression.LiteralExpression; | ||
import org.opensearch.sql.expression.config.ExpressionConfig; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
class NoFieldQueryTest { | ||
NoFieldQuery query; | ||
private final DSL dsl = new ExpressionConfig().dsl(new ExpressionConfig().functionRepository()); | ||
private final String testQueryName = "test_query"; | ||
private final Map<String, RelevanceQuery.QueryBuilderStep> actionMap | ||
= ImmutableMap.of("paramA", (o, v) -> o); | ||
|
||
@BeforeEach | ||
void setUp() { | ||
query = mock(NoFieldQuery.class, | ||
Mockito.withSettings().useConstructor(actionMap) | ||
.defaultAnswer(Mockito.CALLS_REAL_METHODS)); | ||
when(query.getQueryName()).thenReturn(testQueryName); | ||
} | ||
|
||
@Test | ||
void createQueryBuilderTest() { | ||
String sampleQuery = "field:query"; | ||
|
||
query.createQueryBuilder(List.of( | ||
dsl.namedArgument("query", | ||
new LiteralExpression(ExprValueUtils.stringValue(sampleQuery))))); | ||
|
||
verify(query).createBuilder(eq(sampleQuery)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters