### Question:
UpgradeCatalog270 extends AbstractUpgradeCatalog { @Override protected void updateKerberosDescriptorArtifact(ArtifactDAO artifactDAO, ArtifactEntity artifactEntity) throws AmbariException { if (artifactEntity == null) { return; } Map<String, Object> data = artifactEntity.getArtifactData(); if (data == null) { return; } final KerberosDescriptor kerberosDescriptor = new KerberosDescriptorFactory().createInstance(data); if (kerberosDescriptor == null) { return; } final boolean updateInfraKerberosDescriptor = updateInfraKerberosDescriptor(kerberosDescriptor); final boolean updateWebHCatHostKerberosDescriptor = updateWebHCatHostKerberosDescriptor(kerberosDescriptor); final boolean updateYarnKerberosDescriptor = updateYarnKerberosDescriptor(kerberosDescriptor); if (updateInfraKerberosDescriptor || updateWebHCatHostKerberosDescriptor || updateYarnKerberosDescriptor) { artifactEntity.setArtifactData(kerberosDescriptor.toMap()); artifactDAO.merge(artifactEntity); } } @Inject  UpgradeCatalog270(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); static final String[] COMPONENT_NAME_SERVICE_NAME_CLUSTER_ID_KEY_COLUMNS; static final String[] SERVICE_NAME_CLUSTER_ID_KEY_COLUMNS; static final String AMBARI_INFRA_OLD_NAME; static final String AMBARI_INFRA_NEW_NAME; static final String SERVICE_CONFIG_MAPPING_TABLE; static final String CLUSTER_CONFIG_TABLE; static final String FK_HOSTCOMPONENTDESIREDSTATE_COMPONENT_NAME; static final String FK_HOSTCOMPONENTSTATE_COMPONENT_NAME; static final String FK_SERVICECOMPONENTDESIREDSTATE_SERVICE_NAME; }### Answer:
@Test public void testupdateKerberosDescriptorArtifact() throws Exception { String kerberosDescriptorJson = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("org/apache/ambari/server/upgrade/kerberos_descriptor.json"), "UTF-8"); assertTrue(kerberosDescriptorJson.contains("${clusterHostInfo/webhcat_server_host|append(core-site/hadoop.proxyuser.HTTP.hosts, \\\\\\\\,, true)}")); assertTrue(kerberosDescriptorJson.contains("${clusterHostInfo/rm_host}")); ArtifactEntity artifactEntity = new ArtifactEntity(); artifactEntity.setArtifactName("kerberos_descriptor"); artifactEntity.setArtifactData(GSON.<Map<String, Object>>fromJson(kerberosDescriptorJson, Map.class)); UpgradeCatalog270 upgradeCatalog270 = createMockBuilder(UpgradeCatalog270.class).createMock(); expect(artifactDAO.merge(artifactEntity)).andReturn(artifactEntity); replay(upgradeCatalog270); upgradeCatalog270.updateKerberosDescriptorArtifact(artifactDAO, artifactEntity); final String newKerberosDescriptorJson = GSON.toJson(artifactEntity.getArtifactData()); int oldCount = substringCount(kerberosDescriptorJson, AMBARI_INFRA_OLD_NAME); int newCount = substringCount(newKerberosDescriptorJson, AMBARI_INFRA_NEW_NAME); assertThat(newCount, is(oldCount)); assertTrue(newKerberosDescriptorJson.contains("${clusterHostInfo/webhcat_server_hosts|append(core-site/hadoop.proxyuser.HTTP.hosts, \\\\,, true)}")); assertTrue(newKerberosDescriptorJson.contains("${clusterHostInfo/resourcemanager_hosts}")); verify(upgradeCatalog270); }