@Test
  public void testProcessClusterConfigRequestRemoveUnusedConfigTypes() throws Exception {
    // GIVEN
    Configuration configuration = createConfigurations();
    Set<String> services = new HashSet<>();
    services.add("HDFS");
    services.add("RANGER");
    Map<String, HostGroupInfo> hostGroupInfoMap = Maps.newHashMap();
    HostGroupInfo hg1 = new HostGroupInfo("hg1");
    hg1.setConfiguration(createConfigurationsForHostGroup());
    hostGroupInfoMap.put("hg1", hg1);

    expect(topology.getAmbariContext()).andReturn(ambariContext).anyTimes();
    expect(topology.getConfiguration()).andReturn(configuration).anyTimes();
    expect(topology.getBlueprint()).andReturn(blueprint).anyTimes();
    expect(topology.getHostGroupInfo()).andReturn(hostGroupInfoMap);
    expect(blueprint.getStack()).andReturn(stack).anyTimes();
    expect(blueprint.getServices()).andReturn(services).anyTimes();

    expect(blueprint.isValidConfigType("hdfs-site")).andReturn(true).anyTimes();
    expect(blueprint.isValidConfigType("admin-properties")).andReturn(true).anyTimes();
    expect(blueprint.isValidConfigType("yarn-site")).andReturn(false).anyTimes();
    expect(blueprint.isValidConfigType("cluster-env")).andReturn(true).anyTimes();
    expect(blueprint.isValidConfigType("global")).andReturn(true).anyTimes();

    expect(ambariContext.getConfigHelper()).andReturn(configHelper).anyTimes();

    expect(configHelper.getDefaultStackProperties(
        EasyMock.eq(new StackId(STACK_NAME, STACK_VERSION)))).andReturn(stackProperties).anyTimes();

    EasyMock.replay(stack, blueprint, topology, ambariContext, configHelper);
    // WHEN
    new ClusterConfigurationRequest(ambariContext, topology, false, stackAdvisorBlueprintProcessor);
    // THEN
    assertFalse("YARN service not present in topology config thus 'yarn-site' config type should be removed from config.", configuration.getFullProperties().containsKey("yarn-site"));
    assertTrue("HDFS service is present in topology host group config thus 'hdfs-site' config type should be left in the config.", configuration.getFullAttributes().containsKey("hdfs-site"));
    assertTrue("'cluster-env' config type should not be removed from configuration.", configuration.getFullProperties().containsKey("cluster-env"));
    assertTrue("'global' config type should not be removed from configuration.", configuration.getFullProperties().containsKey("global"));

    assertFalse("SPARK service not present in topology host group config thus 'spark-env' config type should be removed from config.", hg1.getConfiguration().getFullAttributes().containsKey("spark-env"));
    assertTrue("HDFS service is present in topology host group config thus 'hdfs-site' config type should be left in the config.", hg1.getConfiguration().getFullAttributes().containsKey("hdfs-site"));
    verify(stack, blueprint, topology, ambariContext, configHelper);
  }
testConfigType config type shouldn't be in updatedConfigTypes, as testProperty in Blueprint is a custom value
(no default value in stack for testProperty)
==> Kerberos config property shouldn't be updated
@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java