ConfigUpgradePack { public Map<String, ConfigUpgradeChangeDefinition> enumerateConfigChangesByID() { if (changesById == null) { changesById = new HashMap<>(); for(AffectedService service : services) { for(AffectedComponent component: service.components) { for (ConfigUpgradeChangeDefinition changeDefinition : component.changes) { if (changeDefinition.id == null) { LOG.warn(String.format("Config upgrade change definition for service %s," + " component %s has no id", service.name, component.name)); } else if (changesById.containsKey(changeDefinition.id)) { LOG.warn("Duplicate config upgrade change definition with ID " + changeDefinition.id); } changesById.put(changeDefinition.id, changeDefinition); } } } } return changesById; } ConfigUpgradePack();  ConfigUpgradePack(List<AffectedService> services); Map<String, AffectedService> getServiceMap(); Map<String, ConfigUpgradeChangeDefinition> enumerateConfigChangesByID(); static ConfigUpgradePack merge(ArrayList<ConfigUpgradePack> cups); @XmlElementWrapper(name="services")
  @XmlElement(name="service")
  public List<AffectedService> services; }
@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()); 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)); }