4444import static org .hamcrest .Matchers .equalTo ;
4545import static org .hamcrest .Matchers .hasToString ;
4646import static org .hamcrest .Matchers .instanceOf ;
47- import static org .hamcrest .Matchers .matchesPattern ;
4847import static org .mockito .ArgumentMatchers .any ;
4948import static org .mockito .ArgumentMatchers .eq ;
50- import static org .mockito .ArgumentMatchers .matches ;
5149import static org .mockito .Mockito .mock ;
5250import static org .mockito .Mockito .times ;
5351import static org .mockito .Mockito .verify ;
@@ -107,24 +105,25 @@ public void testRemoteIndexValidation() {
107105 .numberOfReplicas (1 )
108106 .state (IndexMetadata .State .CLOSE )
109107 .build ();
110- IndexMetadata firstBackingIndex = DataStreamTestHelper .createFirstBackingIndex (dataStreamName )
111- .build ();
108+ IndexMetadata firstBackingIndex = DataStreamTestHelper .createFirstBackingIndex (dataStreamName ).build ();
112109 IndexMetadata firstFailureStore = DataStreamTestHelper .createFirstFailureStore (dataStreamName ).build ();
113110 DataStream dataStream = DataStreamTestHelper .newInstance (
114111 dataStreamName ,
115112 List .of (firstBackingIndex .getIndex ()),
116113 List .of (firstFailureStore .getIndex ())
117114 );
118115 ClusterState remoteClusterState = ClusterState .builder (new ClusterName (randomIdentifier ()))
119- .metadata (Metadata .builder ()
120- .put (indexMetadata , false )
121- .put (closedIndexMetadata , false )
122- .put (firstBackingIndex , false )
123- .put (firstFailureStore , false )
124- .dataStreams (
125- Map .of (dataStreamName , dataStream ),
126- Map .of (dsAliasName , new DataStreamAlias (dsAliasName , List .of (dataStreamName ), dataStreamName , Map .of ()))
127- ))
116+ .metadata (
117+ Metadata .builder ()
118+ .put (indexMetadata , false )
119+ .put (closedIndexMetadata , false )
120+ .put (firstBackingIndex , false )
121+ .put (firstFailureStore , false )
122+ .dataStreams (
123+ Map .of (dataStreamName , dataStream ),
124+ Map .of (dsAliasName , new DataStreamAlias (dsAliasName , List .of (dataStreamName ), dataStreamName , Map .of ()))
125+ )
126+ )
128127 .build ();
129128
130129 final boolean isCcrAllowed = randomBoolean ();
@@ -149,7 +148,12 @@ protected void doCheckRemoteClusterLicenseAndFetchClusterState(
149148 }
150149
151150 @ Override
152- public void hasPrivilegesToFollowIndices (ThreadContext threadContext , RemoteClusterClient remoteClient , String [] indices , Consumer <Exception > handler ) {
151+ public void hasPrivilegesToFollowIndices (
152+ ThreadContext threadContext ,
153+ RemoteClusterClient remoteClient ,
154+ String [] indices ,
155+ Consumer <Exception > handler
156+ ) {
153157 fail ("Test case should fail before this code is called" );
154158 }
155159 };
@@ -176,21 +180,21 @@ public void hasPrivilegesToFollowIndices(ThreadContext threadContext, RemoteClus
176180 {
177181 Exception exception = executeExpectingException (checker , mockClient , clusterAlias , aliasName );
178182 assertThat (exception , instanceOf (IllegalArgumentException .class ));
179- assertThat (exception .getMessage (), equalTo ("cannot follow [" + aliasName + "], because it is a ALIAS" ));
183+ assertThat (exception .getMessage (), equalTo ("cannot follow [" + aliasName + "], because it is a ALIAS" ));
180184 }
181185
182186 // When following a data stream, throw IllegalArgumentException
183187 {
184188 Exception exception = executeExpectingException (checker , mockClient , clusterAlias , dataStreamName );
185189 assertThat (exception , instanceOf (IllegalArgumentException .class ));
186- assertThat (exception .getMessage (), equalTo ("cannot follow [" + dataStreamName + "], because it is a DATA_STREAM" ));
190+ assertThat (exception .getMessage (), equalTo ("cannot follow [" + dataStreamName + "], because it is a DATA_STREAM" ));
187191 }
188192
189193 // When following a data stream alias, throw IllegalArgumentException
190194 {
191195 Exception exception = executeExpectingException (checker , mockClient , clusterAlias , dsAliasName );
192196 assertThat (exception , instanceOf (IllegalArgumentException .class ));
193- assertThat (exception .getMessage (), equalTo ("cannot follow [" + dsAliasName + "], because it is a ALIAS" ));
197+ assertThat (exception .getMessage (), equalTo ("cannot follow [" + dsAliasName + "], because it is a ALIAS" ));
194198 }
195199
196200 // When following a closed index, throw IndexClosedException
0 commit comments