Skip to content

Commit

Permalink
Improving HighlightOperator test coverage and removing not used annot…
Browse files Browse the repository at this point in the history
…ations from HighlightOperator.

Signed-off-by: forestmvey <forestv@bitquilltech.com>
  • Loading branch information
forestmvey committed Aug 22, 2022
1 parent ec1e504 commit 875bbb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
/**
* HighlightOperator class.
*/
@Getter
@EqualsAndHashCode
public class HighlightOperator extends PhysicalPlan {
@Getter
private final PhysicalPlan input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.iterableWithSize;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
import static org.opensearch.sql.data.model.ExprValueUtils.tupleValue;
import static org.opensearch.sql.data.type.ExprCoreType.STRING;
Expand All @@ -23,6 +24,7 @@
import org.opensearch.sql.data.model.ExprValue;
import org.opensearch.sql.data.model.ExprValueUtils;
import org.opensearch.sql.expression.DSL;
import org.opensearch.sql.expression.ReferenceExpression;

@ExtendWith(MockitoExtension.class)
class HighlightOperatorTest extends PhysicalPlanTestBase {
Expand All @@ -33,8 +35,12 @@ class HighlightOperatorTest extends PhysicalPlanTestBase {
public void do_nothing_with_none_tuple_value() {
when(inputPlan.hasNext()).thenReturn(true, false);
when(inputPlan.next()).thenReturn(ExprValueUtils.integerValue(1));
PhysicalPlan plan = new HighlightOperator(inputPlan, DSL.ref("reference", STRING));
ReferenceExpression highlightReferenceExp = DSL.ref("reference", STRING);
PhysicalPlan plan = new HighlightOperator(inputPlan, highlightReferenceExp);
List<ExprValue> result = execute(plan);

assertTrue(((HighlightOperator)plan).getInput().equals(inputPlan));
assertTrue(((HighlightOperator)plan).getHighlight().equals(highlightReferenceExp));
assertThat(result, allOf(iterableWithSize(1), hasItems(ExprValueUtils.integerValue(1))));
}

Expand Down

0 comments on commit 875bbb7

Please sign in to comment.