public void refreshMetadata(String clusterName, MetadataResponse metadataResponse) {
        List<Node> list = new ArrayList<>();
        for (Node node : metadataResponse.getNodes()) {
            if (node.getRole() == ClusterRole.LEADER) {
                this.setLeaderNode(clusterName, node);
            }
            list.add(node);
        }
        this.storeMode = StoreMode.get(metadataResponse.getStoreMode());
        if (!list.isEmpty()) {
            String group = list.get(0).getGroup();
            this.setNodes(clusterName, group, list);
            this.clusterTerm.computeIfAbsent(clusterName, k -> new ConcurrentHashMap<>()).put(group,
                metadataResponse.getTerm());
        }
    }
@Test
    public void testRefreshMetadata() {
        Node node = new Node();
        node.setGroup("group");
        node.setRole(ClusterRole.LEADER);
        Node node1 = new Node();
        node1.setGroup("group");
        node1.setRole(ClusterRole.FOLLOWER);

        List<Node> nodes = new ArrayList<>();
        nodes.add(node);
        nodes.add(node1);

        MetadataResponse metadataResponse = new MetadataResponse();
        metadataResponse.setNodes(nodes);
        metadataResponse.setStoreMode(StoreMode.RAFT.getName());
        Assertions.assertDoesNotThrow(() -> metadata.refreshMetadata("cluster", metadataResponse));
        metadataResponse.setNodes(new ArrayList<>());
        Assertions.assertDoesNotThrow(() -> metadata.refreshMetadata("cluster", metadataResponse));
    }