private static void discovery(XmlGenerator gen, DiscoveryConfig discovery) {
        if (discovery.getNodeFilter() == null && discovery.getNodeFilterClass() == null
                && discovery.getDiscoveryStrategyConfigs().isEmpty()) {
            return;
        }
        gen.open("discovery-strategies")
                .node("node-filter", null, "class",
                        classNameOrImplClass(discovery.getNodeFilterClass(), discovery.getNodeFilter()));
        for (DiscoveryStrategyConfig strategy : discovery.getDiscoveryStrategyConfigs()) {
            gen.open("discovery-strategy", "class", strategy.getClassName(), "enabled", true)
                    .appendProperties(strategy.getProperties())
                    .close();
        }
        gen.close();
    }
@Test
    public void discovery() {
        DiscoveryConfig expected = new DiscoveryConfig();
        expected.setNodeFilterClass(randomString());
        DiscoveryStrategyConfig discoveryStrategy = new DiscoveryStrategyConfig(randomString());
        discoveryStrategy.addProperty("prop", randomString());
        expected.addDiscoveryStrategyConfig(discoveryStrategy);
        clientConfig.getNetworkConfig().setDiscoveryConfig(expected);

        DiscoveryConfig actual = newConfigViaGenerator().getNetworkConfig().getDiscoveryConfig();
        assertEquals(expected.getNodeFilterClass(), actual.getNodeFilterClass());
        assertCollection(expected.getDiscoveryStrategyConfigs(), actual.getDiscoveryStrategyConfigs(),
                new Comparator<DiscoveryStrategyConfig>() {
                    @Override
                    public int compare(DiscoveryStrategyConfig o1, DiscoveryStrategyConfig o2) {
                        assertMap(o1.getProperties(), o2.getProperties());
                        return o1.getClassName().equals(o2.getClassName()) ? 0 : -1;
                    }
                });
    }