// test null map with no prior
cr.setDesiredConfig(
new ConfigurationRequest(clusterName, "typeA", "v1", null));
controller.updateClusters(Collections.singleton(cr), new HashMap<String, String>());
Config config = cluster.getDesiredConfigByType("typeA");
Assert.assertNull(config);
// test empty map with no prior
cr.setDesiredConfig(
new ConfigurationRequest(clusterName, "typeA", "v1", new HashMap<String, String>()));
controller.updateClusters(Collections.singleton(cr), new HashMap<String, String>());
config = cluster.getDesiredConfigByType("typeA");
Assert.assertNotNull(config);
// test empty properties on a new version
cr.setDesiredConfig(
new ConfigurationRequest(clusterName, "typeA", "v2", new HashMap<String, String>()));
controller.updateClusters(Collections.singleton(cr), new HashMap<String, String>());
config = cluster.getDesiredConfigByType("typeA");
Assert.assertNotNull(config);
Assert.assertEquals(Integer.valueOf(0), Integer.valueOf(config.getProperties().size()));
// test new version
Map<String, String> map = new HashMap<String, String>();
map.clear();
map.put("c", "d");
cr.setDesiredConfig(
new ConfigurationRequest(clusterName, "typeA", "v3", map));
controller.updateClusters(Collections.singleton(cr), new HashMap<String, String>());
config = cluster.getDesiredConfigByType("typeA");
Assert.assertNotNull(config);
Assert.assertTrue(config.getProperties().containsKey("c"));
// test reset to v2
cr.setDesiredConfig(
new ConfigurationRequest(clusterName, "typeA", "v2", new HashMap<String, String>()));
controller.updateClusters(Collections.singleton(cr), new HashMap<String, String>());
config = cluster.getDesiredConfigByType("typeA");
Assert.assertEquals("v2", config.getVersionTag());
Assert.assertNotNull(config);
Assert.assertEquals(Integer.valueOf(0), Integer.valueOf(config.getProperties().size()));
// test v2, but with properties
cr.setDesiredConfig(
new ConfigurationRequest(clusterName, "typeA", "v2", new HashMap<String, String>() {{ put("a", "b"); }}));
try {