@Test public void testUpdateProperties() throws AmbariException { KerberosDescriptor oldValue = KERBEROS_DESCRIPTOR_FACTORY.createInstance("{" + " \"properties\": {" + " \"realm\": \"${kerberos-env/realm}\"," + " \"keytab_dir\": \"/etc/security/keytabs\"," + " \"additional_realms\": \"\"," + " \"old_property\": \"old_value\"" + " }" + "}"); KerberosDescriptor newValue = KERBEROS_DESCRIPTOR_FACTORY.createInstance("{" + " \"properties\": {" + " \"realm\": \"${kerberos-env/realm}\"," + " \"keytab_dir\": \"/etc/security/keytabs\"," + " \"additional_realms\": \"\"," + " \"new_property\": \"new_value\"" + " }" + "}"); KerberosDescriptor userValue = KERBEROS_DESCRIPTOR_FACTORY.createInstance("{" + " \"properties\": {" + " \"realm\": \"EXAMPLE.COM\"," + " \"keytab_dir\": \"/etc/security/keytabs\"," + " \"additional_realms\": \"\"," + " \"old_property\": \"old_value\"" + " }" + "}"); KerberosDescriptor updatedUserValue = KerberosDescriptorUpdateHelper.updateUserKerberosDescriptor( oldValue, newValue, userValue); Assert.assertEquals( KERBEROS_DESCRIPTOR_FACTORY.createInstance( "{\n" + " \"properties\": {\n" + " \"new_property\": \"new_value\",\n" + " \"realm\": \"EXAMPLE.COM\",\n" + " \"additional_realms\": \"\",\n" + " \"keytab_dir\": \"/etc/security/keytabs\"\n" + " }\n" + "}"), updatedUserValue); }
public static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor, KerberosDescriptor endingStackKerberosDescriptor, KerberosDescriptor userKerberosDescriptor) { KerberosDescriptor updated = new KerberosDescriptor(userKerberosDescriptor.toMap()); updated.setProperties(processProperties( beginningStackKerberosDescriptor.getProperties(), endingStackKerberosDescriptor.getProperties(), updated.getProperties())); updated.setConfigurations(processConfigurations( beginningStackKerberosDescriptor.getConfigurations(), endingStackKerberosDescriptor.getConfigurations(), updated.getConfigurations())); updated.setIdentities(processIdentities( beginningStackKerberosDescriptor.getIdentities(), endingStackKerberosDescriptor.getIdentities(), updated.getIdentities())); updated.setAuthToLocalProperties(processAuthToLocalProperties( beginningStackKerberosDescriptor.getAuthToLocalProperties(), endingStackKerberosDescriptor.getAuthToLocalProperties(), updated.getAuthToLocalProperties())); updated.setServices(processServices( beginningStackKerberosDescriptor.getServices(), endingStackKerberosDescriptor.getServices(), updated.getServices())); return updated; }
KerberosDescriptorUpdateHelper { public static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor, KerberosDescriptor endingStackKerberosDescriptor, KerberosDescriptor userKerberosDescriptor) { KerberosDescriptor updated = new KerberosDescriptor(userKerberosDescriptor.toMap()); updated.setProperties(processProperties( beginningStackKerberosDescriptor.getProperties(), endingStackKerberosDescriptor.getProperties(), updated.getProperties())); updated.setConfigurations(processConfigurations( beginningStackKerberosDescriptor.getConfigurations(), endingStackKerberosDescriptor.getConfigurations(), updated.getConfigurations())); updated.setIdentities(processIdentities( beginningStackKerberosDescriptor.getIdentities(), endingStackKerberosDescriptor.getIdentities(), updated.getIdentities())); updated.setAuthToLocalProperties(processAuthToLocalProperties( beginningStackKerberosDescriptor.getAuthToLocalProperties(), endingStackKerberosDescriptor.getAuthToLocalProperties(), updated.getAuthToLocalProperties())); updated.setServices(processServices( beginningStackKerberosDescriptor.getServices(), endingStackKerberosDescriptor.getServices(), updated.getServices())); return updated; } }
KerberosDescriptorUpdateHelper { public static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor, KerberosDescriptor endingStackKerberosDescriptor, KerberosDescriptor userKerberosDescriptor) { KerberosDescriptor updated = new KerberosDescriptor(userKerberosDescriptor.toMap()); updated.setProperties(processProperties( beginningStackKerberosDescriptor.getProperties(), endingStackKerberosDescriptor.getProperties(), updated.getProperties())); updated.setConfigurations(processConfigurations( beginningStackKerberosDescriptor.getConfigurations(), endingStackKerberosDescriptor.getConfigurations(), updated.getConfigurations())); updated.setIdentities(processIdentities( beginningStackKerberosDescriptor.getIdentities(), endingStackKerberosDescriptor.getIdentities(), updated.getIdentities())); updated.setAuthToLocalProperties(processAuthToLocalProperties( beginningStackKerberosDescriptor.getAuthToLocalProperties(), endingStackKerberosDescriptor.getAuthToLocalProperties(), updated.getAuthToLocalProperties())); updated.setServices(processServices( beginningStackKerberosDescriptor.getServices(), endingStackKerberosDescriptor.getServices(), updated.getServices())); return updated; }  }
KerberosDescriptorUpdateHelper { public static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor, KerberosDescriptor endingStackKerberosDescriptor, KerberosDescriptor userKerberosDescriptor) { KerberosDescriptor updated = new KerberosDescriptor(userKerberosDescriptor.toMap()); updated.setProperties(processProperties( beginningStackKerberosDescriptor.getProperties(), endingStackKerberosDescriptor.getProperties(), updated.getProperties())); updated.setConfigurations(processConfigurations( beginningStackKerberosDescriptor.getConfigurations(), endingStackKerberosDescriptor.getConfigurations(), updated.getConfigurations())); updated.setIdentities(processIdentities( beginningStackKerberosDescriptor.getIdentities(), endingStackKerberosDescriptor.getIdentities(), updated.getIdentities())); updated.setAuthToLocalProperties(processAuthToLocalProperties( beginningStackKerberosDescriptor.getAuthToLocalProperties(), endingStackKerberosDescriptor.getAuthToLocalProperties(), updated.getAuthToLocalProperties())); updated.setServices(processServices( beginningStackKerberosDescriptor.getServices(), endingStackKerberosDescriptor.getServices(), updated.getServices())); return updated; }  static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor,
                                                                KerberosDescriptor endingStackKerberosDescriptor,
                                                                KerberosDescriptor userKerberosDescriptor); }
