From 4070fb3cd6ae2afae2c06b005c7b00470d311d14 Mon Sep 17 00:00:00 2001 From: Vigya Sharma Date: Tue, 28 Jul 2020 23:32:17 -0700 Subject: [PATCH] Spotbugs fix --- .../performanceanalyzer/plugins/PluginController.java | 3 +++ .../rca/store/ElasticSearchAnalysisGraph.java | 1 + .../performanceanalyzer/plugins/PluginControllerTest.java | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/plugins/PluginController.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/plugins/PluginController.java index 3ba701724..0b547d2a0 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/plugins/PluginController.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/plugins/PluginController.java @@ -36,6 +36,9 @@ public PluginController(PluginControllerConfig pluginConfig, Publisher publisher this.pluginControllerConfig = pluginConfig; this.publisher = publisher; this.plugins = new ArrayList<>(); + } + + public void initPlugins() { loadFrameworkPlugins(); registerActionListeners(); } diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/store/ElasticSearchAnalysisGraph.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/store/ElasticSearchAnalysisGraph.java index 4ef439e55..52f83f224 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/store/ElasticSearchAnalysisGraph.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/store/ElasticSearchAnalysisGraph.java @@ -220,6 +220,7 @@ public void construct() { // TODO: Refactor using DI to move out of construct method PluginControllerConfig pluginControllerConfig = new PluginControllerConfig(); PluginController pluginController = new PluginController(pluginControllerConfig, publisher); + pluginController.initPlugins(); } private void constructShardResourceUsageGraph() { diff --git a/src/test/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/plugins/PluginControllerTest.java b/src/test/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/plugins/PluginControllerTest.java index 085ac49f3..a21cf09e7 100644 --- a/src/test/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/plugins/PluginControllerTest.java +++ b/src/test/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/plugins/PluginControllerTest.java @@ -40,6 +40,7 @@ public void testInit() { Mockito.when(pluginControllerConfig.getFrameworkPlugins()).thenReturn(frameworkPlugins); Publisher publisher = Mockito.mock(Publisher.class); PluginController pluginController = new PluginController(pluginControllerConfig, publisher); + pluginController.initPlugins(); List plugins = pluginController.getPlugins(); assertEquals(2, plugins.size()); @@ -58,6 +59,7 @@ public void testPrivateConstructorPlugin() { Mockito.when(pluginControllerConfig.getFrameworkPlugins()).thenReturn(frameworkPlugins); Publisher publisher = Mockito.mock(Publisher.class); PluginController pluginController = new PluginController(pluginControllerConfig, publisher); + pluginController.initPlugins(); } @Test(expected = IllegalStateException.class) @@ -69,6 +71,7 @@ public void testMultiConstructorPlugin() { Mockito.when(pluginControllerConfig.getFrameworkPlugins()).thenReturn(frameworkPlugins); Publisher publisher = Mockito.mock(Publisher.class); PluginController pluginController = new PluginController(pluginControllerConfig, publisher); + pluginController.initPlugins(); } @Test(expected = IllegalStateException.class) @@ -80,6 +83,7 @@ public void testNonDefaultConstructorPlugin() { Mockito.when(pluginControllerConfig.getFrameworkPlugins()).thenReturn(frameworkPlugins); Publisher publisher = Mockito.mock(Publisher.class); PluginController pluginController = new PluginController(pluginControllerConfig, publisher); + pluginController.initPlugins(); } public static class TestActionListener extends Plugin implements ActionListener {