StormShutdownWarning extends AbstractCheckDescriptor { @Override public boolean isApplicable(PrereqCheckRequest request) throws AmbariException { boolean isApplicable = super.isApplicable(request, Arrays.asList("STORM"), true); return isApplicable && request.getUpgradeType() == UpgradeType.ROLLING; } StormShutdownWarning(); @Override boolean isApplicable(PrereqCheckRequest request); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request);  }
@Test public void testIsApplicable() throws Exception { final StormShutdownWarning shutdownWarning = new StormShutdownWarning(); shutdownWarning.clustersProvider = new Provider<Clusters>() { @Override public Clusters get() { return m_clusters; } }; final Cluster cluster = niceMock(Cluster.class); final Service hive = niceMock(Service.class); final Map<String, Service> services = new HashMap<>(); services.put("STORM", hive); EasyMock.expect(cluster.getClusterId()).andReturn(1L).anyTimes(); EasyMock.expect(cluster.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.3")).anyTimes(); EasyMock.expect(cluster.getServices()).andReturn(services).atLeastOnce(); EasyMock.expect(m_clusters.getCluster(m_clusterName)).andReturn(cluster).atLeastOnce(); PrereqCheckRequest request = niceMock(PrereqCheckRequest.class); EasyMock.expect(request.getClusterName()).andReturn(m_clusterName); EasyMock.expect(request.getUpgradeType()).andReturn(UpgradeType.ROLLING); replayAll(); Assert.assertTrue(shutdownWarning.isApplicable(request)); verifyAll(); }