### Question:
AutoStartDisabledCheck extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { String autoStartEnabled = getProperty(request, CLUSTER_ENV_TYPE, RECOVERY_ENABLED_KEY); if (!Boolean.valueOf(autoStartEnabled)) { return; } String recoveryType = getProperty(request, CLUSTER_ENV_TYPE, RECOVERY_TYPE_KEY); if (StringUtils.equals(recoveryType, RECOVERY_AUTO_START)) { prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL); prerequisiteCheck.getFailedOn().add(request.getClusterName()); } } AutoStartDisabledCheck(); @Override Set<String> getApplicableServices(); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request);  }### Answer:
@Test public void testNoAutoStart() throws Exception { PrerequisiteCheck check = new PrerequisiteCheck(CheckDescription.AUTO_START_DISABLED, "foo"); PrereqCheckRequest request = new PrereqCheckRequest("cluster"); request.setTargetRepositoryVersion(repositoryVersionEntity); Assert.assertTrue(m_check.isApplicable(request)); m_check.perform(check, request); Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus()); Assert.assertTrue(StringUtils.isBlank(check.getFailReason())); }
@Test public void testAutoStartFalse() throws Exception { PrerequisiteCheck check = new PrerequisiteCheck(CheckDescription.AUTO_START_DISABLED, "foo"); PrereqCheckRequest request = new PrereqCheckRequest("cluster"); request.setTargetRepositoryVersion(repositoryVersionEntity); Assert.assertTrue(m_check.isApplicable(request)); m_configMap.put(AutoStartDisabledCheck.RECOVERY_ENABLED_KEY, "false"); m_check.perform(check, request); Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus()); Assert.assertTrue(StringUtils.isBlank(check.getFailReason())); }
@Test public void testAutoStartTrue() throws Exception { PrerequisiteCheck check = new PrerequisiteCheck(CheckDescription.AUTO_START_DISABLED, "foo"); PrereqCheckRequest request = new PrereqCheckRequest("cluster"); request.setTargetRepositoryVersion(repositoryVersionEntity); Assert.assertTrue(m_check.isApplicable(request)); m_configMap.put(AutoStartDisabledCheck.RECOVERY_ENABLED_KEY, "true"); m_configMap.put(AutoStartDisabledCheck.RECOVERY_TYPE_KEY, AutoStartDisabledCheck.RECOVERY_AUTO_START); m_check.perform(check, request); Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus()); Assert.assertTrue(StringUtils.isNotBlank(check.getFailReason())); Assert.assertEquals("Auto Start must be disabled before performing an Upgrade. To disable Auto Start, navigate to " + "Admin > Service Auto Start. Turn the toggle switch off to Disabled and hit Save.", check.getFailReason()); }