@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);
  // "old_property" is removed
  // "new_property" is added
  // "realm" retains user set value
  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);
}