public static <T> T loadData(Map<String, Object> config,
                                 T existingData,
                                 Class<T> dataCls) {
        try {
            String existingConfigJson = MAPPER.writeValueAsString(existingData);
            Map<String, Object> existingConfig = MAPPER.readValue(existingConfigJson, Map.class);
            Map<String, Object> newConfig = new HashMap<>();
            newConfig.putAll(existingConfig);
            newConfig.putAll(config);
            String configJson = MAPPER.writeValueAsString(newConfig);
            return MAPPER.readValue(configJson, dataCls);
        } catch (IOException e) {
            throw new RuntimeException("Failed to load config into existing configuration data", e);
        }

    }
@Test
    public void testLoadClientConfigurationData() {
        ClientConfigurationData confData = new ClientConfigurationData();
        confData.setServiceUrl("pulsar://unknown:6650");
        confData.setMaxLookupRequest(600);
        confData.setMaxLookupRedirects(10);
        confData.setNumIoThreads(33);
        Map<String, Object> config = new HashMap<>();
        Map<String, String> authParamMap = new HashMap<>();
        authParamMap.put("k1", "v1");
        authParamMap.put("k2", "v2");

        config.put("serviceUrl", "pulsar://localhost:6650");
        config.put("maxLookupRequest", 70000);
        config.put("maxLookupRedirects", 50);
        config.put("authParams", "testAuthParams");
        config.put("authParamMap", authParamMap);
        config.put("dnsLookupBindAddress", "0.0.0.0");
        config.put("dnsLookupBindPort", 0);
        List<InetSocketAddress> dnsServerAddresses = Arrays.asList(new InetSocketAddress[] {
                new InetSocketAddress("1.1.1.1", 53), new InetSocketAddress("2.2.2.2",100)
        });
        config.put("dnsServerAddresses", dnsServerAddresses);
        confData = ConfigurationDataUtils.loadData(config, confData, ClientConfigurationData.class);
        assertEquals("pulsar://localhost:6650", confData.getServiceUrl());
        assertEquals(70000, confData.getMaxLookupRequest());
        assertEquals(50, confData.getMaxLookupRedirects());
        assertEquals(33, confData.getNumIoThreads());
        assertEquals("testAuthParams", confData.getAuthParams());
        assertEquals("v1", confData.getAuthParamMap().get("k1"));
        assertEquals("v2", confData.getAuthParamMap().get("k2"));
        assertEquals("0.0.0.0", confData.getDnsLookupBindAddress());
        assertEquals(0, confData.getDnsLookupBindPort());
        assertEquals(dnsServerAddresses, confData.getDnsServerAddresses());
    }