ApiManager implements IApiManager { @Override public List<ApiRestartRequiredService> getRestartRequiredServices(String clusterName) throws AmbariApiException { Map<String, ApiRestartRequiredService> apiRestartRequiredServicesMap = new HashMap<String, ApiRestartRequiredService>(); Response response = null; try { String fields = "HostRoles/*,&minimal_response=true"; String staleConfigs = "true"; response = apiResourceRootV1.getClustersResource().getHostComponentsResource(clusterName).readComponentsAfterConfigChange(fields, staleConfigs); } catch (Exception e) { throw AmbariApiException.CANNOT_CONNECT_AMBARI_SERVER(e); } String apiComponentListJson = handleAmbariResponse(response); ApiComponentList apiComponentList = ApiUtils.jsonToObject(ApiComponentList.class, apiComponentListJson); for (ApiComponent apiComponent : apiComponentList.getComponents()) { ApiComponentInfo apiComponentInfo = apiComponent.getHostComponent(); String serviceName = apiComponentInfo.getServiceName(); ApiRestartRequiredService apiRestartRequiredService = new ApiRestartRequiredService(); if (apiRestartRequiredServicesMap.containsKey(serviceName)) { apiRestartRequiredService = apiRestartRequiredServicesMap.get(serviceName); } apiRestartRequiredService.setName(serviceName); String componentName = apiComponentInfo.getComponentName(); String host = apiComponentInfo.getHostName(); List<ApiRestartRequiredCompent> apiRestartRequiredCompents = apiRestartRequiredService.getApiRestartRequiredCompents(); if (apiRestartRequiredCompents == null) { apiRestartRequiredCompents = new ArrayList<ApiRestartRequiredCompent> (); } boolean isExisted = false; for (ApiRestartRequiredCompent apiRestartRequiredCompent : apiRestartRequiredCompents) { if (apiRestartRequiredCompent.getName().equals(componentName)) { apiRestartRequiredCompent.addHost(host); isExisted = true; break; } } if(!isExisted) { ApiRestartRequiredCompent apiRestartRequiredCompent = new ApiRestartRequiredCompent(); apiRestartRequiredCompent.setName(componentName); apiRestartRequiredCompent.addHost(host); apiRestartRequiredCompents.add(apiRestartRequiredCompent); } apiRestartRequiredService.setApiRestartRequiredCompents(apiRestartRequiredCompents); apiRestartRequiredServicesMap.put(serviceName, apiRestartRequiredService); } List<ApiRestartRequiredService> apiRestartRequiredServices = new ArrayList<ApiRestartRequiredService>(); apiRestartRequiredServices.addAll(apiRestartRequiredServicesMap.values()); return apiRestartRequiredServices; } ApiManager(String amServerHost, int port, String user, String password);  ApiManager(URL baseUrl, String user, String password);  ApiManager(AmbariManagerClientbuilder clientbuilder); @Override ApiStackList getStackList(); @Override ApiStack getStack(String stackName); @Override ApiService readService(String clusterName, String serviceName); @Override boolean isServiceStarted(String clusterName, String serviceName); @Override ApiStackVersionList getStackVersionList(String stackName); @Override ApiStackVersion getStackVersion(String stackName, String stackVersion); @Override ApiStackServiceList getStackServiceList(String stackName,
         String stackVersion); @Override ApiStackServiceList getStackServiceListWithComponents(
         String stackName, String stackVersion); @Override ApiStackServiceList getStackServiceListWithConfigurations(
         String stackName, String stackVersion); @Override ApiStackService getStackServiceWithComponents(String stackName,
         String stackVersion, String serviceName); List<ApiConfiguration> getServiceConfiguration(String stackName,
         String stackVersion, String serviceName); @Override ApiStackService getStackService(String stackName,
         String stackVersion, String stackServiceName); @Override ApiStackComponentList getStackComponentList(String stackName,
         String stackVersion, String stackServiceName); @Override ApiStackComponent getStackComponent(String stackName,
         String stackVersion, String stackServiceName, String stackComponentName); @Override ApiClusterList getClusterList(); @Override ApiCluster getCluster(String clusterName); @Override List<ApiService> getClusterServices(String clusterName); @Override ApiRequest stopAllServicesInCluster(String clusterName); @Override ApiRequest startAllServicesInCluster(String clusterName); ApiRequest decommissionComponent(String clusterName, String host, String serviceName, String managementRoleName, String slaveRoleName); @Override List<String> getClusterServicesNames(String clusterName); @Override ApiRequest provisionCluster(String clusterName,
         ApiClusterBlueprint apiClusterBlueprint); @Override ApiBlueprintList getBlueprintList(); @Override ApiBlueprint getBlueprint(String blueprintName); @Override ApiBlueprint createBlueprint(String blueprintName,
         ApiBlueprint apiBlueprint); boolean updatePersist(ApiPersist persist); @Override ApiRequest deleteHost(String clusterName, String fqdn); @Override boolean deleteBlueprint(String blueprintName); @Override boolean deleteCluster(String clusterName); @Override ApiRequestList getRequestList(String clusterName); @Override ApiRequest getRequest(String clusterName, Long requestId); @Override ApiBootstrap createBootstrap(ApiBootstrap bootstrap); @Override ApiBootstrapStatus getBootstrapStatus(Long bootstrapId); @Override ApiRequest getRequestWithTasks(String clusterName, Long requestId); @Override ServiceStatus getClusterStatus(String clusterName, HadoopStack stack); @Override Map<String, ServiceStatus> getHostStatus(String clusterName); @Override ApiHostList getHostsSummaryInfo(String clusterName); List<ApiHostComponent> getHostComponents(String clusterName, String hostName); @Override String healthCheck(); @Override String getVersion(); @Override boolean deleteService(String clusterName, String serviceName); @Override List<String> getExistingHosts(String clusterName,
         List<String> hostNames); @Override void addHostsToCluster(String clusterName, List<String> hostNames); @Override ApiHostList getClusterHostsList(String clusterName); @Override ApiRequest stopAllComponentsInHosts(String clusterName,
         List<String> hostNames); @Override void deleteAllComponents(String clusterName, String hostName); @Override List<String> getAssociatedConfigGroups(String clusterName,
         String hostName); ApiConfigGroupList getConfigGroupsList(String clusterName); @Override void deleteConfigGroup(String clusterName, String groupId); ApiClusterConfigurations getClusterConfigurationsWithTypeAndTag(String clusterName, String type, String tag); @Override ApiRequest startComponents(String clusterName,
         List<String> hostNames, List<String> components); @Override void createConfigGroups(String clusterName,
         List<ApiConfigGroup> configGroups); ApiConfigGroup readConfigGroup(String clusterName, String configGroupId); void updateConfigGroup(String clusterName, String groupId,
         ApiConfigGroup configGroup); @Override void addComponents(String clusterName, List<String> hostNames,
         ApiHostComponentsRequest components); @Override ApiRequest installComponents(String clusterName); @Override ApiStackServiceList getStackWithCompAndConfigs(String stackName,
         String stackVersion); @Override ApiHostList getRegisteredHosts(); @Override ApiStackServiceList getServicesWithFilter(String stackName,
         String stackVersion, String filter); @Override List<ApiRequest> restartRequiredServices(String clusterName); @Override ApiRequest restartRequiredService(String clusterName, ApiRestartRequiredService apiRestartRequiredService); @Override List<ApiRestartRequiredService> getRestartRequiredServices(String clusterName); @Override void setClusterHostsRackInfo(String clusterName, String rackInfo, Set<String> hosts);  }
@Test public void testGetRestartRequiredServices() throws Exception { List<ApiRestartRequiredService> apiRestartRequiredServices = apiManager.getRestartRequiredServices(clusterName); Assert.assertNotNull(apiRestartRequiredServices); }