@Test
  public void testConfigUpgradeDefinitionParsing() throws Exception {
    ConfigUpgradePack cup = ambariMetaInfo.getConfigUpgradePack("HDP", "2.1.1");
    Map<String, ConfigUpgradeChangeDefinition> changesByID = cup.enumerateConfigChangesByID();

    ConfigUpgradeChangeDefinition hdp_2_1_1_nm_pre_upgrade = changesByID.get("hdp_2_1_1_nm_pre_upgrade");
    assertEquals("core-site", hdp_2_1_1_nm_pre_upgrade.getConfigType());
    assertEquals(4, hdp_2_1_1_nm_pre_upgrade.getTransfers().size());

    /*
            <transfer operation="COPY" from-key="copy-key" to-key="copy-key-to" />
            <transfer operation="COPY" from-type="my-site" from-key="my-copy-key" to-key="my-copy-key-to" />
            <transfer operation="MOVE" from-key="move-key" to-key="move-key-to" />
            <transfer operation="DELETE" delete-key="delete-key">
              <keep-key>important-key</keep-key>
            </transfer>
    */
    ConfigUpgradeChangeDefinition.Transfer t1 = hdp_2_1_1_nm_pre_upgrade.getTransfers().get(0);
    assertEquals(TransferOperation.COPY, t1.operation);
    assertEquals("copy-key", t1.fromKey);
    assertEquals("copy-key-to", t1.toKey);

    ConfigUpgradeChangeDefinition.Transfer t2 = hdp_2_1_1_nm_pre_upgrade.getTransfers().get(1);
    assertEquals(TransferOperation.COPY, t2.operation);
    assertEquals("my-site", t2.fromType);
    assertEquals("my-copy-key", t2.fromKey);
    assertEquals("my-copy-key-to", t2.toKey);
    assertTrue(t2.keepKeys.isEmpty());

    ConfigUpgradeChangeDefinition.Transfer t3 = hdp_2_1_1_nm_pre_upgrade.getTransfers().get(2);
    assertEquals(TransferOperation.MOVE, t3.operation);
    assertEquals("move-key", t3.fromKey);
    assertEquals("move-key-to", t3.toKey);

    ConfigUpgradeChangeDefinition.Transfer t4 = hdp_2_1_1_nm_pre_upgrade.getTransfers().get(3);
    assertEquals(TransferOperation.DELETE, t4.operation);
    assertEquals("delete-key", t4.deleteKey);
    assertNull(t4.toKey);
    assertTrue(t4.preserveEdits);
    assertEquals(1, t4.keepKeys.size());
    assertEquals("important-key", t4.keepKeys.get(0));

  }
Tests for the config upgrade pack
ambari-server/src/test/java/org/apache/ambari/server/state/stack/ConfigUpgradePackTest.java