public synchronized void post(Map<String, List<Map<String, Object>>> ruleMap) {
        if (ruleMap.isEmpty()) {
            // clear rule
            for (Map.Entry<String, Set<MeshRuleListener>> entry : listenerMap.entrySet()) {
                for (MeshRuleListener listener : entry.getValue()) {
                    listener.clearRule(appName);
                }
            }
        } else {
            for (Map.Entry<String, List<Map<String, Object>>> entry : ruleMap.entrySet()) {
                String ruleType = entry.getKey();
                Set<MeshRuleListener> listeners = listenerMap.get(ruleType);
                if (CollectionUtils.isNotEmpty(listeners)) {
                    for (MeshRuleListener listener : listeners) {
                        listener.onRuleChange(appName, entry.getValue());
                    }
                } else {
                    logger.warn(
                            CLUSTER_NO_RULE_LISTENER,
                            "Receive mesh rule but none of listener has been registered",
                            "",
                            "Receive rule but none of listener has been registered. Maybe type not matched. Rule Type: "
                                    + ruleType);
                }
            }
            // clear rule listener not being notified in this time
            for (Map.Entry<String, Set<MeshRuleListener>> entry : listenerMap.entrySet()) {
                if (!ruleMap.containsKey(entry.getKey())) {
                    for (MeshRuleListener listener : entry.getValue()) {
                        listener.clearRule(appName);
                    }
                }
            }
        }
    }
@Test
    void post() {
        MeshRuleDispatcher meshRuleDispatcher = new MeshRuleDispatcher("TestApp");

        Map<String, List<Map<String, Object>>> ruleMap = new HashMap<>();
        List<Map<String, Object>> type1 = new LinkedList<>();
        List<Map<String, Object>> type2 = new LinkedList<>();
        List<Map<String, Object>> type3 = new LinkedList<>();
        ruleMap.put("Type1", type1);
        ruleMap.put("Type2", type2);
        ruleMap.put("Type3", type3);

        AtomicInteger count = new AtomicInteger(0);
        MeshRuleListener listener1 = new MeshRuleListener() {
            @Override
            public void onRuleChange(String appName, List<Map<String, Object>> rules) {
                Assertions.assertEquals("TestApp", appName);
                Assertions.assertEquals(System.identityHashCode(type1), System.identityHashCode(rules));
                count.incrementAndGet();
            }

            @Override
            public void clearRule(String appName) {}

            @Override
            public String ruleSuffix() {
                return "Type1";
            }
        };

        MeshRuleListener listener2 = new MeshRuleListener() {
            @Override
            public void onRuleChange(String appName, List<Map<String, Object>> rules) {
                Assertions.assertEquals("TestApp", appName);
                Assertions.assertEquals(System.identityHashCode(type2), System.identityHashCode(rules));
                count.incrementAndGet();
            }

            @Override
            public void clearRule(String appName) {}

            @Override
            public String ruleSuffix() {
                return "Type2";
            }
        };

        MeshRuleListener listener4 = new MeshRuleListener() {
            @Override
            public void onRuleChange(String appName, List<Map<String, Object>> rules) {
                Assertions.fail();
            }

            @Override
            public void clearRule(String appName) {
                Assertions.assertEquals("TestApp", appName);
                count.incrementAndGet();
            }

            @Override
            public String ruleSuffix() {
                return "Type4";
            }
        };

        meshRuleDispatcher.register(listener1);
        meshRuleDispatcher.register(listener2);
        meshRuleDispatcher.register(listener4);

        meshRuleDispatcher.post(ruleMap);

        Assertions.assertEquals(3, count.get());
    }