### Question:
RequiredServicesInRepositoryCheck extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { String clusterName = request.getClusterName(); Cluster cluster = clustersProvider.get().getCluster(clusterName); VersionDefinitionXml xml = getVersionDefinitionXml(request); Set<String> missingDependencies = xml.getMissingDependencies(cluster); if (!missingDependencies.isEmpty()) { String failReasonTemplate = getFailReason(prerequisiteCheck, request); String message = String.format( "The following services are also required to be included in this upgrade: %s", StringUtils.join(missingDependencies, ", ")); prerequisiteCheck.setFailedOn(new LinkedHashSet<>(missingDependencies)); prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL); prerequisiteCheck.setFailReason(String.format(failReasonTemplate, message)); Set<ServiceDetail> missingServiceDetails = missingDependencies.stream().map( missingService -> new ServiceDetail(missingService)).collect( Collectors.toCollection(TreeSet::new)); prerequisiteCheck.getFailedDetail().addAll(missingServiceDetails); return; } prerequisiteCheck.setStatus(PrereqCheckStatus.PASS); } RequiredServicesInRepositoryCheck(); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request);  }### Answer:
@Test public void testNoMissingServices() throws Exception { PrereqCheckRequest request = new PrereqCheckRequest(CLUSTER_NAME); request.setTargetRepositoryVersion(m_repositoryVersion); PrerequisiteCheck check = new PrerequisiteCheck(null, CLUSTER_NAME); m_requiredServicesCheck.perform(check, request); Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus()); Assert.assertTrue(check.getFailedDetail().isEmpty()); }
@Test public void testMissingRequiredService() throws Exception { PrereqCheckRequest request = new PrereqCheckRequest(CLUSTER_NAME); request.setTargetRepositoryVersion(m_repositoryVersion); m_missingDependencies.add("BAR"); PrerequisiteCheck check = new PrerequisiteCheck(null, CLUSTER_NAME); m_requiredServicesCheck.perform(check, request); Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus()); Assert.assertFalse(check.getFailedDetail().isEmpty()); }