Skip to content

Commit

Permalink
Update RestController constructor for tests. (opensearch-project#440)
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Drobnjakovic <[email protected]>
  • Loading branch information
Tjofil authored and khushbr committed May 17, 2023
1 parent b159f65 commit 329e8f4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.env.Environment;
import org.opensearch.env.TestEnvironment;
import org.opensearch.identity.IdentityService;
import org.opensearch.indices.breaker.BreakerSettings;
import org.opensearch.indices.breaker.CircuitBreakerService;
import org.opensearch.indices.breaker.HierarchyCircuitBreakerService;
Expand Down Expand Up @@ -60,6 +61,7 @@ public class PerformanceAnalyzerPluginTests extends OpenSearchTestCase {
private CircuitBreakerService circuitBreakerService;
private ClusterService clusterService;
private ClusterSettings clusterSettings;
private IdentityService identityService;

@Before
public void setup() {
Expand All @@ -76,13 +78,15 @@ public void setup() {
nodeClient = new NodeClient(settings, threadPool);
environment = TestEnvironment.newEnvironment(settings);
clusterService = new ClusterService(settings, clusterSettings, threadPool);
identityService = new IdentityService(Settings.EMPTY, List.of());
restController =
new RestController(
Collections.emptySet(),
null,
nodeClient,
circuitBreakerService,
usageService);
usageService,
identityService);
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -25,6 +26,7 @@
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.identity.IdentityService;
import org.opensearch.indices.breaker.BreakerSettings;
import org.opensearch.indices.breaker.CircuitBreakerService;
import org.opensearch.indices.breaker.HierarchyCircuitBreakerService;
Expand All @@ -50,6 +52,7 @@ public class PerformanceAnalyzerClusterConfigActionTests {
private ClusterSettings clusterSettings;
private PerformanceAnalyzerClusterSettingHandler clusterSettingHandler;
private NodeStatsSettingHandler nodeStatsSettingHandler;
private IdentityService identityService;

@Mock private PerformanceAnalyzerController controller;
@Mock private ClusterSettingsManager clusterSettingsManager;
Expand All @@ -66,13 +69,15 @@ public void init() {
UsageService usageService = new UsageService();
threadPool = new TestThreadPool("test");
nodeClient = new NodeClient(Settings.EMPTY, threadPool);
identityService = new IdentityService(Settings.EMPTY, List.of());
restController =
new RestController(
Collections.emptySet(),
null,
nodeClient,
circuitBreakerService,
usageService);
usageService,
identityService);
clusterSettingHandler =
new PerformanceAnalyzerClusterSettingHandler(controller, clusterSettingsManager);
nodeStatsSettingHandler = new NodeStatsSettingHandler(controller, clusterSettingsManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -26,6 +27,7 @@
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.identity.IdentityService;
import org.opensearch.indices.breaker.BreakerSettings;
import org.opensearch.indices.breaker.CircuitBreakerService;
import org.opensearch.indices.breaker.HierarchyCircuitBreakerService;
Expand All @@ -46,6 +48,7 @@ public class PerformanceAnalyzerConfigActionTests {
private NodeClient nodeClient;
private CircuitBreakerService circuitBreakerService;
private ClusterSettings clusterSettings;
private IdentityService identityService;

@Mock private PerformanceAnalyzerController controller;

Expand All @@ -61,13 +64,15 @@ public void init() {
UsageService usageService = new UsageService();
threadPool = new TestThreadPool("test");
nodeClient = new NodeClient(Settings.EMPTY, threadPool);
identityService = new IdentityService(Settings.EMPTY, List.of());
restController =
new RestController(
Collections.emptySet(),
null,
nodeClient,
circuitBreakerService,
usageService);
usageService,
identityService);
configAction = new PerformanceAnalyzerConfigAction(restController, controller);
restController.registerHandler(configAction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -24,6 +25,7 @@
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.identity.IdentityService;
import org.opensearch.indices.breaker.BreakerSettings;
import org.opensearch.indices.breaker.CircuitBreakerService;
import org.opensearch.indices.breaker.HierarchyCircuitBreakerService;
Expand All @@ -46,6 +48,7 @@ public class PerformanceAnalyzerOverridesClusterConfigActionTests {
private NodeClient nodeClient;
private CircuitBreakerService circuitBreakerService;
private ClusterSettings clusterSettings;
private IdentityService identityService;

@Mock private ConfigOverridesClusterSettingHandler configOverridesClusterSettingHandler;
@Mock private ConfigOverridesWrapper overridesWrapper;
Expand All @@ -62,13 +65,15 @@ public void init() {
UsageService usageService = new UsageService();
threadPool = new TestThreadPool("test");
nodeClient = new NodeClient(Settings.EMPTY, threadPool);
identityService = new IdentityService(Settings.EMPTY, List.of());
restController =
new RestController(
Collections.emptySet(),
null,
nodeClient,
circuitBreakerService,
usageService);
usageService,
identityService);
configAction =
new PerformanceAnalyzerOverridesClusterConfigAction(
Settings.EMPTY,
Expand Down

0 comments on commit 329e8f4

Please sign in to comment.