### Question:
AbstractCheckDescriptor { public final boolean isApplicable(PrereqCheckRequest request) throws AmbariException { List<CheckQualification> qualifications = Lists.newArrayList( new ServiceQualification(), new OrchestrationQualification(getClass())); qualifications.addAll(getQualifications()); for (CheckQualification qualification : qualifications) { if (!qualification.isApplicable(request)) { return false; } } return true; } protected  AbstractCheckDescriptor(CheckDescription description); Set<String> getApplicableServices(); List<CheckQualification> getQualifications(); final boolean isApplicable(PrereqCheckRequest request); abstract void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request); CheckDescription getDescription(); PrereqCheckType getType(); boolean isRequired(UpgradeType upgradeType);  }### Answer:
@Test public void testIsApplicable() throws Exception{ final String clusterName = "c1"; final Cluster cluster = createMock(Cluster.class); Map<String, Service> services = new HashMap<String, Service>(){{ put("SERVICE1", null); put("SERVICE2", null); put("SERVICE3", null); }}; Set<String> oneServiceList = Sets.newHashSet("SERVICE1"); Set<String> atLeastOneServiceList = Sets.newHashSet("SERVICE1", "MISSING_SERVICE"); Set<String> allServicesList = Sets.newHashSet("SERVICE1", "SERVICE2"); Set<String> missingServiceList = Sets.newHashSet("MISSING_SERVICE"); expect(clusters.getCluster(anyString())).andReturn(cluster).atLeastOnce(); expect(cluster.getServices()).andReturn(services).atLeastOnce(); RepositoryVersionEntity repositoryVersion = createNiceMock(RepositoryVersionEntity.class); expect(repositoryVersion.getType()).andReturn(RepositoryType.STANDARD).anyTimes(); expect(repositoryVersion.getRepositoryXml()).andReturn(m_vdfXml).atLeastOnce(); expect(m_vdfXml.getClusterSummary(EasyMock.anyObject(Cluster.class))).andReturn( m_clusterVersionSummary).atLeastOnce(); expect(m_clusterVersionSummary.getAvailableServiceNames()).andReturn( allServicesList).atLeastOnce(); replayAll(); TestCheckImpl check = new TestCheckImpl(PrereqCheckType.SERVICE); PrereqCheckRequest request = new PrereqCheckRequest(clusterName, UpgradeType.ROLLING); request.setTargetRepositoryVersion(repositoryVersion); check.setApplicableServices(oneServiceList); Assert.assertTrue(check.isApplicable(request)); check.setApplicableServices(atLeastOneServiceList); Assert.assertTrue(check.isApplicable(request)); check.setApplicableServices(missingServiceList); Assert.assertFalse(check.isApplicable(request)); }