Skip to content

Commit 1f9d90e

Browse files
committed
Mock method for tests
1 parent 62c4349 commit 1f9d90e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
import org.elasticsearch.index.analysis.AnalysisRegistry;
147147
import org.elasticsearch.index.mapper.MapperMetrics;
148148
import org.elasticsearch.index.mapper.MapperRegistry;
149+
import org.elasticsearch.index.search.stats.ShardSearchLoadRateProvider;
149150
import org.elasticsearch.index.seqno.GlobalCheckpointSyncAction;
150151
import org.elasticsearch.index.seqno.RetentionLeaseSyncer;
151152
import org.elasticsearch.index.shard.PrimaryReplicaSyncer;
@@ -202,6 +203,7 @@
202203
import org.elasticsearch.xcontent.NamedXContentRegistry;
203204
import org.junit.After;
204205
import org.junit.Before;
206+
import org.mockito.Mockito;
205207

206208
import java.io.IOException;
207209
import java.nio.file.Path;
@@ -244,7 +246,9 @@
244246
import static org.hamcrest.Matchers.iterableWithSize;
245247
import static org.hamcrest.Matchers.lessThanOrEqualTo;
246248
import static org.hamcrest.Matchers.notNullValue;
249+
import static org.mockito.ArgumentMatchers.any;
247250
import static org.mockito.Mockito.mock;
251+
import static org.mockito.Mockito.when;
248252

249253
public class SnapshotResiliencyTests extends ESTestCase {
250254

@@ -2217,8 +2221,12 @@ public RecyclerBytesStreamOutput newNetworkBytesStream() {
22172221
);
22182222
final MapperRegistry mapperRegistry = new IndicesModule(Collections.emptyList()).getMapperRegistry();
22192223

2224+
PluginsService pluginsService = Mockito.mock(PluginsService.class);
2225+
when(pluginsService.loadSingletonServiceProvider(any(), any())).thenReturn(ShardSearchLoadRateProvider.DEFAULT);
2226+
2227+
22202228
indicesService = new IndicesServiceBuilder().settings(settings)
2221-
.pluginsService(mock(PluginsService.class))
2229+
.pluginsService(pluginsService)
22222230
.nodeEnvironment(nodeEnv)
22232231
.xContentRegistry(namedXContentRegistry)
22242232
.analysisRegistry(

0 commit comments

Comments
 (0)