Skip to content

Commit fffa471

Browse files
author
Hendrik Muhs
committed
adapt unit test
1 parent 2bc1884 commit fffa471

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSetTests.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.elasticsearch.xpack.core.ml.stats.ForecastStatsTests;
4747
import org.elasticsearch.xpack.core.watcher.support.xcontent.XContentSource;
4848
import org.elasticsearch.xpack.ml.job.JobManager;
49+
import org.elasticsearch.xpack.ml.job.JobManagerHolder;
4950
import org.junit.Before;
5051

5152
import java.util.Arrays;
@@ -74,6 +75,7 @@ public class MachineLearningFeatureSetTests extends ESTestCase {
7475
private ClusterService clusterService;
7576
private Client client;
7677
private JobManager jobManager;
78+
private JobManagerHolder jobManagerHolder;
7779
private XPackLicenseState licenseState;
7880

7981
@Before
@@ -85,6 +87,7 @@ public void init() {
8587
clusterService = mock(ClusterService.class);
8688
client = mock(Client.class);
8789
jobManager = mock(JobManager.class);
90+
jobManagerHolder = new JobManagerHolder(jobManager);
8891
licenseState = mock(XPackLicenseState.class);
8992
ClusterState clusterState = new ClusterState.Builder(ClusterState.EMPTY_STATE).build();
9093
when(clusterService.state()).thenReturn(clusterState);
@@ -109,7 +112,7 @@ public void testIsRunningOnMlPlatform() {
109112

110113
public void testAvailable() throws Exception {
111114
MachineLearningFeatureSet featureSet = new MachineLearningFeatureSet(TestEnvironment.newEnvironment(commonSettings), clusterService,
112-
client, licenseState, jobManager);
115+
client, licenseState, jobManagerHolder);
113116
boolean available = randomBoolean();
114117
when(licenseState.isMachineLearningAllowed()).thenReturn(available);
115118
assertThat(featureSet.available(), is(available));
@@ -134,7 +137,7 @@ public void testEnabled() throws Exception {
134137
}
135138
boolean expected = enabled || useDefault;
136139
MachineLearningFeatureSet featureSet = new MachineLearningFeatureSet(TestEnvironment.newEnvironment(settings.build()),
137-
clusterService, client, licenseState, jobManager);
140+
clusterService, client, licenseState, jobManagerHolder);
138141
assertThat(featureSet.enabled(), is(expected));
139142
PlainActionFuture<Usage> future = new PlainActionFuture<>();
140143
featureSet.usage(future);
@@ -168,7 +171,7 @@ public void testUsage() throws Exception {
168171
));
169172

170173
MachineLearningFeatureSet featureSet = new MachineLearningFeatureSet(TestEnvironment.newEnvironment(settings.build()),
171-
clusterService, client, licenseState, jobManager);
174+
clusterService, client, licenseState, jobManagerHolder);
172175
PlainActionFuture<Usage> future = new PlainActionFuture<>();
173176
featureSet.usage(future);
174177
XPackFeatureSet.Usage mlUsage = future.get();
@@ -244,7 +247,7 @@ public void testNodeCount() throws Exception {
244247
Settings.Builder settings = Settings.builder().put(commonSettings);
245248
settings.put("xpack.ml.enabled", true);
246249
MachineLearningFeatureSet featureSet = new MachineLearningFeatureSet(TestEnvironment.newEnvironment(settings.build()),
247-
clusterService, client, licenseState, jobManager);
250+
clusterService, client, licenseState, jobManagerHolder);
248251

249252
PlainActionFuture<Usage> future = new PlainActionFuture<>();
250253
featureSet.usage(future);
@@ -287,7 +290,7 @@ public void testUsageGivenMlMetadataNotInstalled() throws Exception {
287290
when(clusterService.state()).thenReturn(ClusterState.EMPTY_STATE);
288291

289292
MachineLearningFeatureSet featureSet = new MachineLearningFeatureSet(TestEnvironment.newEnvironment(settings.build()),
290-
clusterService, client, licenseState, jobManager);
293+
clusterService, client, licenseState, jobManagerHolder);
291294
PlainActionFuture<Usage> future = new PlainActionFuture<>();
292295
featureSet.usage(future);
293296
XPackFeatureSet.Usage usage = future.get();

0 commit comments

Comments
 (0)