Skip to content

Commit

Permalink
FIx unit tests for PIT changes
Browse files Browse the repository at this point in the history
Signed-off-by: Manasvini B S <[email protected]>
  • Loading branch information
manasvinibs committed Aug 14, 2024
1 parent 2773b1b commit e7e86a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package org.opensearch.sql.legacy.unittest.cursor;

import static java.util.Collections.emptyList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.emptyOrNullString;
import static org.hamcrest.Matchers.startsWith;
Expand All @@ -17,29 +16,23 @@
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opensearch.action.support.ActionFilters;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.search.builder.SearchSourceBuilder;
import org.opensearch.sql.common.setting.Settings;
import org.opensearch.sql.legacy.cursor.CursorType;
import org.opensearch.sql.legacy.cursor.DefaultCursor;
import org.opensearch.sql.legacy.esdomain.LocalClusterState;
import org.opensearch.sql.legacy.metrics.Metrics;
import org.opensearch.sql.opensearch.setting.OpenSearchSettings;

public class DefaultCursorTest {
@Mock
private OpenSearchSettings settings;
@Mock private OpenSearchSettings settings;

@Mock
private SearchSourceBuilder sourceBuilder;
@Mock private SearchSourceBuilder sourceBuilder;

@Before
public void setUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,17 @@
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.when;

import java.io.ByteArrayOutputStream;
import java.util.*;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.opensearch.action.search.SearchRequestBuilder;
import org.opensearch.client.Client;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.script.Script;
import org.opensearch.search.builder.SearchSourceBuilder;
import org.opensearch.search.sort.FieldSortBuilder;
import org.opensearch.search.sort.SortOrder;
import org.opensearch.sql.common.setting.Settings;
Expand All @@ -41,7 +33,6 @@
import org.opensearch.sql.legacy.metrics.Metrics;
import org.opensearch.sql.legacy.query.DefaultQueryAction;
import org.opensearch.sql.legacy.request.SqlRequest;
import org.opensearch.sql.opensearch.setting.OpenSearchSettings;

public class DefaultQueryActionTest {

Expand Down Expand Up @@ -268,7 +259,9 @@ private void mockLocalClusterStateAndInitializeMetrics(TimeValue time) {
.when(mockLocalClusterState)
.getSettingValue(Settings.Key.METRICS_ROLLING_WINDOW);
doReturn(2L).when(mockLocalClusterState).getSettingValue(Settings.Key.METRICS_ROLLING_INTERVAL);
doReturn(true).when(mockLocalClusterState).getSettingValue(Settings.Key.SQL_PAGINATION_API_SEARCH_AFTER);
doReturn(true)
.when(mockLocalClusterState)
.getSettingValue(Settings.Key.SQL_PAGINATION_API_SEARCH_AFTER);

Metrics.getInstance().registerDefaultMetrics();
}
Expand All @@ -278,10 +271,12 @@ private void mockLocalClusterStateAndIntializeMetricsForScroll(TimeValue time) {
LocalClusterState.state(mockLocalClusterState);
doReturn(time).when(mockLocalClusterState).getSettingValue(Settings.Key.SQL_CURSOR_KEEP_ALIVE);
doReturn(3600L)
.when(mockLocalClusterState)
.getSettingValue(Settings.Key.METRICS_ROLLING_WINDOW);
.when(mockLocalClusterState)
.getSettingValue(Settings.Key.METRICS_ROLLING_WINDOW);
doReturn(2L).when(mockLocalClusterState).getSettingValue(Settings.Key.METRICS_ROLLING_INTERVAL);
doReturn(false).when(mockLocalClusterState).getSettingValue(Settings.Key.SQL_PAGINATION_API_SEARCH_AFTER);
doReturn(false)
.when(mockLocalClusterState)
.getSettingValue(Settings.Key.SQL_PAGINATION_API_SEARCH_AFTER);

Metrics.getInstance().registerDefaultMetrics();
}
Expand Down

0 comments on commit e7e86a2

Please sign in to comment.