@Test public void testJSONWithOnlyServiceNameAndConfigurations() throws AmbariException { String JSON_VALUE_ONLY_NAME_AND_CONFIGS = "{" + " \"name\": \"SERVICE_NAME\"," + " \"configurations\": [" + " {" + " \"service-site\": {" + " \"service.property1\": \"value1\"," + " \"service.property2\": \"value2\"" + " }" + " }" + " ]" + "}"; TreeMap<String, Object> CHANGE_NAME = new TreeMap<String, Object>() {{ put("name", "A_DIFFERENT_SERVICE_NAME"); }}; KerberosServiceDescriptor serviceDescriptor = KERBEROS_SERVICE_DESCRIPTOR_FACTORY.createInstance("SERVICE_NAME", JSON_VALUE_ONLY_NAME_AND_CONFIGS); KerberosServiceDescriptor updatedServiceDescriptor = new KerberosServiceDescriptor(CHANGE_NAME); Assert.assertNotNull(serviceDescriptor); Assert.assertNotNull(updatedServiceDescriptor); serviceDescriptor.update(updatedServiceDescriptor); Assert.assertNotNull(serviceDescriptor); Assert.assertEquals("A_DIFFERENT_SERVICE_NAME", serviceDescriptor.getName()); }
public void update(KerberosServiceDescriptor updates) { if (updates != null) { Map<String, KerberosComponentDescriptor> updatedComponents = updates.getComponents(); if (updatedComponents != null) { for (Map.Entry<String, KerberosComponentDescriptor> entry : updatedComponents.entrySet()) { KerberosComponentDescriptor existing = getComponent(entry.getKey()); if (existing == null) { putComponent(entry.getValue()); } else { existing.update(entry.getValue()); } } } } super.update(updates); }
KerberosServiceDescriptor extends AbstractKerberosDescriptorContainer { public void update(KerberosServiceDescriptor updates) { if (updates != null) { Map<String, KerberosComponentDescriptor> updatedComponents = updates.getComponents(); if (updatedComponents != null) { for (Map.Entry<String, KerberosComponentDescriptor> entry : updatedComponents.entrySet()) { KerberosComponentDescriptor existing = getComponent(entry.getKey()); if (existing == null) { putComponent(entry.getValue()); } else { existing.update(entry.getValue()); } } } } super.update(updates); } }
KerberosServiceDescriptor extends AbstractKerberosDescriptorContainer { public void update(KerberosServiceDescriptor updates) { if (updates != null) { Map<String, KerberosComponentDescriptor> updatedComponents = updates.getComponents(); if (updatedComponents != null) { for (Map.Entry<String, KerberosComponentDescriptor> entry : updatedComponents.entrySet()) { KerberosComponentDescriptor existing = getComponent(entry.getKey()); if (existing == null) { putComponent(entry.getValue()); } else { existing.update(entry.getValue()); } } } } super.update(updates); } KerberosServiceDescriptor(Map<?, ?> data);   KerberosServiceDescriptor(String name, Map<?, ?> data); }
KerberosServiceDescriptor extends AbstractKerberosDescriptorContainer { public void update(KerberosServiceDescriptor updates) { if (updates != null) { Map<String, KerberosComponentDescriptor> updatedComponents = updates.getComponents(); if (updatedComponents != null) { for (Map.Entry<String, KerberosComponentDescriptor> entry : updatedComponents.entrySet()) { KerberosComponentDescriptor existing = getComponent(entry.getKey()); if (existing == null) { putComponent(entry.getValue()); } else { existing.update(entry.getValue()); } } } } super.update(updates); } KerberosServiceDescriptor(Map<?, ?> data);   KerberosServiceDescriptor(String name, Map<?, ?> data); @Override Collection<? extends AbstractKerberosDescriptorContainer> getChildContainers(); @Override AbstractKerberosDescriptorContainer getChildContainer(String name); Map<String, KerberosComponentDescriptor> getComponents(); KerberosComponentDescriptor getComponent(String name); void putComponent(KerberosComponentDescriptor component); void update(KerberosServiceDescriptor updates); @Override Map<String, Object> toMap(); @Override int hashCode(); @Override boolean equals(Object object); }
KerberosServiceDescriptor extends AbstractKerberosDescriptorContainer { public void update(KerberosServiceDescriptor updates) { if (updates != null) { Map<String, KerberosComponentDescriptor> updatedComponents = updates.getComponents(); if (updatedComponents != null) { for (Map.Entry<String, KerberosComponentDescriptor> entry : updatedComponents.entrySet()) { KerberosComponentDescriptor existing = getComponent(entry.getKey()); if (existing == null) { putComponent(entry.getValue()); } else { existing.update(entry.getValue()); } } } } super.update(updates); } KerberosServiceDescriptor(Map<?, ?> data);   KerberosServiceDescriptor(String name, Map<?, ?> data); @Override Collection<? extends AbstractKerberosDescriptorContainer> getChildContainers(); @Override AbstractKerberosDescriptorContainer getChildContainer(String name); Map<String, KerberosComponentDescriptor> getComponents(); KerberosComponentDescriptor getComponent(String name); void putComponent(KerberosComponentDescriptor component); void update(KerberosServiceDescriptor updates); @Override Map<String, Object> toMap(); @Override int hashCode(); @Override boolean equals(Object object);  }