server/src/test/java/org/elasticsearch/health/node/DiskHealthIndicatorServiceTests.java
for (String nodeId : indexNameToNodeIdsMap.get(index)) {
                ShardId shardId = new ShardId(indexMetadata.getIndex(), shardAutoincrementNumber);
                IndexShardRoutingTable.Builder indexShardRoutingBuilder = IndexShardRoutingTable.builder(shardId);
                indexShardRoutingBuilder.addShard(TestShardRouting.newShardRouting(shardId, nodeId, true, ShardRoutingState.STARTED));
                indexRoutingTable.addIndexShard(indexShardRoutingBuilder);
            }
            metadata.put(indexMetadata, false);
            routingTable.add(indexRoutingTable);
        }
        ClusterState.Builder state = ClusterState.builder(new ClusterName("test"));
        state.nodes(nodesBuilder);
        state.metadata(metadata.generateClusterUuidIfNeeded().build());
        state.routingTable(routingTable.build());
        state.blocks(clusterBlocksBuilder);
        return state.build();
    }
    private Map<String, Object> xContentToMap(ToXContent xcontent) throws IOException {
        XContentBuilder builder = XContentFactory.jsonBuilder();
        xcontent.toXContent(builder, ToXContent.EMPTY_PARAMS);
        XContentParser parser = XContentType.JSON.xContent()
            .createParser(xContentRegistry(), LoggingDeprecationHandler.INSTANCE, BytesReference.bytes(builder).streamInput());
        return parser.map();
    }
    record HealthInfoConfig(HealthStatus unhealthyStatus, int numberOfUnhealthyNodes, Collection<DiscoveryNode> nodes) {
        HealthInfoConfig {
            assert numberOfUnhealthyNodes <= nodes.size();
        }
    }
}