### Question:
ServicesMaintenanceModeCheck extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final Cluster cluster = clustersProvider.get().getCluster(request.getClusterName()); Set<String> servicesInUpgrade = getServicesInUpgrade(request); for (String serviceName : servicesInUpgrade) { final Service service = cluster.getService(serviceName); if (!service.isClientOnlyService() && service.getMaintenanceState() == MaintenanceState.ON) { prerequisiteCheck.getFailedOn().add(service.getName()); } } if (!prerequisiteCheck.getFailedOn().isEmpty()) { prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } } ServicesMaintenanceModeCheck(); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request);  }### Answer:
@Test public void testPerform() throws Exception { final ServicesMaintenanceModeCheck servicesMaintenanceModeCheck = new ServicesMaintenanceModeCheck(); servicesMaintenanceModeCheck.clustersProvider = new Provider<Clusters>() { @Override public Clusters get() { return clusters; } }; servicesMaintenanceModeCheck.ambariMetaInfo = new Provider<AmbariMetaInfo>() { @Override public AmbariMetaInfo get() { return Mockito.mock(AmbariMetaInfo.class); } }; final Cluster cluster = Mockito.mock(Cluster.class); Mockito.when(cluster.getClusterId()).thenReturn(1L); Mockito.when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP", "2.2")); Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster); final Service service = Mockito.mock(Service.class); Mockito.when(cluster.getServices()).thenReturn(Collections.singletonMap("service", service)); Mockito.when(service.isClientOnlyService()).thenReturn(false); Mockito.when(service.getDesiredState()).thenReturn(State.UNKNOWN); PrerequisiteCheck check = new PrerequisiteCheck(null, null); PrereqCheckRequest request = new PrereqCheckRequest("cluster"); request.setTargetRepositoryVersion(m_repositoryVersion); servicesMaintenanceModeCheck.perform(check, request); Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus()); Mockito.when(service.getDesiredState()).thenReturn(State.STARTED); check = new PrerequisiteCheck(null, null); servicesMaintenanceModeCheck.perform(check, request); Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus()); }