@@ -757,7 +757,7 @@ public void testReplicaProxy() throws InterruptedException, ExecutionException {
757757 assertEquals (0 , shardFailedRequests .length );
758758 }
759759
760- public void testSeqNoIsSetOnPrimary () throws Exception {
760+ public void testSeqNoIsSetOnPrimary () {
761761 final String index = "test" ;
762762 final ShardId shardId = new ShardId (index , "_na_" , 0 );
763763 // we use one replica to check the primary term was set on the operation and sent to the replica
@@ -788,14 +788,14 @@ public void testSeqNoIsSetOnPrimary() throws Exception {
788788 return null ;
789789 }).when (shard ).acquirePrimaryOperationPermit (any (), anyString (), anyObject ());
790790
791- TestAction action =
792- new TestAction ( Settings . EMPTY , "internal:testSeqNoIsSetOnPrimary" , transportService , clusterService , shardStateAction ,
793- threadPool ) {
794- @ Override
795- protected IndexShard getIndexShard ( ShardId shardId ) {
796- return shard ;
797- }
798- } ;
791+ final IndexService indexService = mock ( IndexService . class );
792+ when ( indexService . getShard ( shard . shardId (). id ())). thenReturn ( shard );
793+
794+ final IndicesService indicesService = mock ( IndicesService . class );
795+ when ( indicesService . indexServiceSafe ( shard . shardId (). getIndex ())). thenReturn ( indexService );
796+
797+ TestAction action = new TestAction ( Settings . EMPTY , "internal:testSeqNoIsSetOnPrimary" , transportService , clusterService ,
798+ shardStateAction , threadPool , indicesService ) ;
799799
800800 action .handlePrimaryRequest (concreteShardRequest , createTransportChannel (listener ), null );
801801 CapturingTransport .CapturedRequest [] requestsToReplicas = transport .capturedRequests ();
@@ -1207,11 +1207,16 @@ static class TestResponse extends ReplicationResponse {
12071207
12081208 private class TestAction extends TransportReplicationAction <Request , Request , TestResponse > {
12091209
1210-
12111210 TestAction (Settings settings , String actionName , TransportService transportService ,
12121211 ClusterService clusterService , ShardStateAction shardStateAction ,
12131212 ThreadPool threadPool ) {
1214- super (settings , actionName , transportService , clusterService , mockIndicesService (clusterService ), threadPool ,
1213+ this (settings , actionName , transportService , clusterService , shardStateAction , threadPool , mockIndicesService (clusterService ));
1214+ }
1215+
1216+ TestAction (Settings settings , String actionName , TransportService transportService ,
1217+ ClusterService clusterService , ShardStateAction shardStateAction ,
1218+ ThreadPool threadPool , IndicesService indicesService ) {
1219+ super (settings , actionName , transportService , clusterService , indicesService , threadPool ,
12151220 shardStateAction ,
12161221 new ActionFilters (new HashSet <>()), new IndexNameExpressionResolver (),
12171222 Request ::new , Request ::new , ThreadPool .Names .SAME );
@@ -1241,7 +1246,7 @@ protected boolean resolveIndex() {
12411246 }
12421247 }
12431248
1244- final IndicesService mockIndicesService (ClusterService clusterService ) {
1249+ private IndicesService mockIndicesService (ClusterService clusterService ) {
12451250 final IndicesService indicesService = mock (IndicesService .class );
12461251 when (indicesService .indexServiceSafe (any (Index .class ))).then (invocation -> {
12471252 Index index = (Index )invocation .getArguments ()[0 ];
@@ -1261,7 +1266,7 @@ final IndicesService mockIndicesService(ClusterService clusterService) {
12611266 return indicesService ;
12621267 }
12631268
1264- final IndexService mockIndexService (final IndexMetaData indexMetaData , ClusterService clusterService ) {
1269+ private IndexService mockIndexService (final IndexMetaData indexMetaData , ClusterService clusterService ) {
12651270 final IndexService indexService = mock (IndexService .class );
12661271 when (indexService .getShard (anyInt ())).then (invocation -> {
12671272 int shard = (Integer ) invocation .getArguments ()[0 ];
0 commit comments