ServicesMapReduceDistributedCacheCheck extends AbstractCheckDescriptor { @Override public boolean isApplicable(PrereqCheckRequest request) throws AmbariException { if (!super.isApplicable(request, Arrays.asList("YARN"), true)) { return false; } PrereqCheckStatus ha = request.getResult(CheckDescription.SERVICES_NAMENODE_HA); if (null != ha && ha == PrereqCheckStatus.FAIL) { return false; } return true; } ServicesMapReduceDistributedCacheCheck(); @Override boolean isApplicable(PrereqCheckRequest request); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request);  }
@Test public void testIsApplicable() throws Exception { final Cluster cluster = Mockito.mock(Cluster.class); final Map<String, Service> services = new HashMap<>(); final Service service = Mockito.mock(Service.class); services.put("YARN", service); Mockito.when(cluster.getServices()).thenReturn(services); Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster); Mockito.when(cluster.getClusterId()).thenReturn(1L); Assert.assertTrue(servicesMapReduceDistributedCacheCheck.isApplicable(new PrereqCheckRequest("cluster"))); PrereqCheckRequest req = new PrereqCheckRequest("cluster"); req.addResult(CheckDescription.SERVICES_NAMENODE_HA, PrereqCheckStatus.FAIL); Assert.assertFalse(servicesMapReduceDistributedCacheCheck.isApplicable(req)); req.addResult(CheckDescription.SERVICES_NAMENODE_HA, PrereqCheckStatus.PASS); Assert.assertTrue(servicesMapReduceDistributedCacheCheck.isApplicable(req)); services.remove("YARN"); Assert.assertFalse(servicesMapReduceDistributedCacheCheck.isApplicable(new PrereqCheckRequest("cluster"))); }