KerberosDescriptorUpdateHelper { public static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor, KerberosDescriptor endingStackKerberosDescriptor, KerberosDescriptor userKerberosDescriptor) { KerberosDescriptor updated = new KerberosDescriptor(userKerberosDescriptor.toMap()); updated.setProperties(processProperties( beginningStackKerberosDescriptor.getProperties(), endingStackKerberosDescriptor.getProperties(), updated.getProperties())); updated.setConfigurations(processConfigurations( beginningStackKerberosDescriptor.getConfigurations(), endingStackKerberosDescriptor.getConfigurations(), updated.getConfigurations())); updated.setIdentities(processIdentities( beginningStackKerberosDescriptor.getIdentities(), endingStackKerberosDescriptor.getIdentities(), updated.getIdentities())); updated.setAuthToLocalProperties(processAuthToLocalProperties( beginningStackKerberosDescriptor.getAuthToLocalProperties(), endingStackKerberosDescriptor.getAuthToLocalProperties(), updated.getAuthToLocalProperties())); updated.setServices(processServices( beginningStackKerberosDescriptor.getServices(), endingStackKerberosDescriptor.getServices(), updated.getServices())); return updated; }  static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor,
                                                                KerberosDescriptor endingStackKerberosDescriptor,
                                                                KerberosDescriptor userKerberosDescriptor);  }