KerberosConfigurationDescriptor extends AbstractKerberosDescriptor { public void update(KerberosConfigurationDescriptor updates) { if (updates != null) { setType(updates.getType()); Map<String, String> updatedProperties = updates.getProperties(); if (updatedProperties != null) { for (Map.Entry<String, String> entry : updatedProperties.entrySet()) { putProperty(entry.getKey(), entry.getValue()); } } } } KerberosConfigurationDescriptor(Map<?, ?> data); String getType(); void setType(String type); void setProperties(Map<String, String> properties); Map<String, String> getProperties(); String getProperty(String name); void putProperty(String name, String value); void update(KerberosConfigurationDescriptor updates); @Override Map<String, Object> toMap(); @Override int hashCode(); @Override boolean equals(Object object);  }
@Test public void testUpdate() { Map<String, Map<String, Object>> jsonData = new Gson().fromJson(JSON_SINGLE_VALUE, new TypeToken<Map<String, Map<String, Object>>>() { }.getType()); KerberosConfigurationDescriptor configuration = new KerberosConfigurationDescriptor(jsonData); KerberosConfigurationDescriptor updatedConfiguration = new KerberosConfigurationDescriptor(MAP_SINGLE_VALUE); Map<String, String> properties; properties = configuration.getProperties(); Assert.assertEquals("configuration-type", configuration.getType()); Assert.assertNotNull(properties); Assert.assertEquals(2, properties.size()); Assert.assertEquals("${property-value1}", properties.get("property1")); Assert.assertEquals("${property.value2}", properties.get("property2")); configuration.update(updatedConfiguration); properties = configuration.getProperties(); Assert.assertEquals("configuration-type", configuration.getType()); Assert.assertNotNull(properties); Assert.assertEquals(2, properties.size()); Assert.assertEquals("black", properties.get("property1")); Assert.assertEquals("white", properties.get("property2")); updatedConfiguration.setType("updated-type"); configuration.update(updatedConfiguration); Assert.assertEquals("updated-type", configuration.getType()); Assert.assertNotNull(properties); Assert.assertEquals(2, properties.size()); Assert.assertEquals("black", properties.get("property1")); Assert.assertEquals("white", properties.get("property2")); }