During the development and review process of the disk health indicator we noticed that it was hard to understand. Since we learnt a lot from the first round of development we want to go through the code one more time and restructure it.
server/src/test/java/org/elasticsearch/health/node/DiskHealthIndicatorServiceTests.java
RoutingTable routingTable = mock(RoutingTable.class);
        List<ShardRouting> shardRoutings = new ArrayList<>();
        when(routingTable.allShards()).thenReturn(shardRoutings);
        ClusterBlocks.Builder clusterBlocksBuilder = new ClusterBlocks.Builder();
        Map<String, IndexMetadata> indexMetadataMap = new HashMap<>();
        List<ClusterBlocks> clusterBlocksList = new ArrayList<>();
        for (String indexName : indexNameToNodeIdsMap.keySet()) {
            boolean blockIndex = blockedIndices.contains(indexName);
            IndexMetadata indexMetadata = new IndexMetadata.Builder(indexName).settings(
                Settings.builder()
                    .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
                    .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
                    .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
                    .put(IndexMetadata.INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING.getKey(), blockIndex)
                    .build()
            ).build();
            indexMetadataMap.put(indexMetadata.getIndex().getName(), indexMetadata);
            if (blockIndex) {
                ClusterBlocks clusterBlocks = clusterBlocksBuilder.addBlocks(indexMetadata).build();
                clusterBlocksList.add(clusterBlocks);
            }
            for (String nodeId : indexNameToNodeIdsMap.get(indexName)) {
                ShardRouting shardRouting = TestShardRouting.newShardRouting(
                    indexMetadata.getIndex().getName(),
                    randomIntBetween(1, 5),
                    nodeId,
                    randomBoolean(),
                    ShardRoutingState.STARTED
                );
                shardRoutings.add(shardRouting);