9595import static org .hamcrest .Matchers .not ;
9696import static org .hamcrest .Matchers .notNullValue ;
9797import static org .hamcrest .Matchers .nullValue ;
98- import static org .hamcrest .Matchers .oneOf ;
9998import static org .mockito .ArgumentMatchers .any ;
10099import static org .mockito .ArgumentMatchers .anyString ;
101100import static org .mockito .ArgumentMatchers .eq ;
@@ -316,13 +315,10 @@ public void testIndexHealthChangeListeners() {
316315 final AtomicReference <IndexState > previousState = new AtomicReference <>();
317316 final AtomicReference <IndexState > currentState = new AtomicReference <>();
318317 final TriConsumer <ProjectId , IndexState , IndexState > listener = (projId , prevState , state ) -> {
319- assertThat (projId , oneOf (ProjectId .DEFAULT , projectId ));
320- if (projId .equals (projectId )) {
321- projectIdRef .set (projId );
322- previousState .set (prevState );
323- currentState .set (state );
324- listenerCalled .set (true );
325- }
318+ projectIdRef .set (projId );
319+ previousState .set (prevState );
320+ currentState .set (state );
321+ listenerCalled .set (true );
326322 };
327323 manager .addStateListener (listener );
328324
@@ -577,11 +573,9 @@ public void testIndexOutOfDateListeners() {
577573 manager .clusterChanged (new ClusterChangedEvent ("test-event" , clusterState , clusterState ));
578574 AtomicBoolean upToDateChanged = new AtomicBoolean ();
579575 manager .addStateListener ((projId , prev , current ) -> {
580- assertThat (projId , oneOf (ProjectId .DEFAULT , projectId ));
581- if (projId .equals (projectId )) {
582- listenerCalled .set (true );
583- upToDateChanged .set (prev .isIndexUpToDate != current .isIndexUpToDate );
584- }
576+ assertThat (projId , equalTo (projectId ));
577+ listenerCalled .set (true );
578+ upToDateChanged .set (prev .isIndexUpToDate != current .isIndexUpToDate );
585579 });
586580 assertThat (manager .getProject (projectId ).isIndexUpToDate (), is (true ));
587581
@@ -785,7 +779,7 @@ public void testGetRoleMappingsCleanupMigrationStatus() {
785779 metadataBuilder .put (builder .build ());
786780
787781 // No role mappings in cluster state yet
788- metadataBuilder .getProject ( projectId ). putCustom (RoleMappingMetadata .TYPE , new RoleMappingMetadata (Set .of ()));
782+ metadataBuilder .putCustom (RoleMappingMetadata .TYPE , new RoleMappingMetadata (Set .of ()));
789783
790784 assertThat (
791785 SecurityIndexManager .getRoleMappingsCleanupMigrationStatus (
@@ -809,13 +803,10 @@ public void testGetRoleMappingsCleanupMigrationStatus() {
809803 metadataBuilder .put (builder .build ());
810804
811805 // Role mappings in cluster state with fallback name
812- metadataBuilder .getProject (projectId )
813- .putCustom (
814- RoleMappingMetadata .TYPE ,
815- new RoleMappingMetadata (
816- Set .of (new ExpressionRoleMapping (RoleMappingMetadata .FALLBACK_NAME , null , null , null , null , true ))
817- )
818- );
806+ metadataBuilder .putCustom (
807+ RoleMappingMetadata .TYPE ,
808+ new RoleMappingMetadata (Set .of (new ExpressionRoleMapping (RoleMappingMetadata .FALLBACK_NAME , null , null , null , null , true )))
809+ );
819810
820811 assertThat (
821812 SecurityIndexManager .getRoleMappingsCleanupMigrationStatus (
@@ -839,11 +830,10 @@ public void testGetRoleMappingsCleanupMigrationStatus() {
839830 metadataBuilder .put (builder .build ());
840831
841832 // Role mappings in cluster state
842- metadataBuilder .getProject (projectId )
843- .putCustom (
844- RoleMappingMetadata .TYPE ,
845- new RoleMappingMetadata (Set .of (new ExpressionRoleMapping ("role_mapping_1" , null , null , null , null , true )))
846- );
833+ metadataBuilder .putCustom (
834+ RoleMappingMetadata .TYPE ,
835+ new RoleMappingMetadata (Set .of (new ExpressionRoleMapping ("role_mapping_1" , null , null , null , null , true )))
836+ );
847837
848838 assertThat (
849839 SecurityIndexManager .getRoleMappingsCleanupMigrationStatus (
@@ -1100,7 +1090,7 @@ private ClusterState.Builder createClusterState(
11001090 String mappings ,
11011091 Map <String , SystemIndexDescriptor .MappingsVersion > compatibilityVersions
11021092 ) {
1103- final Metadata metadata = Metadata .builder (Metadata . EMPTY_METADATA )
1093+ final Metadata metadata = Metadata .builder ()
11041094 .put (createProjectMetadata (projectId , indexName , aliasName , format , state , mappings ))
11051095 .build ();
11061096 final GlobalRoutingTable routingTable = GlobalRoutingTableTestHelper .buildRoutingTable (metadata , RoutingTable .Builder ::addAsNew );
@@ -1151,10 +1141,7 @@ public static ClusterState state(ProjectId projectId) {
11511141 .masterNodeId ("1" )
11521142 .localNodeId ("1" )
11531143 .build ();
1154- final Metadata metadata = Metadata .builder (Metadata .EMPTY_METADATA )
1155- .put (ProjectMetadata .builder (projectId ))
1156- .generateClusterUuidIfNeeded ()
1157- .build ();
1144+ final Metadata metadata = Metadata .builder ().put (ProjectMetadata .builder (projectId )).generateClusterUuidIfNeeded ().build ();
11581145 return ClusterState .builder (CLUSTER_NAME ).nodes (nodes ).metadata (metadata ).build ();
11591146 }
11601147
0 commit comments