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
clusterService.state()
            ),
            equalTo(Stream.concat(pureDataNodes.stream(), mixedNodes.stream()).map(DiscoveryNode::getId).collect(Collectors.toSet()))
        );
    }
    public void testGetNodesWithMasterRole() {
        Set<DiscoveryNodeRole> nonMasterRoles = Sets.union(DATA_ROLES, OTHER_ROLES);
        Set<DiscoveryNode> nonMasterNodes = createNodes(new HashSet<>(randomNonEmptySubsetOf(nonMasterRoles)));
        Set<DiscoveryNode> pureMasterNodes = createNodes(Set.of(DiscoveryNodeRole.MASTER_ROLE));
        Set<DiscoveryNode> mixedNodes = createNodes(DiscoveryNodeRole.roles());
        Set<DiscoveryNode> allNodes = Stream.concat(Stream.concat(nonMasterNodes.stream(), pureMasterNodes.stream()), mixedNodes.stream())
            .collect(Collectors.toSet());
        ClusterService clusterService = createClusterService(false, allNodes);
        assertThat(
            DiskHealthIndicatorService.getNodesWithMasterRole(
                allNodes.stream().map(DiscoveryNode::getId).collect(Collectors.toSet()),
                clusterService.state()
            ),
            equalTo(pureMasterNodes.stream().map(DiscoveryNode::getId).collect(Collectors.toSet()))
        );
    }
    public void testGetNodesWithNonDataNonMasterRoles() {
        Set<DiscoveryNodeRole> dataAndMasterRoles = Sets.union(Set.of(DiscoveryNodeRole.MASTER_ROLE), DATA_ROLES);
        Set<DiscoveryNode> dataAndMasterNodes = createNodes(new HashSet<>(randomNonEmptySubsetOf(dataAndMasterRoles)));
        Set<DiscoveryNode> pureNonDataNonMasterNodes = createNodes(new HashSet<>(randomNonEmptySubsetOf(OTHER_ROLES)));
        Set<DiscoveryNode> mixedNodes = createNodes(
            Stream.concat(randomNonEmptySubsetOf(dataAndMasterRoles).stream(), randomNonEmptySubsetOf(OTHER_ROLES).stream())
                .collect(Collectors.toSet())
        );
        Set<DiscoveryNode> allNodes = Stream.concat(