Skip to content

Commit

Permalink
Add test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Nov 2, 2023
1 parent 8f01443 commit 809f3ba
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public class FlowFrameworkPluginTests extends OpenSearchTestCase {
private ClusterAdminClient clusterAdminClient;
private ThreadPool threadPool;
private Settings settings;
Environment environment;
ClusterSettings clusterSettings;
ClusterService clusterService;
private Environment environment;
private ClusterSettings clusterSettings;
private ClusterService clusterService;

@Override
public void setUp() throws Exception {
Expand Down Expand Up @@ -81,6 +81,7 @@ public void testPlugin() throws IOException {
assertEquals(2, ffp.getRestHandlers(null, null, null, null, null, null, null).size());
assertEquals(2, ffp.getActions().size());
assertEquals(1, ffp.getExecutorBuilders(settings).size());
assertEquals(1, ffp.getSettings().size());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
package org.opensearch.flowframework.common;

import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Settings;
import org.opensearch.env.Environment;
import org.opensearch.test.OpenSearchTestCase;

import java.io.IOException;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class FlowFrameworkFeatureEnabledSettingTests extends OpenSearchTestCase {

private Settings settings;
private Environment environment;
private ClusterSettings clusterSettings;
private ClusterService clusterService;

private FlowFrameworkFeatureEnabledSetting flowFrameworkFeatureEnabledSetting;

@Override
public void setUp() throws Exception {
super.setUp();

settings = Settings.builder().build();
final Set<Setting<?>> settingsSet = Stream.concat(
ClusterSettings.BUILT_IN_CLUSTER_SETTINGS.stream(),
Stream.of(FlowFrameworkFeatureEnabledSetting.FLOW_FRAMEWORK_ENABLED)
).collect(Collectors.toSet());
clusterSettings = new ClusterSettings(settings, settingsSet);
clusterService = mock(ClusterService.class);
when(clusterService.getClusterSettings()).thenReturn(clusterSettings);
flowFrameworkFeatureEnabledSetting = new FlowFrameworkFeatureEnabledSetting(clusterService, settings);
}

@Override
public void tearDown() throws Exception {
super.tearDown();
}

public void testSettings() throws IOException {
assertFalse(flowFrameworkFeatureEnabledSetting.isFlowFrameworkEnabled());
}
}

0 comments on commit 809f3ba

Please sign in to comment.