@Test
  public void testServiceComponentRecoveryChanged() throws Exception {
    Cluster cluster = heartbeatTestHelper.getDummyCluster();
    RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(cluster);
    Service hdfs = cluster.addService(HDFS, repositoryVersion);

    hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);

    // Get the recovery configuration
    RecoveryConfig recoveryConfig = recoveryConfigHelper.getRecoveryConfig(cluster.getClusterName(), DummyHostname1);
    assertEquals(Lists.newArrayList(
      new RecoveryConfigComponent(DATANODE, HDFS, State.INIT)
    ), recoveryConfig.getEnabledComponents());

    // Turn off auto start for HDFS::DATANODE
    hdfs.getServiceComponent(DATANODE).setRecoveryEnabled(false);

    // Get the latest config. DATANODE should not be present.
    recoveryConfig = recoveryConfigHelper.getRecoveryConfig(cluster.getClusterName(), DummyHostname1);
    assertEquals(new ArrayList<RecoveryConfigComponent>(), recoveryConfig.getEnabledComponents());
  }
Disable recovery on a component and verify that the config is stale.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java