@Test
public void testRegistrationRecoveryConfigMaintenanceMode()
    throws Exception, InvalidStateTransitionException {

  ActionManager am = actionManagerTestHelper.getMockActionManager();
  replay(am);
  Clusters fsm = clusters;
  HeartBeatHandler handler = new HeartBeatHandler(fsm, new ActionQueue(), am,
          injector);
  Cluster cluster = heartbeatTestHelper.getDummyCluster();
  Service hdfs = cluster.addService(HDFS);
  /**
   * Add three service components enabled for auto start.
   */
  hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
  hdfs.getServiceComponent(DATANODE);
  hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
  hdfs.addServiceComponent(NAMENODE).setRecoveryEnabled(true);
  hdfs.getServiceComponent(NAMENODE);
  hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
  hdfs.addServiceComponent(HDFS_CLIENT).setRecoveryEnabled(true);
  hdfs.getServiceComponent(HDFS_CLIENT);
  hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1);
  Host hostObject = clusters.getHost(DummyHostname1);
  hostObject.setIPv4("ipv4");
  hostObject.setIPv6("ipv6");
  // set maintenance mode on HDFS_CLIENT on host1 to true
  ServiceComponentHost schHdfsClient = hdfs.getServiceComponent(HDFS_CLIENT).getServiceComponentHost(DummyHostname1);
  schHdfsClient.setMaintenanceState(MaintenanceState.ON);
  Register reg = new Register();
  HostInfo hi = new HostInfo();
  hi.setHostName(DummyHostname1);
  hi.setOS(DummyOsType);
  reg.setHostname(DummyHostname1);
  reg.setCurrentPingPort(DummyCurrentPingPort);
  reg.setHardwareProfile(hi);
  reg.setAgentVersion(metaInfo.getServerVersion());
  reg.setPrefix(Configuration.PREFIX_DIR);
  RegistrationResponse rr = handler.handleRegistration(reg);
  RecoveryConfig rc = rr.getRecoveryConfig();
  assertEquals(rc.getMaxCount(), "4");
  assertEquals(rc.getType(), "AUTO_START");
  assertEquals(rc.getMaxLifetimeCount(), "10");
  assertEquals(rc.getRetryGap(), "2");
  assertEquals(rc.getWindowInMinutes(), "23");
  assertEquals(rc.getEnabledComponents(), "DATANODE,NAMENODE"); // HDFS_CLIENT is in maintenance mode
}